[FFmpeg-devel] [PATCH]Fix odd RGB555 camstudio

Reimar Döffinger Reimar.Doeffinger at gmx.de
Mon Apr 16 22:24:40 CEST 2012


On Mon, Apr 16, 2012 at 11:42:26PM +0200, Carl Eugen Hoyos wrote:
> Hi!
> 
> Attached patch fixes ticket #1220 for me.
> 
> Please review, Carl Eugen

> diff --git a/libavcodec/cscd.c b/libavcodec/cscd.c
> index 032b58a..c4642be 100644
> --- a/libavcodec/cscd.c
> +++ b/libavcodec/cscd.c
> @@ -233,7 +233,11 @@ static av_cold int decode_init(AVCodecContext *avctx) {
>      c->bpp = avctx->bits_per_coded_sample;
>      avcodec_get_frame_defaults(&c->pic);
>      c->pic.data[0] = NULL;
> +    if (avctx->bits_per_coded_sample == 16) {
> +        c->linelen = (avctx->width + (avctx->width & 1)) * avctx->bits_per_coded_sample / 8;
> +    } else {
>      c->linelen = avctx->width * avctx->bits_per_coded_sample / 8;
> +    }

Maybe slightly nicer as
if (avctx->bits_per_coded_sample == 16)
    c->linelen = FFALIGN(c->linelen, 4)); // RGB16 is padded to word boundaries

Note that I chose to align the byte count instead of the width,
since this behaviour probably comes from the Windows BMP specification,
which uses this wording.
I might be confusing it with RGB24 though.
Either way, even in the original version FFALIGN might be nicer...


More information about the ffmpeg-devel mailing list