summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2019-11-02 18:49:17 +0100
committerwm4 <wm4@nowhere>2019-11-02 18:49:17 +0100
commit6eb0dc54477aebe49c14fc17046cd08493177630 (patch)
tree3781c6d5061053a19ddfd8531ef802f8d19eed38
parentd26c1c68141d7e45f94786831fd7bdf7e2a05040 (diff)
downloadmpv-6eb0dc54477aebe49c14fc17046cd08493177630.tar.bz2
mpv-6eb0dc54477aebe49c14fc17046cd08493177630.tar.xz
zimg: support subsampled chroma with non-aligned image sizes
-rw-r--r--video/zimg.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/video/zimg.c b/video/zimg.c
index 16987f3561..04a500705d 100644
--- a/video/zimg.c
+++ b/video/zimg.c
@@ -641,8 +641,15 @@ static bool setup_format(zimg_image_format *zfmt, struct mp_zimg_repack *r,
r->zplanes = desc.num_planes;
- zfmt->width = fmt.w;
- zfmt->height = fmt.h;
+ // Note: formats with subsampled chroma may have odd width or height in mpv
+ // and FFmpeg. This is because the width/height is actually a cropping
+ // rectangle. Reconstruct the image allocation size and set the cropping.
+ zfmt->width = MP_ALIGN_UP(fmt.w, desc.chroma_w);
+ zfmt->height = MP_ALIGN_UP(fmt.h, desc.chroma_h);
+ if (zfmt->width != fmt.w)
+ zfmt->active_region.width = fmt.w;
+ if (zfmt->height != fmt.h)
+ zfmt->active_region.height = fmt.h;
zfmt->subsample_w = mp_log2(desc.chroma_w);
zfmt->subsample_h = mp_log2(desc.chroma_h);