[FFmpeg-devel] [PATCH] Sun Rasterfile decoder

Michael Niedermayer michaelni
Thu Dec 27 15:38:25 CET 2007


On Thu, Dec 27, 2007 at 12:53:16PM +0100, Ivo wrote:
> On Thursday 27 December 2007 01:53, Michael Niedermayer wrote:
> > On Thu, Dec 27, 2007 at 12:16:24AM +0100, Ivo wrote:
> > > +    AVFrame * const p = (AVFrame *)&s->picture;
> >
> > hmmmmmmmm
> 
> Oops, forgot that one. Fixed.
> 
> > > +    if (type == RT_BYTE_ENCODED) {
> > > +        int a, value, run;
> > > +        uint8_t *end = ptr + h*stride;
> > > +
> > > +        x = 0;
> > > +        for (a=0; a < alen*h && ptr < end; ) {
> >
> > and what if stride is negative?
> 
> Yep, won't work correctly. How about this:
> 
> +    if (type == RT_BYTE_ENCODED) {
> +        int a, value, run;
> +        uint8_t *end = ptr + h*stride;
> +
> +        x = 0;
> +        for (a=0; a < alen*h && ptr != end; ) {
> +            run = 1;
> +            if ((value = *buf++) == 0x80) {
> +                run = *buf++ + 1;
> +                if (run != 1)
> +                    value = *buf++;
> +            }
> +            while (run--) {
> +                if (x < len)
> +                    ptr[x] = value;
> +                if (++x >= alen) {
> +                    x = 0;
> +                    ptr += stride;
> +                    if (ptr == end)
> +                        break;
> +                }
> +                a++;
> +            }
> +        }
> +    } else {

isnt the a < alen*h redundant?

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

No great genius has ever existed without some touch of madness. -- Aristotle
-------------- 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/20071227/190ffe04/attachment.pgp>



More information about the ffmpeg-devel mailing list