[FFmpeg-devel] [PATCH] Sun Rasterfile decoder

Michael Niedermayer michaelni
Fri Dec 28 04:40:23 CET 2007


On Fri, Dec 28, 2007 at 12:18:47AM +0100, Ivo wrote:
> 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 {

ok

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

I do not agree with what you have to say, but I'll defend to the death your
right to say it. -- Voltaire
-------------- 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/20071228/97ef99f4/attachment.pgp>



More information about the ffmpeg-devel mailing list