[FFmpeg-devel] [PATCH] Escape 124 (RPL) decoder rev3

Michael Niedermayer michaelni
Sat Mar 29 21:58:50 CET 2008


On Sat, Mar 29, 2008 at 01:28:51PM -0700, Eli Friedman wrote:
> On Sat, Mar 29, 2008 at 11:47 AM, Michael Niedermayer <michaelni at gmx.at> wrote:
> >  > +            if (i == 0) {
> >  > +                // This is the most basic codebook: pow(2,depth) entries for
> >  > +                // a depth-length key
> >  > +                cb_depth = get_bits(&gb, 4);
> >  > +                cb_size = 1 << cb_depth;
> >  > +                cb_alloc_size = cb_size;
> >  > +            } else if (i == 1) {
> >  > +                // This codebook varies per superblock
> >  > +                // FIXME: I don't think this handles integer overflow
> >  > +                // properly
> >  > +                cb_depth = get_bits(&gb, 4);
> >  > +                cb_size = s->num_superblocks << cb_depth;
> >  > +                cb_alloc_size = cb_size;
> >  > +            } else {
> >  > +                // This codebook can be cut off at places other than
> >  > +                // powers of 2, leaving some of the entries undefined.
> >  > +                cb_size = get_bits_long(&gb, 20);
> >  > +                cb_depth = av_log2(cb_size - 1) + 1;
> >  > +                cb_alloc_size = 1 << cb_depth;
> >  > +            }
> >
> >  What is the use of having cb_alloc_size > cb_size ?
> 
> So that the code doesn't crash on invalid bitstreams.

Id rather check for the index being invalid. Either way such rounding
up belongs somewhere else, not outside the function allocating stuff.
And there should be a comment explaining the reason for the round up.


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

I wish the Xiph folks would stop pretending they've got something they
do not.  Somehow I fear this will remain a wish. -- M?ns Rullg?rd
-------------- 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/20080329/27ddd736/attachment.pgp>



More information about the ffmpeg-devel mailing list