ML_VAR_PARTITION: adjust model threshold
authorHui Su <huisu@google.com>
Wed, 3 Oct 2018 16:07:07 +0000 (09:07 -0700)
committerHui Su <huisu@google.com>
Fri, 5 Oct 2018 18:10:12 +0000 (11:10 -0700)
Make decisions more aggressively to improve encoding speed.

Coding gains(avg-psnr) after this change over baseline:
rtc       1.55% for speed 7;  2.89% for speed 8.
ytlivehr  2.20% for speed 6.

Change-Id: If6ac4a942a5b4708bcc6b0a49bd92fbc4d67c3f8

vp9/encoder/vp9_encodeframe.c

index ad30951..9a2cd39 100644 (file)
@@ -4505,15 +4505,9 @@ static int ml_predict_var_paritioning(VP9_COMP *cpi, MACROBLOCK *x,
                                       int mi_col) {
   VP9_COMMON *const cm = &cpi->common;
   const NN_CONFIG *nn_config = NULL;
-  float thresh_low = -0.2f;
-  float thresh_high = 0.0f;
 
   switch (bsize) {
-    case BLOCK_64X64:
-      nn_config = &vp9_var_part_nnconfig_64;
-      thresh_low = -0.3f;
-      thresh_high = -0.1f;
-      break;
+    case BLOCK_64X64: nn_config = &vp9_var_part_nnconfig_64; break;
     case BLOCK_32X32: nn_config = &vp9_var_part_nnconfig_32; break;
     case BLOCK_16X16: nn_config = &vp9_var_part_nnconfig_16; break;
     case BLOCK_8X8: break;
@@ -4525,6 +4519,7 @@ static int ml_predict_var_paritioning(VP9_COMP *cpi, MACROBLOCK *x,
   vpx_clear_system_state();
 
   {
+    const float thresh = 0.0f;
     float features[FEATURES] = { 0.0f };
     const int dc_q = vp9_dc_quant(cm->base_qindex, 0, cm->bit_depth);
     int feature_idx = 0;
@@ -4565,8 +4560,8 @@ static int ml_predict_var_paritioning(VP9_COMP *cpi, MACROBLOCK *x,
 
     assert(feature_idx == FEATURES);
     nn_predict(features, nn_config, score);
-    if (score[0] > thresh_high) return 3;
-    if (score[0] < thresh_low) return 0;
+    if (score[0] > thresh) return PARTITION_SPLIT;
+    if (score[0] < thresh) return PARTITION_NONE;
     return -1;
   }
 }
@@ -4644,8 +4639,8 @@ static void nonrd_pick_partition(VP9_COMP *cpi, ThreadData *td,
     if (partition_none_allowed && do_split) {
       const int ml_predicted_partition =
           ml_predict_var_paritioning(cpi, x, bsize, mi_row, mi_col);
-      if (ml_predicted_partition == 0) do_split = 0;
-      if (ml_predicted_partition == 3) partition_none_allowed = 0;
+      if (ml_predicted_partition == PARTITION_NONE) do_split = 0;
+      if (ml_predicted_partition == PARTITION_SPLIT) partition_none_allowed = 0;
     }
   }
 #endif  // CONFIG_ML_VAR_PARTITION