shithub: libvpx

Download patch

ref: 982b061dc2f39cb4a7505260a856ce870ba7ba1c
parent: a0ed4e63802a395c6147b5abb70311f50b98d95e
author: Yaowu Xu <yaowu@google.com>
date: Thu Nov 10 07:54:22 EST 2011

Make 8x8 and extend_qrange to work together

This commit added scaling factors to 8x8 transform, quant, dequant and
inverse transform pipeline to make 8x8 transform to work when configed
with enable-extend_qrange. This commit also disabled the trellis-quant
when extend_qrange is configured.

Change-Id: Icfb3192e4746f70a4bb35ad18b7b47705b657e52

--- a/vp8/decoder/dequantize.c
+++ b/vp8/decoder/dequantize.c
@@ -131,7 +131,11 @@
 
     for (i = 0; i < 16; i++)
     {
+#if CONFIG_EXTEND_QRANGE
+        DQ[i] = (short)((Q[i] * DQC[i]+2)>>2);
+#else
        DQ[i] = (short)(Q[i] * DQC[i]);
+#endif
     }
 #ifdef DEC_DEBUG
     if (dec_debug) {
@@ -163,10 +167,21 @@
       }
     }
 #endif
+
+#if CONFIG_EXTEND_QRANGE
+      input[0]= (input[0] * dq[0]+2)>>2;
+#else
+      input[0]= input[0] * dq[0];
+#endif
+
     // recover quantizer for 4 4x4 blocks
-    for (i = 0; i < 64; i++)
+    for (i = 1; i < 64; i++)
     {
-      input[i]=input[i] * dq[i!=0];
+#if CONFIG_EXTEND_QRANGE
+      input[i]=(input[i] * dq[1]+2)>>2;
+#else
+      input[i]=input[i] * dq[1];
+#endif
     }
 #ifdef DEC_DEBUG
     if (dec_debug) {
@@ -259,7 +274,11 @@
 #endif
     for (i = 1; i < 64; i++)
     {
-        input[i] = input[i] * dq[i!=0];
+#if CONFIG_EXTEND_QRANGE
+        input[i]=(input[i] * dq[1]+2)>>2;
+#else
+        input[i]=input[i] * dq[1];
+#endif
     }
 
 #ifdef DEC_DEBUG
--- a/vp8/encoder/dct.c
+++ b/vp8/encoder/dct.c
@@ -36,7 +36,11 @@
   {
     for (j = 0; j < 8; j++)
     {
+#if !CONFIG_EXTEND_QRANGE
       b[j] = (float)( block[k + j]<<1);
+#else
+      b[j] = (float)( block[k + j]<<3);
+#endif
     }
     /* Horizontal transform */
     for (j = 0; j < 4; j++)
--- a/vp8/encoder/encodemb.c
+++ b/vp8/encoder/encodemb.c
@@ -1075,6 +1075,9 @@
     ENTROPY_CONTEXT *ta;
     ENTROPY_CONTEXT *tl;
 
+#if CONFIG_EXTEND_QRANGE
+return ;
+#endif
     vpx_memcpy(&t_above, x->e_mbd.above_context, sizeof(ENTROPY_CONTEXT_PLANES));
     vpx_memcpy(&t_left, x->e_mbd.left_context, sizeof(ENTROPY_CONTEXT_PLANES));
 
@@ -1164,6 +1167,11 @@
     ENTROPY_CONTEXT *ta;
     ENTROPY_CONTEXT *tl;
 
+#if CONFIG_EXTEND_QRANGE
+return ;
+#endif
+
+
     if (!x->e_mbd.above_context)
         return;
 
@@ -1227,6 +1235,10 @@
     ENTROPY_CONTEXT_PLANES t_above, t_left;
     ENTROPY_CONTEXT *ta;
     ENTROPY_CONTEXT *tl;
+
+#if CONFIG_EXTEND_QRANGE
+return ;
+#endif
 
     if (!x->e_mbd.above_context)
         return;
--- a/vp8/encoder/quantize.c
+++ b/vp8/encoder/quantize.c
@@ -458,6 +458,9 @@
       qcoeff_ptr[rc] = x;                          // write to destination
       //dqcoeff_ptr[rc] = x * dequant_ptr[rc] / q2nd;        // dequantized value
       dqcoeff_ptr[rc] = x * dequant_ptr[rc];        // dequantized value
+#if CONFIG_EXTEND_QRANGE
+      dqcoeff_ptr[rc] = (dqcoeff_ptr[rc]+2)>>2;
+#endif
 
       if (y)
       {
@@ -506,6 +509,12 @@
       qcoeff_ptr[rc] = x;                         // write to destination
       //dqcoeff_ptr[rc] = x * dequant_ptr[rc!=0] / q1st;        // dequantized value
       dqcoeff_ptr[rc] = x * dequant_ptr[rc!=0];        // dequantized value
+
+#if CONFIG_EXTEND_QRANGE
+      dqcoeff_ptr[rc] = (dqcoeff_ptr[rc]+2)>>2;
+#endif
+
+
       if (y)
       {
         eob = i;                                // last nonzero coeffs
@@ -562,6 +571,11 @@
       //dqcoeff_ptr[rc] = x * dequant_ptr[rc]/q2nd;        // dequantized value
       dqcoeff_ptr[rc] = x * dequant_ptr[rc];        // dequantized value
 
+#if CONFIG_EXTEND_QRANGE
+      dqcoeff_ptr[rc] = (dqcoeff_ptr[rc]+2)>>2;
+#endif
+
+
       if (y)
       {
         eob = i;                                // last nonzero coeffs
@@ -620,6 +634,9 @@
       qcoeff_ptr[rc]  = x;                         // write to destination
       //dqcoeff_ptr[rc] = x * dequant_ptr[rc!=0] / q1st;        // dequantized value
       dqcoeff_ptr[rc] = x * dequant_ptr[rc!=0];        // dequantized value
+#if CONFIG_EXTEND_QRANGE
+      dqcoeff_ptr[rc] = (dqcoeff_ptr[rc]+2)>>2;
+#endif
 
       if (y)
       {