diff --git a/libavcodec/imgconvert.c b/libavcodec/imgconvert.c index e1dde8146d..0fb2fe6c46 100644 --- a/libavcodec/imgconvert.c +++ b/libavcodec/imgconvert.c @@ -760,8 +760,8 @@ int avpicture_layout(const AVPicture* src, enum PixelFormat pix_fmt, int width, for (i=0; i> desc->log2_chroma_w) * pf->depth + 7) / 8; - h = height >> desc->log2_chroma_h; + w = (- ((-width) >> desc->log2_chroma_w) * pf->depth + 7) / 8; + h = -((-height) >> desc->log2_chroma_h); if (pix_fmt == PIX_FMT_NV12 || pix_fmt == PIX_FMT_NV21) w <<= 1; } else if (i == 3) {