]> granicus.if.org Git - libvpx/commitdiff
Merge "Change use of eob in the encoder"
authorScott LaVarnway <slavarnway@google.com>
Thu, 3 Nov 2011 15:06:06 +0000 (08:06 -0700)
committerGerrit Code Review <gerrit@gerrit.golo.chromium.org>
Thu, 3 Nov 2011 15:06:06 +0000 (08:06 -0700)
1  2 
vp8/encoder/encodemb.c

index 16f6875b1bdcfaca335224d2b88e37cdd66dc722,28ee2e831267deca90ba6af911e679852820e0cd..faa1a8e3300a7a58af5ec7a4f6a5f2e93530f397
@@@ -466,46 -466,9 +466,46 @@@ static void optimize_b(MACROBLOCK *mb, 
      }
      final_eob++;
  
-     d->eob = final_eob;
-     *a = *l = (d->eob != !type);
+     *a = *l = (final_eob != !type);
+     *d->eob = (char)final_eob;
  }
 +static void check_reset_2nd_coeffs(MACROBLOCKD *x, int type,
 +                                   ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l)
 +{
 +    int sum=0;
 +    int i;
 +    BLOCKD *bd = &x->block[24];
 +
 +    if(bd->dequant[0]>=35 && bd->dequant[1]>=35)
 +        return;
 +
 +    for(i=0;i<bd->eob;i++)
 +    {
 +        int coef = bd->dqcoeff[vp8_default_zig_zag1d[i]];
 +        sum+= (coef>=0)?coef:-coef;
 +        if(sum>=35)
 +            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)
 +    {
 +        for(i=0;i<bd->eob;i++)
 +        {
 +            int rc = vp8_default_zig_zag1d[i];
 +            bd->qcoeff[rc]=0;
 +            bd->dqcoeff[rc]=0;
 +        }
 +        bd->eob = 0;
 +        *a = *l = (bd->eob != !type);
 +    }
 +}
  
  static void optimize_mb(MACROBLOCK *x, const VP8_ENCODER_RTCD *rtcd)
  {