You've already forked FFmpeg
							
							
				mirror of
				https://github.com/FFmpeg/FFmpeg.git
				synced 2025-10-30 23:18:11 +02:00 
			
		
		
		
	lavc/sunrastenc: consider cases with linesize < 0
Make sunrast_image_write_image() deal with cases when linesize is < 0. Fix trac ticket #1077.
This commit is contained in:
		| @@ -56,7 +56,7 @@ static void sunrast_image_write_image(AVCodecContext *avctx, | |||||||
| { | { | ||||||
|     SUNRASTContext *s = avctx->priv_data; |     SUNRASTContext *s = avctx->priv_data; | ||||||
|     const uint8_t *ptr; |     const uint8_t *ptr; | ||||||
|     int len, alen, x; |     int len, alen, x, y; | ||||||
|  |  | ||||||
|     if (s->maplength) {     // palettized |     if (s->maplength) {     // palettized | ||||||
|         PutByteContext pb_r, pb_g; |         PutByteContext pb_r, pb_g; | ||||||
| @@ -83,30 +83,30 @@ static void sunrast_image_write_image(AVCodecContext *avctx, | |||||||
|      if (s->type == RT_BYTE_ENCODED) { |      if (s->type == RT_BYTE_ENCODED) { | ||||||
|         uint8_t value, value2; |         uint8_t value, value2; | ||||||
|         int run; |         int run; | ||||||
|         const uint8_t *end = pixels + avctx->height * linesize; |  | ||||||
|  |  | ||||||
|  |         y = 0; | ||||||
|         ptr = pixels; |         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; |         value2 = GET_VALUE; | ||||||
|         while (ptr < end) { |         while (y < avctx->height) { | ||||||
|             run = 1; |             run = 1; | ||||||
|             value = value2; |             value = value2; | ||||||
|             x++; |             x++; | ||||||
|             if (x >= alen) { |             if (x >= alen) { | ||||||
|                 x = 0; |                 x = 0; | ||||||
|                 ptr += linesize; |                 ptr += linesize, y++; | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             value2 = GET_VALUE; |             value2 = GET_VALUE; | ||||||
|             while (value2 == value && run < 256 && ptr < end) { |             while (value2 == value && run < 256 && y < avctx->height) { | ||||||
|                 x++; |                 x++; | ||||||
|                 run++; |                 run++; | ||||||
|                 if (x >= alen) { |                 if (x >= alen) { | ||||||
|                     x = 0; |                     x = 0; | ||||||
|                     ptr += linesize; |                     ptr += linesize, y++; | ||||||
|                 } |                 } | ||||||
|                 value2 = GET_VALUE; |                 value2 = GET_VALUE; | ||||||
|             } |             } | ||||||
| @@ -125,7 +125,6 @@ static void sunrast_image_write_image(AVCodecContext *avctx, | |||||||
|         // update data length for header |         // update data length for header | ||||||
|         s->length = bytestream2_tell_p(&s->p) - 32 - s->maplength; |         s->length = bytestream2_tell_p(&s->p) - 32 - s->maplength; | ||||||
|     } else { |     } else { | ||||||
|         int y; |  | ||||||
|         for (y = 0; y < avctx->height; y++) { |         for (y = 0; y < avctx->height; y++) { | ||||||
|             bytestream2_put_buffer(&s->p, ptr, len); |             bytestream2_put_buffer(&s->p, ptr, len); | ||||||
|             if (len < alen) |             if (len < alen) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user