]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/pictordec.c
build: Try to find fate_config.sh.template in source path
[ffmpeg] / libavcodec / pictordec.c
index 09aae720e4e76bd004b5182e0b461aed9d144e35..7c95f89bbde8ade77166b20a9881ba9f71237774 100644 (file)
@@ -130,7 +130,7 @@ static int decode_frame(AVCodecContext *avctx,
         return AVERROR_INVALIDDATA;
     }
 
-    if (*buf == 0xFF) {
+    if (*buf == 0xFF || bpp == 8) {
         buf += 2;
         etype  = bytestream_get_le16(&buf);
         esize  = bytestream_get_le16(&buf);
@@ -198,17 +198,17 @@ static int decode_frame(AVCodecContext *avctx,
     buf += esize;
 
 
-    x = 0;
     y = s->height - 1;
-    plane = 0;
     if (bytestream_get_le16(&buf)) {
-        while (buf_end - buf >= 6) {
+        x = 0;
+        plane = 0;
+        while (y >= 0 && buf_end - buf >= 6) {
             const uint8_t *buf_pend = buf + FFMIN(AV_RL16(buf), buf_end - buf);
             //ignore uncompressed block size reported at buf[2]
             int marker = buf[4];
             buf += 5;
 
-            while (plane < s->nb_planes && buf_pend - buf >= 1) {
+            while (plane < s->nb_planes && y >= 0 && buf_pend - buf >= 1) {
                 int run = 1;
                 int val = *buf++;
                 if (val == marker) {
@@ -222,16 +222,17 @@ static int decode_frame(AVCodecContext *avctx,
 
                 if (bits_per_plane == 8) {
                     picmemset_8bpp(s, val, run, &x, &y);
-                    if (y < 0)
-                        break;
                 } else {
                     picmemset(s, val, run, &x, &y, &plane, bits_per_plane);
                 }
             }
         }
     } else {
-        av_log_ask_for_sample(avctx, "uncompressed image\n");
-        return buf_size;
+        while (y >= 0 && buf < buf_end) {
+            memcpy(s->frame.data[0] + y * s->frame.linesize[0], buf, FFMIN(avctx->width, buf_end - buf));
+            buf += avctx->width;
+            y--;
+        }
     }
 
     *data_size = sizeof(AVFrame);