[FFmpeg-devel] [PATCH] Sun Rasterfile decoder

Ivo ivop
Fri Dec 28 00:18:47 CET 2007


On Thursday 27 December 2007 15:38, Michael Niedermayer wrote:
> On Thu, Dec 27, 2007 at 12:53:16PM +0100, Ivo wrote:
> > 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?

Yes, it is. I removed the whole 'a' variable and changed it to 
a 'while(ptr!=end)' loop:

    if (type == RT_BYTE_ENCODED) {
        int value, run;
        uint8_t *end = ptr + h*stride;

        x = 0;
        while (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;
                }
            }
        }
    } else {

--Ivo




More information about the ffmpeg-devel mailing list