shithub: libvpx

Download patch

ref: 861ed6a5c12a0563701e3222843fadc86b6d8d74
parent: e1a55b504a625771ad41f42f66f16879d386033d
author: Scott LaVarnway <slavarnway@google.com>
date: Wed Nov 9 05:41:05 EST 2011

Relocated idct/add calls for encoder

Call the idct/add after the tokenize.  This is WIP with
the goal of creating a common idct/add for the encoder and
decoder. This move is necessary because the decoder's version
of the idct clobbers qcoeff, which is used by the tokenize.

Change-Id: I6b08d8e8397cd873647fa4fb9469884e3c876756

--- a/vp8/common/invtrans.c
+++ b/vp8/common/invtrans.c
@@ -44,10 +44,13 @@
 {
     int i;
 
-    /* do 2nd order transform on the dc block */
-    IDCT_INVOKE(rtcd, iwalsh16)(x->block[24].dqcoeff, x->block[24].diff);
+    if(x->mode_info_context->mbmi.mode != SPLITMV)
+    {
+        /* do 2nd order transform on the dc block */
+        IDCT_INVOKE(rtcd, iwalsh16)(x->block[24].dqcoeff, x->block[24].diff);
 
-    recon_dcblock(x);
+        recon_dcblock(x);
+    }
 
     for (i = 0; i < 16; i++)
     {
--- a/vp8/encoder/encodeframe.c
+++ b/vp8/encoder/encodeframe.c
@@ -28,6 +28,7 @@
 #include <stdio.h>
 #include <limits.h>
 #include "vp8/common/subpixel.h"
+#include "vp8/common/invtrans.h"
 #include "vpx_ports/vpx_timer.h"
 
 #if CONFIG_RUNTIME_CPU_DETECT
@@ -1165,6 +1166,11 @@
     sum_intra_stats(cpi, x);
     vp8_tokenize_mb(cpi, &x->e_mbd, t);
 
+    if (x->e_mbd.mode_info_context->mbmi.mode != B_PRED)
+        vp8_inverse_transform_mby(IF_RTCD(&cpi->rtcd.common->idct), &x->e_mbd);
+
+    vp8_inverse_transform_mbuv(IF_RTCD(&cpi->rtcd.common->idct), &x->e_mbd);
+
     return rate;
 }
 #ifdef SPEEDSTATS
@@ -1337,7 +1343,15 @@
     }
 
     if (!x->skip)
+    {
         vp8_tokenize_mb(cpi, xd, t);
+        if (x->e_mbd.mode_info_context->mbmi.mode != B_PRED)
+        {
+          vp8_inverse_transform_mby(IF_RTCD(&cpi->rtcd.common->idct),
+                                      &x->e_mbd);
+        }
+        vp8_inverse_transform_mbuv(IF_RTCD(&cpi->rtcd.common->idct), &x->e_mbd);
+    }
     else
     {
         if (cpi->common.mb_no_coeff_skip)
--- a/vp8/encoder/encodeintra.c
+++ b/vp8/encoder/encodeintra.c
@@ -37,11 +37,15 @@
 
     if (use_dc_pred)
     {
+        const VP8_ENCODER_RTCD *rtcd = IF_RTCD(&cpi->rtcd);
+
         x->e_mbd.mode_info_context->mbmi.mode = DC_PRED;
         x->e_mbd.mode_info_context->mbmi.uv_mode = DC_PRED;
         x->e_mbd.mode_info_context->mbmi.ref_frame = INTRA_FRAME;
 
-        vp8_encode_intra16x16mby(IF_RTCD(&cpi->rtcd), x);
+        vp8_encode_intra16x16mby(rtcd, x);
+
+        vp8_inverse_transform_mby(IF_RTCD(&rtcd->common->idct), &x->e_mbd);
     }
     else
     {
@@ -104,8 +108,6 @@
     if (x->optimize)
         vp8_optimize_mby(x, rtcd);
 
-    vp8_inverse_transform_mby(IF_RTCD(&rtcd->common->idct), &x->e_mbd);
-
 }
 
 void vp8_encode_intra16x16mbuv(const VP8_ENCODER_RTCD *rtcd, MACROBLOCK *x)
@@ -120,7 +122,5 @@
 
     if (x->optimize)
         vp8_optimize_mbuv(x, rtcd);
-
-    vp8_inverse_transform_mbuv(IF_RTCD(&rtcd->common->idct), &x->e_mbd);
 
 }
--- a/vp8/encoder/encodemb.c
+++ b/vp8/encoder/encodemb.c
@@ -619,67 +619,6 @@
     }
 }
 
-static void recon_dcblock(MACROBLOCKD *x)
-{
-    BLOCKD *b = &x->block[24];
-    int i;
-
-    for (i = 0; i < 16; i++)
-    {
-        x->block[i].dqcoeff[0] = b->diff[i];
-    }
-
-}
-
-
-static void inverse_transform_mb(const vp8_idct_rtcd_vtable_t *rtcd,
-                                 MACROBLOCKD *x)
-{
-    int i;
-
-    if (x->mode_info_context->mbmi.mode != B_PRED &&
-        x->mode_info_context->mbmi.mode != SPLITMV)
-    {
-        /* do 2nd order transform on the dc block */
-
-        IDCT_INVOKE(rtcd, iwalsh16)(&x->block[24].dqcoeff[0], x->block[24].diff);
-        recon_dcblock(x);
-    }
-
-    for (i = 0; i < 16; i++)
-    {
-        BLOCKD *b = &x->block[i];
-
-        if (*b->eob > 1)
-        {
-            IDCT_INVOKE(rtcd, idct16)(b->dqcoeff, b->predictor, 16,
-                  *(b->base_dst) + b->dst, b->dst_stride);
-        }
-        else
-        {
-            IDCT_INVOKE(rtcd, idct1_scalar_add)(b->dqcoeff[0], b->predictor, 16,
-                             *(b->base_dst) + b->dst, b->dst_stride);
-        }
-    }
-
-
-    for (i = 16; i < 24; i++)
-    {
-        BLOCKD *b = &x->block[i];
-
-        if (*b->eob > 1)
-        {
-            IDCT_INVOKE(rtcd, idct16)(b->dqcoeff, b->predictor, 8,
-                  *(b->base_dst) + b->dst, b->dst_stride);
-        }
-        else
-        {
-            IDCT_INVOKE(rtcd, idct1_scalar_add)(b->dqcoeff[0], b->predictor, 8,
-                             *(b->base_dst) + b->dst, b->dst_stride);
-        }
-    }
-
-}
 void vp8_encode_inter16x16(const VP8_ENCODER_RTCD *rtcd, MACROBLOCK *x)
 {
     vp8_build_inter_predictors_mb_e(&x->e_mbd);
@@ -693,10 +632,7 @@
     if (x->optimize)
         optimize_mb(x, rtcd);
 
-    inverse_transform_mb(IF_RTCD(&rtcd->common->idct), &x->e_mbd);
-
 }
-
 
 /* this funciton is used by first pass only */
 void vp8_encode_inter16x16y(const VP8_ENCODER_RTCD *rtcd, MACROBLOCK *x)