adjusted sad_per_bit to correlate with quantizer
authorYaowu Xu <yaowu@google.com>
Fri, 24 Dec 2010 03:59:12 +0000 (19:59 -0800)
committerYaowu Xu <yaowu@google.com>
Fri, 24 Dec 2010 06:59:38 +0000 (22:59 -0800)
Re-calibrated sad_per_bit16 and sad_per_bit4 tables to linearly
correlated to quantizer values, these two variables are used in
motion search for costing motion vectors. This change has an small
positive effect on compression.

Change-Id: Ic9b5ea6fb8d5078ef663ba4899db019cc51f4166

vp8/encoder/rdopt.c

index f1e0579..70be262 100644 (file)
@@ -173,45 +173,44 @@ static int rd_iifactor [ 32 ] =  {    4,   4,   3,   2,   1,   0,   0,   0,
                                  };
 
 
-// The values in this table should be reviewed
-static int sad_per_bit16lut[128] =
+/* values are now correlated to quantizer */
+static int sad_per_bit16lut[QINDEX_RANGE] =
 {
-    4,  4, 4, 4,  4, 4, 4, 4,   // 4
-    4,  4, 4, 4,  4, 4, 4, 4,   // 1
-    4,  4, 4, 4,  4, 4, 4, 4,   // 2
-    4,  4, 4, 4,  4, 4, 4, 4,   // 3
-    4,  4, 4, 4,  4, 4, 4, 4,   // 4
-    4,  4, 12, 12, 13, 13, 14, 14, // 5
-    14, 14, 14, 15, 15, 15, 15, 15, // 6
-    15, 15, 15, 15, 15, 15, 15, 15, // 7
-    15, 15, 15, 15, 15, 16, 16, 16, // 8
-    16, 16, 18, 18, 18, 18, 19, 19, // 9
-    19, 19, 19, 19, 19, 19, 19, 19, // 10
-    20, 20, 22, 22, 22, 22, 21, 21, // 11
-    22, 22, 22, 22, 22, 22, 22, 22, // 12
-    22, 22, 22, 22, 22, 22, 22, 22, // 13
-    22, 22, 22, 22, 22, 22, 22, 22, // 14
-    22, 22, 22, 22, 22, 22, 22, 22, // 15
+    5,  5,  5,  5,  5,  5,  6,  6,
+    6,  6,  6,  6,  6,  7,  7,  7,
+    7,  7,  7,  7,  8,  8,  8,  8,
+    8,  8,  8,  8,  8,  8,  9,  9,
+    9,  9,  9,  9, 10, 10, 10, 10,
+    10, 10, 11, 11, 11, 11, 11, 11,
+    12, 12, 12, 12, 12, 12, 12, 13,
+    13, 13, 13, 13, 13, 14, 14, 14,
+    14, 14, 15, 15, 15, 15, 15, 15,
+    16, 16, 16, 16, 16, 16, 17, 17,
+    17, 17, 17, 17, 17, 18, 18, 18,
+    18, 18, 19, 19, 19, 19, 19, 19,
+    20, 20, 20, 21, 21, 21, 21, 22,
+    22, 22, 23, 23, 23, 24, 24, 24,
+    25, 25, 26, 26, 27, 27, 27, 28,
+    28, 28, 29, 29, 30, 30, 31, 31
 };
-
-static int sad_per_bit4lut[128] =
+static int sad_per_bit4lut[QINDEX_RANGE] =
 {
-    4,  4, 4, 4,  4, 4, 4, 4,   // 4
-    4,  4, 4, 4,  4, 4, 4, 4,   // 1
-    4,  4, 4, 4,  4, 4, 4, 4,   // 2
-    4,  4, 4, 4,  4, 4, 4, 4,   // 3
-    4,  4, 4, 4,  4, 4, 4, 4,   // 4
-    4,  4, 15, 15, 15, 15, 16, 16, // 5
-    16, 17, 17, 17, 17, 17, 17, 17, // 6
-    17, 17, 19, 19, 22, 22, 21, 21, // 7
-    23, 23, 23, 23, 23, 24, 24, 24, // 8
-    25, 25, 27, 27, 27, 27, 28, 28, // 9
-    28, 28, 29, 29, 29, 29, 29, 29, // 10
-    30, 30, 31, 31, 31, 31, 32, 32, // 11
-    34, 34, 34, 34, 34, 34, 34, 34, // 12
-    34, 34, 34, 34, 34, 34, 34, 34, // 13
-    34, 34, 34, 34, 34, 34, 34, 34, // 14
-    34, 34, 34, 34, 34, 34, 34, 34, // 15
+    5,  5,  5,  5,  5,  5,  7,  7,
+    7,  7,  7,  7,  7,  8,  8,  8,
+    8,  8,  8,  8,  10, 10, 10, 10,
+    10, 10, 10, 10, 10, 10, 11, 11,
+    11, 11, 11, 11, 13, 13, 13, 13,
+    13, 13, 14, 14, 14, 14, 14, 14,
+    16, 16, 16, 16, 16, 16, 16, 17,
+    17, 17, 17, 17, 17, 19, 19, 19,
+    19, 19, 20, 20, 20, 20, 20, 20,
+    22, 22, 22, 22, 22, 22, 23, 23,
+    23, 23, 23, 23, 23, 25, 25, 25,
+    25, 25, 26, 26, 26, 26, 26, 26,
+    28, 28, 28, 29, 29, 29, 29, 31,
+    31, 31, 32, 32, 32, 34, 34, 34,
+    35, 35, 37, 37, 38, 38, 38, 40,
+    40, 40, 41, 41, 43, 43, 44, 44,
 };
 
 void vp8cx_initialize_me_consts(VP8_COMP *cpi, int QIndex)
@@ -262,10 +261,6 @@ void vp8_initialize_rd_consts(VP8_COMP *cpi, int Qvalue)
         cpi->RDMULT = 125;
 
     cpi->mb.errorperbit = (cpi->RDMULT / 100);
-
-    if (cpi->mb.errorperbit < 1)
-        cpi->mb.errorperbit = 1;
-
     vp8_set_speed_features(cpi);
 
     if (cpi->common.simpler_lpf)