diff options
author | Stefano Sabatini <stefasab@gmail.com> | 2012-03-18 16:55:53 +0100 |
---|---|---|
committer | Stefano Sabatini <stefasab@gmail.com> | 2012-03-19 19:01:40 +0100 |
commit | 11642cd16f1b18232bdeca4cddb2dd7c11cbd2f3 (patch) | |
tree | 83603c54dc49c5189b41a32ba3f7d1d2e49e6484 | |
parent | f645132061141e1ab8e243eea00d3eac17f43b0f (diff) | |
download | ffmpeg-11642cd16f1b18232bdeca4cddb2dd7c11cbd2f3.tar.gz |
lavc/sunrastenc: consider cases with linesize < 0
Make sunrast_image_write_image() deal with cases when linesize is < 0.
Fix trac ticket #1077.
-rw-r--r-- | libavcodec/sunrastenc.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/libavcodec/sunrastenc.c b/libavcodec/sunrastenc.c index a9b4749758..6aae353983 100644 --- a/libavcodec/sunrastenc.c +++ b/libavcodec/sunrastenc.c @@ -56,7 +56,7 @@ static void sunrast_image_write_image(AVCodecContext *avctx, { SUNRASTContext *s = avctx->priv_data; const uint8_t *ptr; - int len, alen, x; + int len, alen, x, y; if (s->maplength) { // palettized PutByteContext pb_r, pb_g; @@ -83,30 +83,30 @@ 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; + y = 0; ptr = pixels; -#define GET_VALUE ptr >= end ? 0 : x >= len ? ptr[len-1] : ptr[x] +#define GET_VALUE y >= avctx->height ? 0 : x >= len ? ptr[len-1] : ptr[x] - x = 0; + x = 0, y = 0; value2 = GET_VALUE; - while (ptr < end) { + while (y < avctx->height) { run = 1; value = value2; x++; if (x >= alen) { x = 0; - ptr += linesize; + ptr += linesize, y++; } value2 = GET_VALUE; - while (value2 == value && run < 256 && ptr < end) { + while (value2 == value && run < 256 && y < avctx->height) { x++; run++; if (x >= alen) { x = 0; - ptr += linesize; + ptr += linesize, y++; } value2 = GET_VALUE; } @@ -125,7 +125,6 @@ static void sunrast_image_write_image(AVCodecContext *avctx, // update data length for header s->length = bytestream2_tell_p(&s->p) - 32 - s->maplength; } else { - int y; for (y = 0; y < avctx->height; y++) { bytestream2_put_buffer(&s->p, ptr, len); if (len < alen) |