shithub: libvpx

Download patch

ref: 45e8e4a01fb95713fdc8a85c65532200e41dac47
parent: 5016e59e8b367f78a064a0c95786dcdcee9c4b80
parent: c0423abf003ac598fffae0638a9234be6819902d
author: Yunqing Wang <yunqingwang@google.com>
date: Tue Mar 17 12:05:53 EDT 2015

Merge "Refactor set vbp thresholds function"

--- a/vp9/encoder/vp9_encodeframe.c
+++ b/vp9/encoder/vp9_encodeframe.c
@@ -480,32 +480,34 @@
     return;
   } else {
     VP9_COMMON *const cm = &cpi->common;
-    const VP9EncoderConfig *const oxcf = &cpi->oxcf;
     const int is_key_frame = (cm->frame_type == KEY_FRAME);
-    const int use_4x4_partition = is_key_frame;
-    const int low_res = (cm->width <= 352 && cm->height <= 288);
     const int threshold_multiplier = is_key_frame ? 80 : 4;
     const int64_t threshold_base = (int64_t)(threshold_multiplier *
         vp9_convert_qindex_to_q(q, cm->bit_depth));
-    cpi->vbp_threshold = threshold_base;
-    cpi->vbp_threshold_bsize_min = threshold_base << oxcf->speed;
-    cpi->vbp_threshold_bsize_max = threshold_base;
 
-    if (is_key_frame) {
-      cpi->vbp_threshold = threshold_base >> 2;
-      cpi->vbp_threshold_bsize_min = threshold_base << 2;
-    } else if (low_res) {
-      cpi->vbp_threshold_bsize_min = threshold_base << 3;
-      cpi->vbp_threshold_bsize_max = threshold_base >> 2;
-    }
     // TODO(marpan): Allow 4x4 partitions for inter-frames.
     // use_4x4_partition = (variance4x4downsample[i2 + j] == 1);
     // If 4x4 partition is not used, then 8x8 partition will be selected
     // if variance of 16x16 block is very high, so use larger threshold
     // for 16x16 (threshold_bsize_min) in that case.
-    cpi->vbp_threshold_16x16 = (use_4x4_partition) ?
-      cpi->vbp_threshold : cpi->vbp_threshold_bsize_min;
-    cpi->vbp_bsize_min = (use_4x4_partition) ? BLOCK_8X8 : BLOCK_16X16;
+    if (is_key_frame) {
+      cpi->vbp_threshold = threshold_base >> 2;
+      cpi->vbp_threshold_bsize_max = threshold_base;
+      cpi->vbp_threshold_bsize_min = threshold_base << 2;
+      cpi->vbp_threshold_16x16 = cpi->vbp_threshold;
+      cpi->vbp_bsize_min = BLOCK_8X8;
+    } else {
+      cpi->vbp_threshold = threshold_base;
+      if (cm->width <= 352 && cm->height <= 288) {
+        cpi->vbp_threshold_bsize_max = threshold_base >> 2;
+        cpi->vbp_threshold_bsize_min = threshold_base << 3;
+      } else {
+        cpi->vbp_threshold_bsize_max = threshold_base;
+        cpi->vbp_threshold_bsize_min = threshold_base << cpi->oxcf.speed;
+      }
+      cpi->vbp_threshold_16x16 = cpi->vbp_threshold_bsize_min;
+      cpi->vbp_bsize_min = BLOCK_16X16;
+    }
   }
 }