[FFmpeg-devel] [PATCH] fix for rev11962 that broke yuv422 mpeg encoding

christophelorenz christophelorenz
Wed Feb 20 00:57:13 CET 2008


The following command
ffmpeg -i source -pix_fmt yuv422p -vcodec mpeg2video -intra -qscale 1 
output422.m2v
outputs corrupted chroma since rev 11962.
(source is 720x576, -intra and -qscale make the chroma alignment problem 
easier to see)

Rev 11962 has changed the linesize of the yuv planes using ALIGN macro 
to align Y on U dimension.
However macro is only designed to align to pow2 values and not various 
image width.
Also after alignment to picture.linesize[1] there's no garantee that the 
linesize[0] is still aligned to a STRIDE_ALIGN multiple anymore.

Refs in libavcodec/utils.c:
L162:
#define ALIGN(x, a) (((x)+(a)-1)&~((a)-1))
L298:
picture.linesize[0] = ALIGN(picture.linesize[0], picture.linesize[1]);

I changed the code so that the linesize[1,2,3] are adjusted to upper 
value that is a round fraction of linesize[0],
while preserving alignment to STRIDE_ALIGN for all planes.

Chris.

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: uvmemalign.patch
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080220/04ccd712/attachment.asc>



More information about the ffmpeg-devel mailing list