[FFmpeg-devel] [PATCH]Simplify targa decoding
Reimar Döffinger
Reimar.Doeffinger at gmx.de
Tue Jan 17 19:12:26 CET 2012
On Tue, Jan 17, 2012 at 11:41:59AM +0100, Carl Eugen Hoyos wrote:
> Hi!
>
> Attached patch passes fate on le and be.
>
> Please review, Carl Eugen
> diff --git a/libavcodec/targa.c b/libavcodec/targa.c
> index 57a4fee..8bed429 100644
> --- a/libavcodec/targa.c
> +++ b/libavcodec/targa.c
> @@ -65,22 +65,7 @@ static int targa_decode_rle(AVCodecContext *avctx, TargaContext *s, const uint8_
> CHECK_BUFFER_SIZE(src, src_end, count * depth, "image data");
> }
> for(i = 0; i < count; i++){
> - switch(depth){
> - case 1:
> - *dst = *src;
> - break;
> - case 2:
> - *((uint16_t*)dst) = AV_RL16(src);
> - break;
> - case 3:
> - dst[0] = src[0];
> - dst[1] = src[1];
> - dst[2] = src[2];
> - break;
> - case 4:
> - *((uint32_t*)dst) = AV_RL32(src);
> - break;
> - }
> + memcpy(dst, src, count * depth);
> dst += depth;
> if(!type)
> src += depth;
Without having looked properly, I suspect something isn't right here,
you memcpy count*depth but increment only by depth and loop
around all this count times, or am I missing something?
More information about the ffmpeg-devel
mailing list