[FFmpeg-devel] LIBMPEG2_BITSTREAM_READER vs. golomb.h

Michael Niedermayer michaelni
Wed Jul 16 02:50:41 CEST 2008


On Wed, Jul 16, 2008 at 12:06:30AM +0100, M?ns Rullg?rd wrote:
> Michael Niedermayer <michaelni at gmx.at> writes:
> 
> > On Mon, Jul 14, 2008 at 12:02:47AM +0100, M?ns Rullg?rd wrote:
> >> I just spent some time bug-hunting, only to discover that the
> >> exp-golomb functions in golomb.h do not work with
> >> LIBMPEG2_BITSTREAM_READER.  This is because they rely on more than the
> >> promised 17 bits to be available after an UPDATE_CACHE() call.
> >> 
> >> To avoid future mishaps, I was thinking of adding a preprocessor check
> >> to golomb.h (I'm too lazy to try to make it work). 
> >
> > try:
> > @@ -64,10 +63,12 @@
> >
> >          return ff_ue_golomb_vlc_code[buf];
> >      }else{
> > -        log= 2*av_log2(buf) - 31;
> > -        buf>>= log;
> > +        log= 31 - av_log2(buf);
> > +        LAST_SKIP_BITS(re, gb, log);
> > +        UPDATE_CACHE(re, gb);
> > +        buf= SHOW_UBITS(re, gb, log+1);
> >          buf--;
> > -        LAST_SKIP_BITS(re, gb, 32 - log);
> > +        LAST_SKIP_BITS(re, gb, log+1);
> >          CLOSE_READER(re, gb);
> >
> >          return buf;
> > @@ -149,10 +150,11 @@
> >
> >          return ff_se_golomb_vlc_code[buf];
> >      }else{
> > -        log= 2*av_log2(buf) - 31;
> > -        buf>>= log;
> > -
> > -        LAST_SKIP_BITS(re, gb, 32 - log);
> > +        log= 31 - av_log2(buf);
> > +        LAST_SKIP_BITS(re, gb, log);
> > +        UPDATE_CACHE(re, gb);
> > +        buf= SHOW_UBITS(re, gb, log+1);
> > +        LAST_SKIP_BITS(re, gb, log+1);
> >          CLOSE_READER(re, gb);
> >
> >          if(buf&1) buf= -(buf>>1);
> 
> This seems to work with the samples I've tried it on.

But it likely will slow the code down thus i think we cannot
add it by default. #ifdef would be ugly. That leaves
waiting for someone to move this code into a noinline function and
do some benchmarks to ensure the noinline as well as the new code
causes no speedloss.

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I have never wished to cater to the crowd; for what I know they do not
approve, and what they approve I do not know. -- Epicurus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080716/86d301b5/attachment.pgp>



More information about the ffmpeg-devel mailing list