for (i=0; i<data_planes; i++) {
if (i == 1) {
- w = ((width >> 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) {