[FFmpeg-devel] [PATCH] Sun Rasterfile decoder

Ivo ivop
Thu Dec 27 12:53:16 CET 2007


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 {

--Ivo




More information about the ffmpeg-devel mailing list