]> granicus.if.org Git - libvpx/commitdiff
Refactor vp9_dequant_idct_add function
authorYunqing Wang <yunqingwang@google.com>
Thu, 28 Feb 2013 21:01:41 +0000 (13:01 -0800)
committerYunqing Wang <yunqingwang@google.com>
Thu, 28 Feb 2013 22:18:46 +0000 (14:18 -0800)
Provided a wrapper and removed duplicate code.

Change-Id: Iaef842226ec348422e459202793b001d0983ea30

vp9/common/vp9_blockd.h
vp9/common/vp9_rtcd_defs.sh
vp9/decoder/vp9_decodframe.c
vp9/decoder/vp9_dequantize.c
vp9/decoder/vp9_dequantize.h
vp9/decoder/vp9_idct_blk.c

index c7429d553670030e7058f70ad68e7f1d2dd33592..b35c1c2464c93507c8b9c0889e7fbb221adb4a50 100644 (file)
@@ -380,9 +380,7 @@ typedef struct macroblockd {
   void (*inv_txm4x4_1)(int16_t *input, int16_t *output, int pitch);
   void (*inv_txm4x4)(int16_t *input, int16_t *output, int pitch);
   void (*itxm_add)(int16_t *input, const int16_t *dq,
-    uint8_t *pred, uint8_t *output, int pitch, int stride);
-  void (*dc_only_itxm_add)(int input_dc, uint8_t *pred_ptr,
-    uint8_t *dst_ptr, int pitch, int stride);
+    uint8_t *pred, uint8_t *output, int pitch, int stride, int eob);
   void (*itxm_add_y_block)(int16_t *q, const int16_t *dq,
     uint8_t *pre, uint8_t *dst, int stride, struct macroblockd *xd);
   void (*itxm_add_uv_block)(int16_t *q, const int16_t *dq,
index 3ea0b0602eefaaf8730a8953303df7d2e9af4700..091258d8364d15b59f027c4902c75f379aeb2d65 100644 (file)
@@ -41,7 +41,7 @@ specialize vp9_dequant_idct_add_16x16
 prototype void vp9_dequant_idct_add_8x8 "int16_t *input, const int16_t *dq, uint8_t *pred, uint8_t *dest, int pitch, int stride, int eob"
 specialize vp9_dequant_idct_add_8x8
 
-prototype void vp9_dequant_idct_add "int16_t *input, const int16_t *dq, uint8_t *pred, uint8_t *dest, int pitch, int stride"
+prototype void vp9_dequant_idct_add "int16_t *input, const int16_t *dq, uint8_t *pred, uint8_t *dest, int pitch, int stride, int eob"
 specialize vp9_dequant_idct_add
 
 prototype void vp9_dequant_idct_add_y_block "int16_t *q, const int16_t *dq, uint8_t *pre, uint8_t *dst, int stride, struct macroblockd *xd"
index 8e9e5ad7d0d43f1c290604199bfec41b20a017c4..d4212a52eea488176762121a634fdf51e1de5a63 100644 (file)
@@ -126,7 +126,6 @@ static void mb_init_dequantizer(VP9D_COMP *pbi, MACROBLOCKD *xd) {
   xd->inv_txm4x4_1      = vp9_short_idct4x4llm_1;
   xd->inv_txm4x4        = vp9_short_idct4x4llm;
   xd->itxm_add          = vp9_dequant_idct_add;
-  xd->dc_only_itxm_add  = vp9_dc_only_idct_add;
   xd->itxm_add_y_block  = vp9_dequant_idct_add_y_block;
   xd->itxm_add_uv_block = vp9_dequant_idct_add_uv_block;
   if (xd->lossless) {
@@ -134,7 +133,6 @@ static void mb_init_dequantizer(VP9D_COMP *pbi, MACROBLOCKD *xd) {
     xd->inv_txm4x4_1      = vp9_short_inv_walsh4x4_1_x8;
     xd->inv_txm4x4        = vp9_short_inv_walsh4x4_x8;
     xd->itxm_add          = vp9_dequant_idct_add_lossless_c;
-    xd->dc_only_itxm_add  = vp9_dc_only_inv_walsh_add_c;
     xd->itxm_add_y_block  = vp9_dequant_idct_add_y_block_lossless_c;
     xd->itxm_add_uv_block = vp9_dequant_idct_add_uv_block_lossless_c;
   }
@@ -297,11 +295,11 @@ static void decode_8x8(VP9D_COMP *pbi, MACROBLOCKD *xd,
       b = &xd->block[16 + i];
       vp9_intra_uv4x4_predict(xd, &xd->block[16 + i], i8x8mode, b->predictor);
       xd->itxm_add(b->qcoeff, b->dequant, b->predictor,
-                    *(b->base_dst) + b->dst, 8, b->dst_stride);
+                   *(b->base_dst) + b->dst, 8, b->dst_stride, xd->eobs[16 + i]);
       b = &xd->block[20 + i];
       vp9_intra_uv4x4_predict(xd, &xd->block[20 + i], i8x8mode, b->predictor);
       xd->itxm_add(b->qcoeff, b->dequant, b->predictor,
-                    *(b->base_dst) + b->dst, 8, b->dst_stride);
+                   *(b->base_dst) + b->dst, 8, b->dst_stride, xd->eobs[20 + i]);
     }
   } else if (xd->mode_info_context->mbmi.mode == SPLITMV) {
     xd->itxm_add_uv_block(xd->qcoeff + 16 * 16, xd->block[16].dequant,
@@ -351,17 +349,18 @@ static void decode_4x4(VP9D_COMP *pbi, MACROBLOCKD *xd,
                                     b->dst_stride, xd->eobs[ib + iblock[j]]);
         } else {
           xd->itxm_add(b->qcoeff, b->dequant, b->predictor,
-                        *(b->base_dst) + b->dst, 16, b->dst_stride);
+                       *(b->base_dst) + b->dst, 16, b->dst_stride,
+                       xd->eobs[ib + iblock[j]]);
         }
       }
       b = &xd->block[16 + i];
       vp9_intra_uv4x4_predict(xd, b, i8x8mode, b->predictor);
       xd->itxm_add(b->qcoeff, b->dequant, b->predictor,
-                    *(b->base_dst) + b->dst, 8, b->dst_stride);
+                   *(b->base_dst) + b->dst, 8, b->dst_stride, xd->eobs[16 + i]);
       b = &xd->block[20 + i];
       vp9_intra_uv4x4_predict(xd, b, i8x8mode, b->predictor);
       xd->itxm_add(b->qcoeff, b->dequant, b->predictor,
-                    *(b->base_dst) + b->dst, 8, b->dst_stride);
+                   *(b->base_dst) + b->dst, 8, b->dst_stride, xd->eobs[20 + i]);
     }
   } else if (mode == B_PRED) {
     for (i = 0; i < 16; i++) {
@@ -384,7 +383,7 @@ static void decode_4x4(VP9D_COMP *pbi, MACROBLOCKD *xd,
                                   xd->eobs[i]);
       } else {
         xd->itxm_add(b->qcoeff, b->dequant, b->predictor,
-                      *(b->base_dst) + b->dst, 16, b->dst_stride);
+                      *(b->base_dst) + b->dst, 16, b->dst_stride, xd->eobs[i]);
       }
     }
     if (!xd->mode_info_context->mbmi.mb_skip_coeff) {
@@ -440,7 +439,7 @@ static void decode_4x4(VP9D_COMP *pbi, MACROBLOCKD *xd,
                                   b->dst_stride, xd->eobs[i]);
       } else {
         xd->itxm_add(b->qcoeff, b->dequant, b->predictor,
-                      *(b->base_dst) + b->dst, 16, b->dst_stride);
+                      *(b->base_dst) + b->dst, 16, b->dst_stride, xd->eobs[i]);
       }
     }
     xd->itxm_add_uv_block(xd->qcoeff + 16 * 16,
@@ -549,7 +548,7 @@ static void decode_4x4_sb(VP9D_COMP *pbi, MACROBLOCKD *xd,
             + x_idx * 16 + (i & 3) * 4,
             xd->dst.y_buffer + (y_idx * 16 + (i / 4) * 4) * xd->dst.y_stride
             + x_idx * 16 + (i & 3) * 4,
-            xd->dst.y_stride, xd->dst.y_stride);
+            xd->dst.y_stride, xd->dst.y_stride, xd->eobs[i]);
       }
     }
   } else {
index 1da87a3e171aa6d42a2cb7318b693df49b760da5..656c8b92481d3d3a328986c8df9ceb55efd12ad2 100644 (file)
@@ -89,17 +89,24 @@ void vp9_ht_dequant_idct_add_8x8_c(TX_TYPE tx_type, int16_t *input,
 }
 
 void vp9_dequant_idct_add_c(int16_t *input, const int16_t *dq, uint8_t *pred,
-                            uint8_t *dest, int pitch, int stride) {
+                            uint8_t *dest, int pitch, int stride, int eob) {
   int i;
   int16_t output[16];
 
-  for (i = 0; i < 16; i++)
-    input[i] *= dq[i];
+  if (eob > 1) {
+    for (i = 0; i < 16; i++)
+      input[i] *= dq[i];
 
-  // the idct halves ( >> 1) the pitch
-  vp9_short_idct4x4llm_c(input, output, 4 << 1);
-  vpx_memset(input, 0, 32);
-  add_residual(output, pred, pitch, dest, stride, 4, 4);
+    // the idct halves ( >> 1) the pitch
+    vp9_short_idct4x4llm_c(input, output, 4 << 1);
+
+    vpx_memset(input, 0, 32);
+
+    add_residual(output, pred, pitch, dest, stride, 4, 4);
+  } else {
+    vp9_dc_only_idct_add(input[0]*dq[0], pred, dest, pitch, stride);
+    ((int *)input)[0] = 0;
+  }
 }
 
 void vp9_dequant_dc_idct_add_c(int16_t *input, const int16_t *dq, uint8_t *pred,
@@ -120,16 +127,23 @@ void vp9_dequant_dc_idct_add_c(int16_t *input, const int16_t *dq, uint8_t *pred,
 
 void vp9_dequant_idct_add_lossless_c(int16_t *input, const int16_t *dq,
                                      uint8_t *pred, uint8_t *dest,
-                                     int pitch, int stride) {
+                                     int pitch, int stride, int eob) {
   int i;
   int16_t output[16];
 
-  for (i = 0; i < 16; i++)
-    input[i] *= dq[i];
+  if (eob > 1) {
+    for (i = 0; i < 16; i++)
+      input[i] *= dq[i];
 
-  vp9_short_inv_walsh4x4_x8_c(input, output, 4 << 1);
-  vpx_memset(input, 0, 32);
-  add_residual(output, pred, pitch, dest, stride, 4, 4);
+    vp9_short_inv_walsh4x4_x8_c(input, output, 4 << 1);
+
+    vpx_memset(input, 0, 32);
+
+    add_residual(output, pred, pitch, dest, stride, 4, 4);
+  } else {
+    vp9_dc_only_inv_walsh_add(input[0]*dq[0], pred, dest, pitch, stride);
+    ((int *)input)[0] = 0;
+  }
 }
 
 void vp9_dequant_dc_idct_add_lossless_c(int16_t *input, const int16_t *dq,
index 2e7c073574e7c7f222037746b0d6f6cee24dbae0..bde27bb7aca1ebd627a08227190a3553491e55c5 100644 (file)
@@ -18,7 +18,7 @@
 void vp9_dequant_idct_add_lossless_c(int16_t *input, const int16_t *dq,
                                      unsigned char *pred,
                                      unsigned char *output,
-                                     int pitch, int stride);
+                                     int pitch, int stride, int eob);
 
 void vp9_dequant_dc_idct_add_lossless_c(int16_t *input, const int16_t *dq,
                                         unsigned char *pred,
index 0ec5036e44bcf1c8cbf445ab13eae48c305d0bc7..b17955b1caa8d57cb861561693d43accfb3336a2 100644 (file)
@@ -21,13 +21,7 @@ void vp9_dequant_idct_add_y_block_4x4_inplace_c(int16_t *q,
 
   for (i = 0; i < 4; i++) {
     for (j = 0; j < 4; j++) {
-      if (xd->eobs[i * 4 + j] > 1) {
-        xd->itxm_add(q, dq, dst, dst, stride, stride);
-      } else {
-        xd->dc_only_itxm_add(q[0]*dq[0], dst, dst, stride, stride);
-        ((int *)q)[0] = 0;
-      }
-
+      xd->itxm_add(q, dq, dst, dst, stride, stride, xd->eobs[i * 4 + j]);
       q   += 16;
       dst += 4;
     }
@@ -44,13 +38,7 @@ void vp9_dequant_idct_add_y_block_c(int16_t *q, const int16_t *dq,
 
   for (i = 0; i < 4; i++) {
     for (j = 0; j < 4; j++) {
-      if (xd->eobs[i * 4 + j] > 1)
-        vp9_dequant_idct_add_c(q, dq, pre, dst, 16, stride);
-      else {
-        vp9_dc_only_idct_add(q[0]*dq[0], pre, dst, 16, stride);
-        ((int *)q)[0] = 0;
-      }
-
+      vp9_dequant_idct_add(q, dq, pre, dst, 16, stride, xd->eobs[i * 4  + j]);
       q   += 16;
       pre += 4;
       dst += 4;
@@ -69,13 +57,8 @@ void vp9_dequant_idct_add_uv_block_c(int16_t *q, const int16_t *dq,
 
   for (i = 0; i < 2; i++) {
     for (j = 0; j < 2; j++) {
-      if (xd->eobs[16 + i * 2 + j] > 1)
-        vp9_dequant_idct_add_c(q, dq, pre, dstu, 8, stride);
-      else {
-        vp9_dc_only_idct_add(q[0]*dq[0], pre, dstu, 8, stride);
-        ((int *)q)[0] = 0;
-      }
-
+      vp9_dequant_idct_add(q, dq, pre, dstu, 8, stride,
+                           xd->eobs[16 + i * 2 + j]);
       q    += 16;
       pre  += 4;
       dstu += 4;
@@ -87,13 +70,8 @@ void vp9_dequant_idct_add_uv_block_c(int16_t *q, const int16_t *dq,
 
   for (i = 0; i < 2; i++) {
     for (j = 0; j < 2; j++) {
-      if (xd->eobs[20 + i * 2 + j] > 1)
-        vp9_dequant_idct_add_c(q, dq, pre, dstv, 8, stride);
-      else {
-        vp9_dc_only_idct_add(q[0]*dq[0], pre, dstv, 8, stride);
-        ((int *)q)[0] = 0;
-      }
-
+      vp9_dequant_idct_add(q, dq, pre, dstv, 8, stride,
+                           xd->eobs[20 + i * 2 + j]);
       q    += 16;
       pre  += 4;
       dstv += 4;
@@ -113,13 +91,7 @@ void vp9_dequant_idct_add_uv_block_4x4_inplace_c(int16_t *q, const int16_t *dq,
 
   for (i = 0; i < 2; i++) {
     for (j = 0; j < 2; j++) {
-      if (xd->eobs[16 + i * 2 + j] > 1) {
-        xd->itxm_add(q, dq, dstu, dstu, stride, stride);
-      } else {
-        xd->dc_only_itxm_add(q[0]*dq[0], dstu, dstu, stride, stride);
-        ((int *)q)[0] = 0;
-      }
-
+      xd->itxm_add(q, dq, dstu, dstu, stride, stride, xd->eobs[16 + i * 2 + j]);
       q    += 16;
       dstu += 4;
     }
@@ -129,13 +101,7 @@ void vp9_dequant_idct_add_uv_block_4x4_inplace_c(int16_t *q, const int16_t *dq,
 
   for (i = 0; i < 2; i++) {
     for (j = 0; j < 2; j++) {
-      if (xd->eobs[20 + i * 2 + j] > 1) {
-        xd->itxm_add(q, dq, dstv, dstv, stride, stride);
-      } else {
-        xd->dc_only_itxm_add(q[0]*dq[0], dstv, dstv, stride, stride);
-        ((int *)q)[0] = 0;
-      }
-
+      xd->itxm_add(q, dq, dstv, dstv, stride, stride, xd->eobs[20 + i * 2 + j]);
       q    += 16;
       dstv += 4;
     }
@@ -216,13 +182,8 @@ void vp9_dequant_idct_add_y_block_lossless_c(int16_t *q, const int16_t *dq,
 
   for (i = 0; i < 4; i++) {
     for (j = 0; j < 4; j++) {
-      if (xd->eobs[i * 4 + j] > 1)
-        vp9_dequant_idct_add_lossless_c(q, dq, pre, dst, 16, stride);
-      else {
-        vp9_dc_only_inv_walsh_add_c(q[0]*dq[0], pre, dst, 16, stride);
-        ((int *)q)[0] = 0;
-      }
-
+      vp9_dequant_idct_add_lossless_c(q, dq, pre, dst, 16, stride,
+                                      xd->eobs[i * 4 + j]);
       q   += 16;
       pre += 4;
       dst += 4;
@@ -243,13 +204,8 @@ void vp9_dequant_idct_add_uv_block_lossless_c(int16_t *q, const int16_t *dq,
 
   for (i = 0; i < 2; i++) {
     for (j = 0; j < 2; j++) {
-      if (xd->eobs[16 + i * 2 + j] > 1)
-        vp9_dequant_idct_add_lossless_c(q, dq, pre, dstu, 8, stride);
-      else {
-        vp9_dc_only_inv_walsh_add_c(q[0]*dq[0], pre, dstu, 8, stride);
-        ((int *)q)[0] = 0;
-      }
-
+      vp9_dequant_idct_add_lossless_c(q, dq, pre, dstu, 8, stride,
+                                      xd->eobs[16 + i * 2 + j]);
       q    += 16;
       pre  += 4;
       dstu += 4;
@@ -261,13 +217,8 @@ void vp9_dequant_idct_add_uv_block_lossless_c(int16_t *q, const int16_t *dq,
 
   for (i = 0; i < 2; i++) {
     for (j = 0; j < 2; j++) {
-      if (xd->eobs[20 + i * 2 + j] > 1)
-        vp9_dequant_idct_add_lossless_c(q, dq, pre, dstv, 8, stride);
-      else {
-        vp9_dc_only_inv_walsh_add_c(q[0]*dq[0], pre, dstv, 8, stride);
-        ((int *)q)[0] = 0;
-      }
-
+      vp9_dequant_idct_add_lossless_c(q, dq, pre, dstv, 8, stride,
+                                      xd->eobs[20 + i * 2 + j]);
       q    += 16;
       pre  += 4;
       dstv += 4;