[FFmpeg-devel] [PATCH] bink: perform scan order permutation of quantization matrices in read_dct_coeffs()

Kostya kostya.shishkov
Sun Feb 13 14:32:23 CET 2011


On Sun, Feb 13, 2011 at 08:29:42PM +1100, Peter Ross wrote:
> On Sun, Feb 13, 2011 at 07:41:32AM +0100, Kostya wrote:
> > On Sun, Feb 13, 2011 at 02:32:58PM +1100, Peter Ross wrote:
> > > This fixes visual glitches in Bink version 'b' files, as the quantization tables
> > > were not being permutated.
> > > ---
> > >  libavcodec/bink.c     |    4 +-
> > >  libavcodec/binkdata.h |  618 ++++++++++++++++++++++++-------------------------
> > >  2 files changed, 303 insertions(+), 319 deletions(-)
> > > 
> > > diff --git a/libavcodec/bink.c b/libavcodec/bink.c
> > > index 928bf53..5ebf98c 100644
> > > --- a/libavcodec/bink.c
> > > +++ b/libavcodec/bink.c
> > > @@ -678,8 +678,8 @@ static int read_dct_coeffs(GetBitContext *gb, DCTELEM block[64], const uint8_t *
> > >  
> > >      block[0] = (block[0] * quant[0]) >> 11;
> > >      for (i = 0; i < coef_count; i++) {
> > > -        int idx = coef_idx[i];
> > > -        block[scan[idx]] = (block[scan[idx]] * quant[idx]) >> 11;
> > > +        int idx = scan[coef_idx[i]];
> > > +        block[idx] = (block[idx] * quant[idx]) >> 11;
> > >      }
> > 
> > 1) permutation depends on DCT type selected. Maybe in future Jason will
> > fullfill his promise and write optimised DCT for Bink and it will require
> > different permutation. Then decoder will be broken.
> 
> True. My oops, the critical lines should therefore be:
> 
>         int idx = coef_idx[i];
>         block[scan[idx]] = (block[scan[idx]] * quant[bink_scan[idx]]) >> 11;
> 
> > 2) you generate bink-b tables anyway so you can permutate them during creation
> > unlike static data we have for latter Bink versions.
> 
> Ok, for now. We'll need to revisit this when the Bink encoder is committed.

Well, writing DCT-only Bink video encoder is not hard, probably Mike can do
it when he decides he had enough with VP8 encoder.
 
> -- Peter
> (A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)



More information about the ffmpeg-devel mailing list