summaryrefslogtreecommitdiff
path: root/libavcodec/imgconvert.c
diff options
context:
space:
mode:
authorRamiro Polla <ramiro.polla@gmail.com>2009-11-25 17:14:48 +0000
committerRamiro Polla <ramiro.polla@gmail.com>2009-11-25 17:14:48 +0000
commitf2526204a40ed2ea49c0023cb561f05cccfe4196 (patch)
tree99a39c6cad7dc9acf7f5d120970c1b720e047f10 /libavcodec/imgconvert.c
parent800841fd0c6c686c62bdd482e46b6c61b72fa531 (diff)
Fix nv12/nv21 handling. linesize for plane 1 should account for both chroma
planes instead of just doubling the height while computing plane sizes. Also adjust avpicture_layout() to copy the correct amount of data for plane 1. Originally committed as revision 20610 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/imgconvert.c')
-rw-r--r--libavcodec/imgconvert.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/libavcodec/imgconvert.c b/libavcodec/imgconvert.c
index e83c5136b0..bf9ed39287 100644
--- a/libavcodec/imgconvert.c
+++ b/libavcodec/imgconvert.c
@@ -689,7 +689,7 @@ int ff_fill_linesize(AVPicture *picture, enum PixelFormat pix_fmt, int width)
case PIX_FMT_NV21:
w2 = (width + (1 << pinfo->x_chroma_shift) - 1) >> pinfo->x_chroma_shift;
picture->linesize[0] = width;
- picture->linesize[1] = w2;
+ picture->linesize[1] = 2 * w2;
break;
case PIX_FMT_RGB24:
case PIX_FMT_BGR24:
@@ -789,12 +789,12 @@ int ff_fill_pointer(AVPicture *picture, uint8_t *ptr, enum PixelFormat pix_fmt,
case PIX_FMT_NV12:
case PIX_FMT_NV21:
h2 = (height + (1 << pinfo->y_chroma_shift) - 1) >> pinfo->y_chroma_shift;
- size2 = picture->linesize[1] * h2 * 2;
+ size2 = picture->linesize[1] * h2;
picture->data[0] = ptr;
picture->data[1] = picture->data[0] + size;
picture->data[2] = NULL;
picture->data[3] = NULL;
- return size + 2 * size2;
+ return size + size2;
case PIX_FMT_RGB24:
case PIX_FMT_BGR24:
case PIX_FMT_ARGB:
@@ -904,6 +904,8 @@ int avpicture_layout(const AVPicture* src, enum PixelFormat pix_fmt, int width,
if (i == 1) {
w = ((width >> pf->x_chroma_shift) * pf->depth + 7) / 8;
h = height >> pf->y_chroma_shift;
+ if (pix_fmt == PIX_FMT_NV12 || pix_fmt == PIX_FMT_NV21)
+ w <<= 1;
} else if (i == 3) {
w = ow;
h = oh;