shithub: libvpx

Download patch

ref: ae9023a3c915a95e13e96721888b174d68c83553
parent: be360d47f412424e1bf1d645860ccabdad2f3343
author: Paul Wilkins <paulwilkins@google.com>
date: Mon Dec 12 06:18:57 EST 2011

QINDEX_RANGE fixed tables.

Removed a couple more fixed tables for the extended quantizer experiment
that depend on QINDEX_RANGE.

Change-Id: I2c15ffc7488c2a2b8d6504e2c4b6b2339799d117

--- a/vp8/encoder/firstpass.c
+++ b/vp8/encoder/firstpass.c
@@ -63,21 +63,28 @@
 static int vscale_lookup[7] = {0, 1, 1, 2, 2, 3, 3};
 static int hscale_lookup[7] = {0, 0, 1, 1, 2, 2, 3};
 
-// TODO #if CONFIG_EXTEND_QRANGE
-static const int cq_level[QINDEX_RANGE] =
+static void find_next_key_frame(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame);
+
+static int select_cq_level( int qindex )
 {
-    0,0,1,1,2,3,3,4,4,5,6,6,7,8,8,9,
-    9,10,11,11,12,13,13,14,15,15,16,17,17,18,19,20,
-    20,21,22,22,23,24,24,25,26,27,27,28,29,30,30,31,
-    32,33,33,34,35,36,36,37,38,39,39,40,41,42,42,43,
-    44,45,46,46,47,48,49,50,50,51,52,53,54,55,55,56,
-    57,58,59,60,60,61,62,63,64,65,66,67,67,68,69,70,
-    71,72,73,74,75,75,76,77,78,79,80,81,82,83,84,85,
-    86,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100
-};
+    int ret_val = QINDEX_RANGE - 1;
+    int i;
 
-static void find_next_key_frame(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame);
+    double target_q = ( vp8_convert_qindex_to_q( qindex ) * 0.5847 ) + 1.0;
 
+    for ( i = 0; i < QINDEX_RANGE; i++ )
+    {
+        if ( target_q <= vp8_convert_qindex_to_q( i ) )
+        {
+            ret_val = i;
+            break;
+        }
+    }
+
+    return ret_val;
+}
+
+
 // Resets the first pass file to the given position using a relative seek from the current position
 static void reset_fpf_position(VP8_COMP *cpi, FIRSTPASS_STATS *Position)
 {
@@ -1143,7 +1150,7 @@
     }
 
     // Clip value to range "best allowed to (worst allowed - 1)"
-    Q = cq_level[Q];
+    Q = select_cq_level( Q );
     if ( Q >= cpi->worst_quality )
         Q = cpi->worst_quality - 1;
     if ( Q < cpi->best_quality )
--- a/vp8/encoder/ratectrl.c
+++ b/vp8/encoder/ratectrl.c
@@ -45,6 +45,7 @@
 // Bits Per MB at different Q (Multiplied by 512)
 #define BPER_MB_NORMBITS    9
 
+#if !CONFIG_EXTEND_QRANGE
 static const int kf_gf_boost_qlimits[QINDEX_RANGE] =
 {
     150, 155, 160, 165, 170, 175, 180, 185,
@@ -64,6 +65,7 @@
     600, 600, 600, 600, 600, 600, 600, 600,
     600, 600, 600, 600, 600, 600, 600, 600,
 };
+#endif
 
 // % adjustment to target kf size based on seperation from previous frame
 static const int kf_boost_seperation_adjustment[16] =
@@ -499,8 +501,17 @@
         }
 
         // Apply an upper limit based on Q for 1 pass encodes
+#if !CONFIG_EXTEND_QRANGE
         if (Boost > kf_gf_boost_qlimits[Q] && (cpi->pass == 0))
             Boost = kf_gf_boost_qlimits[Q];
+#else
+        // TODO.
+        // This is a temporay measure oas one pass not really supported yet in
+        // the experimental branch
+        if (Boost > 600 && (cpi->pass == 0))
+            Boost = 600;
+
+#endif
 
         // Apply lower limits to boost.
         else if (Boost < 110)