summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorkabeer khan <kabeer.khan@samsung.com>2014-12-17 16:40:59 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2014-12-17 16:40:59 +0900
commit256761bf2f92d74639c665ed99e0b64c64caf8a5 (patch)
tree3a56a0c16b804e00d899b8e0ebcb3c11c4e80ef5 /src/modules
parentafb73157227b9625ac768a4bfd606383baf35218 (diff)
evas/tgv: Added DSSIM metric in evas_image_save_tgv
Summary: Resolved TODO to add DSSIM metric in DEBUG_STATS Signed-off-by: kabeer khan <kabeer.khan@samsung.com> Reviewers: cedric Subscribers: devilhorns, cedric Differential Revision: https://phab.enlightenment.org/D1773
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/evas/savers/tgv/evas_image_save_tgv.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/modules/evas/savers/tgv/evas_image_save_tgv.c b/src/modules/evas/savers/tgv/evas_image_save_tgv.c
index 306a6280c5..c730b24d67 100644
--- a/src/modules/evas/savers/tgv/evas_image_save_tgv.c
+++ b/src/modules/evas/savers/tgv/evas_image_save_tgv.c
@@ -193,7 +193,8 @@ evas_image_save_file_tgv(RGBA_Image *im,
193 193
194#ifdef DEBUG_STATS 194#ifdef DEBUG_STATS
195 struct timespec ts1, ts2; 195 struct timespec ts1, ts2;
196 long long tsdiff, mse = 0, mse_div = 0, mse_alpha = 0; 196 long long tsdiff, mse = 0, mse_div = 0, mse_alpha = 0, pixels_count = 0;
197 double mean_x = 0, mean_y = 0, var_x = 0, var_y = 0, cov_xy = 0;
197 clock_gettime(CLOCK_MONOTONIC, &ts1); 198 clock_gettime(CLOCK_MONOTONIC, &ts1);
198#endif 199#endif
199 200
@@ -464,6 +465,17 @@ evas_image_save_file_tgv(RGBA_Image *im,
464 const int b = (B_VAL(&(todo[k])) - B_VAL(&(done[k]))); 465 const int b = (B_VAL(&(todo[k])) - B_VAL(&(done[k])));
465 const int a = (A_VAL(&(todo[k])) - A_VAL(&(done[k]))); 466 const int a = (A_VAL(&(todo[k])) - A_VAL(&(done[k])));
466 mse += r*r + g*g + b*b; 467 mse += r*r + g*g + b*b;
468
469 /*refer http://planetmath.org/onepassalgorithmtocomputesamplevariance*/
470 const double delta_x = (double)todo[k] - mean_x;
471 const double delta_y = (double)done[k] - mean_y;
472 mean_x = mean_x + (double)(delta_x / (pixels_count + 1));
473 mean_y = mean_y + (double)(delta_y / (pixels_count + 1));
474 var_x = var_x + ((double)(todo[k] - mean_x) * delta_x);
475 var_y = var_y + ((double)(done[k] - mean_y) * delta_y);
476 cov_xy = cov_xy + ((double)(todo[k] - mean_x) * (double)(done[k] - mean_y));
477 pixels_count++;
478
467 if (alpha) mse_alpha += a*a; 479 if (alpha) mse_alpha += a*a;
468 mse_div++; 480 mse_div++;
469 } 481 }
@@ -509,7 +521,12 @@ evas_image_save_file_tgv(RGBA_Image *im,
509#ifdef DEBUG_STATS 521#ifdef DEBUG_STATS
510 if (mse_div && mse) 522 if (mse_div && mse)
511 { 523 {
512 // TODO: Add DSSIM too 524 /* Calculating dssim http://en.wikipedia.org/wiki/Structural_similarity */
525 double c1 = 0.01 * 255.0;
526 double c2 = 0.03 * 255.0;
527 double temp = (mean_x * mean_x + mean_y * mean_y + c1) * (var_x * var_x + var_y * var_y + c2);
528 double ssim = (2 * mean_x * mean_y + c1) * ( 2 * cov_xy + c2) / temp;
529 double dssim = (1 - ssim) / 2.0;
513 double dmse = (double) mse / (double) (mse_div * 3.0); 530 double dmse = (double) mse / (double) (mse_div * 3.0);
514 double psnr = 20 * log10(255.0) - 10 * log10(dmse); 531 double psnr = 20 * log10(255.0) - 10 * log10(dmse);
515 double dmse_alpha = (double) mse_alpha / (double) mse_div; 532 double dmse_alpha = (double) mse_alpha / (double) mse_div;
@@ -518,8 +535,8 @@ evas_image_save_file_tgv(RGBA_Image *im,
518 tsdiff = ((ts2.tv_sec - ts1.tv_sec) * 1000LL) + ((ts2.tv_nsec - ts1.tv_nsec) / 1000000LL); 535 tsdiff = ((ts2.tv_sec - ts1.tv_sec) * 1000LL) + ((ts2.tv_nsec - ts1.tv_nsec) / 1000000LL);
519 if (!alpha) 536 if (!alpha)
520 { 537 {
521 INF("ETC%d encoding stats: %dx%d, Time: %lldms, RGB PSNR: %.02fdB", 538 INF("ETC%d encoding stats: %dx%d, Time: %lldms, RGB PSNR: %.02fdB DSSIM: %.02f",
522 alpha ? 2 : 1, image_stride, image_height, tsdiff, psnr); 539 alpha ? 2 : 1, image_stride, image_height, tsdiff, psnr, dssim);
523 } 540 }
524 else 541 else
525 { 542 {