shithub: libvpx

Download patch

ref: a0ed4e63802a395c6147b5abb70311f50b98d95e
parent: 151b7f25dbb4328800eb93a9f07c64904615d475
parent: cbcba9e7c03e963e0f6ae7c32ebbd5f2540c25af
author: Yaowu Xu <yaowu@google.com>
date: Thu Nov 10 11:34:36 EST 2011

Merge "scaled the threshold for 2nd order coefficient reset" into experimental

--- a/vp8/encoder/encodemb.c
+++ b/vp8/encoder/encodemb.c
@@ -615,6 +615,29 @@
     *a = *l = (d->eob != !type);
 }
 
+#if CONFIG_EXTEND_QRANGE
+    /**************************************************************************
+    our inverse hadamard transform effectively is weighted sum of all 16 inputs
+    with weight either 1 or -1. It has a last stage scaling of (sum+1)>>2. And
+    dc only idct is (dc+16)>>5. So if all the sums are between -65 and 63 the
+    output after inverse wht and idct will be all zero. A sum of absolute value
+    smaller than 65 guarantees all 16 different (+1/-1) weighted sums in wht
+    fall between -65 and +65.
+    **************************************************************************/
+#define SUM_2ND_COEFF_THRESH 65
+#else
+    /**************************************************************************
+    our inverse hadamard transform effectively is weighted sum of all 16 inputs
+    with weight either 1 or -1. It has a last stage scaling of (sum+3)>>3. And
+    dc only idct is (dc+4)>>3. So if all the sums are between -35 and 29, the
+    output after inverse wht and idct will be all zero. A sum of absolute value
+    smaller than 35 guarantees all 16 different (+1/-1) weighted sums in wht
+    fall between -35 and +35.
+    **************************************************************************/
+#define SUM_2ND_COEFF_THRESH 35
+
+#endif
+
 static void check_reset_2nd_coeffs(MACROBLOCKD *x, int type,
                                    ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l)
 {
@@ -621,8 +644,8 @@
     int sum=0;
     int i;
     BLOCKD *bd = &x->block[24];
-
-    if(bd->dequant[0]>=35 && bd->dequant[1]>=35)
+    if(bd->dequant[0]>=SUM_2ND_COEFF_THRESH
+        && bd->dequant[1]>=SUM_2ND_COEFF_THRESH)
         return;
 
     for(i=0;i<bd->eob;i++)
@@ -629,19 +652,11 @@
     {
         int coef = bd->dqcoeff[vp8_default_zig_zag1d[i]];
         sum+= (coef>=0)?coef:-coef;
-        if(sum>=35)
+        if(sum>=SUM_2ND_COEFF_THRESH)
             return;
     }
 
-    /**************************************************************************
-    our inverse hadamard transform effectively is weighted sum of all 16 inputs
-    with weight either 1 or -1. It has a last stage scaling of (sum+3)>>3. And
-    dc only idct is (dc+4)>>3. So if all the sums are between -35 and 29, the
-    output after inverse wht and idct will be all zero. A sum of absolute value
-    smaller than 35 guarantees all 16 different (+1/-1) weighted sums in wht
-    fall between -35 and +35.
-    **************************************************************************/
-    if(sum < 35)
+    if(sum < SUM_2ND_COEFF_THRESH)
     {
         for(i=0;i<bd->eob;i++)
         {