]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/msrledec.c
Disable image flipping during JPEG decoding if CODEC_FLAG_EMU_EDGE is set
[ffmpeg] / libavcodec / msrledec.c
index 1401ee3424ee59bdb25d2e47d234b5a582366f96..b8f5e6246b7d59950dd09f9e4dc97b9d769b090b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Micrsoft RLE Decoder
+ * Microsoft RLE decoder
  * Copyright (C) 2008 Konstantin Shishkov
  *
  * This file is part of FFmpeg.
@@ -21,7 +21,7 @@
 
 /**
  * @file libavcodec/msrledec.c
- * MS RLE Decoder based on decoder by Mike Melanson and my own for TSCC
+ * MS RLE decoder based on decoder by Mike Melanson and my own for TSCC
  * For more information about the MS RLE format, visit:
  *   http://www.multimedia.cx/msrle.txt
  */
@@ -146,7 +146,7 @@ static int msrle_decode_8_16_24_32(AVCodecContext *avctx, AVPicture *pic, int de
             p2 = *src++;
             if(p2 == 0) { //End-of-line
                 output = pic->data[0] + (--line) * pic->linesize[0];
-                if (line < 0){
+                if (line < 0 && !(src+1 < data + srcsize && AV_RB16(src) == 1)) {
                     av_log(avctx, AV_LOG_ERROR, "Next line is beyond picture bounds\n");
                     return -1;
                 }
@@ -167,7 +167,8 @@ static int msrle_decode_8_16_24_32(AVCodecContext *avctx, AVPicture *pic, int de
                 continue;
             }
             // Copy data
-            if (output + p2 * (depth >> 3) > output_end) {
+            if ((pic->linesize[0] > 0 && output + p2 * (depth >> 3) > output_end)
+              ||(pic->linesize[0] < 0 && output + p2 * (depth >> 3) < output_end)) {
                 src += p2 * (depth >> 3);
                 continue;
             }
@@ -195,7 +196,7 @@ static int msrle_decode_8_16_24_32(AVCodecContext *avctx, AVPicture *pic, int de
                 }
             }
             pos += p2;
-        } else { //Run of pixels
+        } else { //run of pixels
             uint8_t pix[3]; //original pixel
             switch(depth){
             case  8: pix[0] = *src++;
@@ -211,7 +212,8 @@ static int msrle_decode_8_16_24_32(AVCodecContext *avctx, AVPicture *pic, int de
                      src += 4;
                      break;
             }
-            if (output + p1 * (depth >> 3) > output_end)
+            if ((pic->linesize[0] > 0 && output + p1 * (depth >> 3) > output_end)
+              ||(pic->linesize[0] < 0 && output + p1 * (depth >> 3) < output_end))
                 continue;
             for(i = 0; i < p1; i++) {
                 switch(depth){
@@ -233,7 +235,7 @@ static int msrle_decode_8_16_24_32(AVCodecContext *avctx, AVPicture *pic, int de
         }
     }
 
-    av_log(avctx, AV_LOG_WARNING, "MS RLE warning: no End-of-picture code\n");
+    av_log(avctx, AV_LOG_WARNING, "MS RLE warning: no end-of-picture code\n");
     return 0;
 }