From 99893f2410f618b712037db4d3ec60e81aa9de1f Mon Sep 17 00:00:00 2001
From: Jingning Han <jingning@google.com>
Date: Fri, 28 Mar 2014 17:42:45 -0700
Subject: [PATCH] Apply finer quantizer to partition search frames in non-RD
 flow

This commit optimizes the bit allocation for the non-RD coding flow.
It applies slightly better quantizer to the frames, where all blocks
run a non-RD partition search. Such frames typically have better
rate-distortion trade off, thus improving the reconstruction quality
for next few frames reference at reasonably low increment in rate
cost.

The coding performance for rtc set at speed -5 with error-resilient
tuned on and rate control set as cbr is improved by 19.58%. It improved
the coding speed by about 10% for a portion of local test clips.

Change-Id: I9d56696cd4359dc8136ca10aff10fff05aaa2686
---
 vp9/encoder/vp9_encodeframe.c | 1 +
 vp9/encoder/vp9_onyx_if.c     | 4 ++--
 vp9/encoder/vp9_ratectrl.c    | 3 +++
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/vp9/encoder/vp9_encodeframe.c b/vp9/encoder/vp9_encodeframe.c
index 1e5890cda0..4939e698a9 100644
--- a/vp9/encoder/vp9_encodeframe.c
+++ b/vp9/encoder/vp9_encodeframe.c
@@ -1377,6 +1377,7 @@ static void copy_partitioning(VP9_COMMON *cm, MODE_INFO **mi_8x8,
     for (block_col = 0; block_col < 8; ++block_col) {
       MODE_INFO *const prev_mi = prev_mi_8x8[block_row * mis + block_col];
       const BLOCK_SIZE sb_type = prev_mi ? prev_mi->mbmi.sb_type : 0;
+
       if (prev_mi) {
         const ptrdiff_t offset = prev_mi - cm->prev_mi;
         mi_8x8[block_row * mis + block_col] = cm->mi + offset;
diff --git a/vp9/encoder/vp9_onyx_if.c b/vp9/encoder/vp9_onyx_if.c
index 0808ec4897..f112fa24f1 100644
--- a/vp9/encoder/vp9_onyx_if.c
+++ b/vp9/encoder/vp9_onyx_if.c
@@ -2673,6 +2673,8 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
   vp9_write_yuv_frame(cpi->Source);
 #endif
 
+  set_speed_features(cpi);
+
   // Decide q and q bounds.
   q = vp9_rc_pick_q_and_bounds(cpi, &bottom_index, &top_index);
 
@@ -2682,8 +2684,6 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
     set_high_precision_mv(cpi, q < HIGH_PRECISION_MV_QTHRESH);
   }
 
-  set_speed_features(cpi);
-
   if (cpi->sf.recode_loop == DISALLOW_RECODE) {
     encode_without_recode_loop(cpi, size, dest, q);
   } else {
diff --git a/vp9/encoder/vp9_ratectrl.c b/vp9/encoder/vp9_ratectrl.c
index c62d31293c..3c8baad791 100644
--- a/vp9/encoder/vp9_ratectrl.c
+++ b/vp9/encoder/vp9_ratectrl.c
@@ -985,6 +985,9 @@ int vp9_rc_pick_q_and_bounds(const VP9_COMP *cpi,
       q /= 3;
     if (q == 0)
       q++;
+    if (cpi->sf.partition_check == 1)
+      q -= 10;
+
     if (q < *bottom_index)
       *bottom_index = q;
     else if (q > *top_index)
-- 
GitLab