[FFmpeg-cvslog] sunrast: Add support for negative linesize.

Aneesh Dogra git at videolan.org
Sun Mar 25 03:10:31 CEST 2012


ffmpeg | branch: master | Aneesh Dogra <lionaneesh at gmail.com> | Fri Mar 23 23:42:00 2012 +0530| [cc965300cb504ce452df1d37041b81c6ee6a5964] | committer: Justin Ruggles

sunrast: Add support for negative linesize.

Signed-off-by: Justin Ruggles <justin.ruggles at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=cc965300cb504ce452df1d37041b81c6ee6a5964
---

 libavcodec/sunrastenc.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/libavcodec/sunrastenc.c b/libavcodec/sunrastenc.c
index a9b4749..1ed1d6e 100644
--- a/libavcodec/sunrastenc.c
+++ b/libavcodec/sunrastenc.c
@@ -83,15 +83,18 @@ static void sunrast_image_write_image(AVCodecContext *avctx,
      if (s->type == RT_BYTE_ENCODED) {
         uint8_t value, value2;
         int run;
-        const uint8_t *end = pixels + avctx->height * linesize;
+        const uint8_t *start = linesize < 0 ? pixels + (avctx->height - 1) * linesize
+                                            : pixels;
+        const uint8_t *end   = linesize < 0 ? pixels - linesize
+                                            : pixels + avctx->height * linesize;
 
         ptr = pixels;
 
-#define GET_VALUE ptr >= end ? 0 : x >= len ? ptr[len-1] : ptr[x]
+#define GET_VALUE ptr >= end || ptr < start ? 0 : x >= len ? ptr[len-1] : ptr[x]
 
         x = 0;
         value2 = GET_VALUE;
-        while (ptr < end) {
+        while (ptr < end && ptr >= start) {
             run = 1;
             value = value2;
             x++;
@@ -101,7 +104,7 @@ static void sunrast_image_write_image(AVCodecContext *avctx,
             }
 
             value2 = GET_VALUE;
-            while (value2 == value && run < 256 && ptr < end) {
+            while (value2 == value && run < 256 && ptr < end && ptr >= start) {
                 x++;
                 run++;
                 if (x >= alen) {



More information about the ffmpeg-cvslog mailing list