[FFmpeg-devel] [PATCH] Electronic Arts TGV decoder

pross at xvid.org pross
Thu Jul 10 11:43:54 CEST 2008


On Thu, Jul 10, 2008 at 01:00:32AM +0200, Michael Niedermayer wrote:
> On Wed, Jul 09, 2008 at 09:18:13PM +1000, pross at xvid.org wrote:
> > Hi!
> > 
> > Second video codec in the EA series.
> > 
> > Samples: http://samples.mplayerhq.hu/game-formats/ea-tgv/
> > Write-up: http://wiki.multimedia.cx/index.php?title=Electronic_Arts_TGV
> [...]
> 
> > +
> > +/**
> > + * Unpack buffer
> > + * @return 0 on success, -1 on critical buffer underflow
> > + */
> > +static int unpack(const uint8_t *src, const uint8_t *src_end, unsigned char *dst, int width, int stride) {
> > +    int size1,size2,offset;
> > +    int size;
> > +    int i;
> > +    int o = 0;
> > +
> 
> > +    if (src+2>src_end)
> > +        return -1;
> > +    if ((AV_RB16(&src[0]) & 0x0100))
> > +        src += 5;
> > +    else
> > +        src += 2;
> > +
> > +    if (src+4>src_end)
> > +        return -1;
> > +    size = AV_RB24(&src[0]);
> > +    src += 3;
> 
> the first end check seems unneeded, and reading a byte would be enough for
> the if()

Thanks for the feedback, but can you explain this comment further.
Why is the first check unnecessary?
What do you mean by the second part of the sentence?

Nb: To be further pedantic, the second check could be src+3>src_end
(and not +4) because it is only fetching 24-bits.

Cheers,
-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
-------------- 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/20080710/5d6b6d81/attachment.pgp>



More information about the ffmpeg-devel mailing list