[FFmpeg-devel] [PATCH] Escape 130 (RPL) WIP2

Michael Niedermayer michaelni
Thu Apr 3 13:32:45 CEST 2008


On Wed, Apr 02, 2008 at 10:04:46PM -0700, Eli Friedman wrote:
> On Wed, Apr 2, 2008 at 4:41 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
> >  > +static int can_safely_read(GetBitContext* gb, int bits) {
> >  > +    return get_bits_count(gb) + bits <= gb->size_in_bits;
> >  > +}
> >
> >  duplicate
> 
> Would this be appropriate to put into bitstream.h? 

maybe, but i think
static inline int get_bits_left(GetBitContext* gb) {
    return gb->size_in_bits - get_bits_count(gb);
}

and checks like
if(get_bits_left(gb) < 123)

would be slightly better looking


> How does code
> outside the Escape codecs deal with overread?

Mpeg1/2/4 codecs are designed so that 24 zero bits cannot occur in a
valid bitstream, that is the 64bit at the end will cause an error if one
checks everything.
Some codecs dont check for overread (sadly ...)
Some just have code like whats in can_safely_read inlined. You can find
these by grep size_in_bits libavcodec/*.c 
It would be nice if someone would change these to use the new function.

dv.c even has its own get_bits_left(), i think i even flamed roman once
for putting that in a common header but maybe i remember it half wrong.
Back then i was against it probably because the code is so simple and
I didnt want to bloat the API but seeing now at how many places we
have code doing that. I thinkit would be slightly better with such a
function in bitstream.h


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

In a rich man's house there is no place to spit but his face.
-- Diogenes of Sinope
-------------- 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/20080403/dca530f9/attachment.pgp>



More information about the ffmpeg-devel mailing list