[FFmpeg-devel] [PATCH]Fix linesize for pix_fmt pal8

Stefano Sabatini stefasab at gmail.com
Thu Jun 14 01:26:01 CEST 2012


On date Wednesday 2012-06-13 15:36:22 +0200, Carl Eugen Hoyos encoded:
> Hi!
> 
> FFmpeg currently cannot read raw pal8 files written with ffmpeg if
> width mod 4 != 0.
> Attached patch fixes that (and allows QuickTime to read the files if
> a palette is written).
> 
> Please review, Carl Eugen

> diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c
> index ef7d413..39f086f 100644
> --- a/libavutil/imgutils.c
> +++ b/libavutil/imgutils.c
> @@ -60,6 +60,11 @@ int image_get_linesize(int width, int plane,
>      linesize = max_step * shifted_w;
>      if (desc->flags & PIX_FMT_BITSTREAM)
>          linesize = (linesize + 7) >> 3;
> +    else if (desc->flags & PIX_FMT_PAL) {
> +        // 2 would be sufficient for QuickTime,
> +        // but 4 works and is what avi and mov samples use
> +        linesize = FFALIGN(linesize, 4);
> +    }
>      return linesize;

Can you elaborate why this is needed?

Note that the alignment is defined by av_image_alloc(), and in general
I don't see why a paletted image should need an aligned size, so I'd
prefer to avoid the special casing, or in other words this seems more
a libavcodec issue (and should be addressed there).
-- 
FFmpeg = Frightening Freak Most Patchable Educated Governor


More information about the ffmpeg-devel mailing list