[FFmpeg-devel] [PATCH]Fix buffer size for 4bpp and 2bpp raw video

Carl Eugen Hoyos cehoyos at ag.or.at
Fri Jul 1 00:00:11 CEST 2011


Hi!

Attached patch fixes decoding of some 4bpp and 2bpp samples.

Please comment, Carl Eugen
-------------- next part --------------
diff --git a/libavcodec/rawdec.c b/libavcodec/rawdec.c
index 6644d6c..1f56db8 100644
--- a/libavcodec/rawdec.c
+++ b/libavcodec/rawdec.c
@@ -103,7 +103,7 @@ static av_cold int raw_init_decoder(AVCodecContext *avctx)
     }
 
     ff_set_systematic_pal2(context->palette, avctx->pix_fmt);
-    context->length = avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height);
+    context->length = avpicture_get_size(avctx->pix_fmt, (avctx->width+3)&~3, avctx->height);
     if((avctx->bits_per_coded_sample == 4 || avctx->bits_per_coded_sample == 2) &&
        avctx->pix_fmt==PIX_FMT_PAL8 &&
        (!avctx->codec_tag || avctx->codec_tag == MKTAG('r','a','w',' '))){


More information about the ffmpeg-devel mailing list