]> granicus.if.org Git - libvpx/commitdiff
Add Tune for SSIM for high bitdepth encoding
authorsdeng <sdeng@google.com>
Thu, 11 Apr 2019 21:49:51 +0000 (14:49 -0700)
committersdeng <sdeng@google.com>
Sat, 13 Apr 2019 18:02:02 +0000 (11:02 -0700)
midres_bd10 test results:
avg_psnr  ssim     ms_ssim
3.189     -4.083   -5.258

Change-Id: I9faccc02f34692fc304d82241390f92267f5a72c

vp9/encoder/vp9_encoder.c
vp9/vp9_cx_iface.c

index f92c8a464141050ffdec3ac96996dfa2373d89a5..fd87e8670e8b44ee548535d9af4ff973ede1fb42 100644 (file)
@@ -4737,13 +4737,19 @@ static void set_frame_index(VP9_COMP *cpi, VP9_COMMON *cm) {
 // Technology, IEEE Transactions on, vol. 23, no. 7, pp. 1170-1181, 2013.
 // SSIM_VAR_SCALE defines the strength of the bias towards SSIM in RDO.
 // Some sample values are:
-// SSIM_VAR_SCALE  avg_psnr   ssim   ms_ssim  (for midres test set)
+// (for midres test set)
+// SSIM_VAR_SCALE  avg_psnr   ssim   ms_ssim
 //     16.0          2.312   -3.062  -3.882
 //     32.0          0.852   -2.260  -2.821
 //     64.0          0.294   -1.606  -1.925
+// (for midres_10bd test set)
+// SSIM_VAR_SCALE  avg_psnr   ssim   ms_ssim
+//      8.0          6.782   -3.872  -5.464
+//     16.0          3.189   -4.083  -5.258
+//     32.0          1.113   -3.423  -4.309
+//     64.0          0.241   -2.515  -3.074
 #define SSIM_VAR_SCALE 16.0
 static void set_mb_ssim_rdmult_scaling(VP9_COMP *cpi) {
-  const double c2 = 0.03 * 0.03 * 255 * 255;
   VP9_COMMON *cm = &cpi->common;
   ThreadData *td = &cpi->td;
   MACROBLOCK *x = &td->mb;
@@ -4759,6 +4765,19 @@ static void set_mb_ssim_rdmult_scaling(VP9_COMP *cpi) {
   double log_sum = 0.0;
   int row, col;
 
+#if CONFIG_VP9_HIGHBITDEPTH
+  double c2;
+  if (xd->bd == 10) {
+    c2 = 941.8761;  // (.03*1023)^2
+  } else if (xd->bd == 12) {
+    c2 = 15092.1225;  // (.03*4095)^2
+  } else {
+    c2 = 58.5225;  // (.03*255)^2
+  }
+#else
+  const double c2 = 58.5225;  // (.03*255)^2
+#endif
+
   // Loop through each 64x64 block.
   for (row = 0; row < num_rows; ++row) {
     for (col = 0; col < num_cols; ++col) {
@@ -4776,7 +4795,18 @@ static void set_mb_ssim_rdmult_scaling(VP9_COMP *cpi) {
 
           buf.buf = y_buffer + row_offset_y * y_stride + col_offset_y;
           buf.stride = y_stride;
-          var += vp9_get_sby_variance(cpi, &buf, BLOCK_8X8) / 64.0;
+
+          // In order to make SSIM_VAR_SCALE in a same scale for both 8 bit
+          // and high bit videos, the variance needs to be divided by 2.0 or
+          // 64.0 separately.
+#if CONFIG_VP9_HIGHBITDEPTH
+          if (cpi->Source->flags & YV12_FLAG_HIGHBITDEPTH)
+            var +=
+                vp9_high_get_sby_variance(cpi, &buf, BLOCK_8X8, xd->bd) / 2.0;
+          else
+#endif
+            var += vp9_get_sby_variance(cpi, &buf, BLOCK_8X8) / 64.0;
+
           num_of_var += 1.0;
         }
       }
index ab5d53d4a7d257630ae25ad045e50c488b5ca8f4..56588285670a9c05e069f6e42bccd4f5b4108189 100644 (file)
@@ -263,12 +263,6 @@ static vpx_codec_err_t validate_config(vpx_codec_alg_priv_t *ctx,
   RANGE_CHECK(extra_cfg, content, VP9E_CONTENT_DEFAULT,
               VP9E_CONTENT_INVALID - 1);
 
-  // TODO(sdeng): remove this when ssim tuning is implemented for highbd
-#if CONFIG_VP9_HIGHBITDEPTH
-  if (extra_cfg->tuning == VP8_TUNE_SSIM)
-    ERROR("Option --tune=ssim is not currently supported in highbd VP9.");
-#endif
-
 #if !CONFIG_REALTIME_ONLY
   if (cfg->g_pass == VPX_RC_LAST_PASS) {
     const size_t packet_sz = sizeof(FIRSTPASS_STATS);