diff options
author | Reimar Döffinger <Reimar.Doeffinger@gmx.de> | 2009-03-19 21:34:55 +0000 |
---|---|---|
committer | Reimar Döffinger <Reimar.Doeffinger@gmx.de> | 2009-03-19 21:34:55 +0000 |
commit | c9d6e84778eef7ea1d04e3d5f0901debb3496d5e (patch) | |
tree | 94f2d9a4626ee1ce7fa4f2ab777372ae95f7ffdf | |
parent | b435725b4cb18a85d8a48d2a5cde37690525a589 (diff) | |
download | ffmpeg-c9d6e84778eef7ea1d04e3d5f0901debb3496d5e.tar.gz |
Change linesize alignment method to ensure that linesize[0] == 2*linesize[1]
for YUV420P and YUV422P always.
Fixes MPEG-2 4:2:2 encoding on PPC and ARM, and should fix mxf_d10 regression.
Originally committed as revision 18047 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r-- | libavcodec/utils.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c index b6412a5313..4134586c5a 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -242,6 +242,7 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){ int h_chroma_shift, v_chroma_shift; int size[4] = {0}; int tmpsize; + int unaligned; AVPicture picture; int stride_align[4]; @@ -254,8 +255,14 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){ h+= EDGE_WIDTH*2; } + do { + // NOTE: do not align linesizes individually, this breaks e.g. assumptions + // that linesize[0] == 2*linesize[1] in the MPEG-encoder for 4:2:2 ff_fill_linesize(&picture, s->pix_fmt, w); + // increase alignment of w for next try (rhs gives the lowest bit set in w) + w += w & ~(w-1); + unaligned = 0; for (i=0; i<4; i++){ //STRIDE_ALIGN is 8 for SSE* but this does not work for SVQ1 chroma planes //we could change STRIDE_ALIGN to 16 for x86/sse but it would increase the @@ -267,8 +274,9 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){ else #endif stride_align[i] = STRIDE_ALIGN; - picture.linesize[i] = ALIGN(picture.linesize[i], stride_align[i]); + unaligned |= picture.linesize[i] % stride_align[i]; } + } while (unaligned); tmpsize = ff_fill_pointer(&picture, NULL, s->pix_fmt, h); if (tmpsize < 0) |