diff options
-rw-r--r-- | video/mp_image.c | 4 | ||||
-rw-r--r-- | video/out/gl_video.c | 12 |
2 files changed, 14 insertions, 2 deletions
diff --git a/video/mp_image.c b/video/mp_image.c index 0013c132fa..4015f27d4a 100644 --- a/video/mp_image.c +++ b/video/mp_image.c @@ -125,6 +125,10 @@ static void mp_image_alloc_planes(struct mp_image *mpi) { assert(!mpi->planes[0]); + // Note: for non-mod-2 4:2:0 YUV frames, we have to allocate an additional + // top/right border. This is needed for correct handling of such + // images in filter and VO code (e.g. vo_vdpau or vo_opengl). + size_t plane_size[MP_MAX_PLANES]; for (int n = 0; n < MP_MAX_PLANES; n++) { int alloc_h = MP_ALIGN_UP(mpi->h, 32) >> mpi->fmt.ys[n]; diff --git a/video/out/gl_video.c b/video/out/gl_video.c index 273e3ac968..0706d65b19 100644 --- a/video/out/gl_video.c +++ b/video/out/gl_video.c @@ -1207,13 +1207,21 @@ static void init_video(struct gl_video *p) debug_check_gl(p, "before video texture creation"); + // For video with odd sizes: enlarge the luma texture so that it covers all + // chroma pixels - then we can render these correctly by cropping the final + // image (conceptually). + // Image allocations are always such that the "additional" luma border + // exists and can be accessed. + int full_w = MP_ALIGN_UP(p->image_w, 1 << p->image_desc.chroma_xs); + int full_h = MP_ALIGN_UP(p->image_h, 1 << p->image_desc.chroma_ys); + struct video_image *vimg = &p->image; for (int n = 0; n < p->plane_count; n++) { struct texplane *plane = &vimg->planes[n]; - plane->w = p->image_w >> p->image_desc.xs[n]; - plane->h = p->image_h >> p->image_desc.ys[n]; + plane->w = full_w >> p->image_desc.xs[n]; + plane->h = full_h >> p->image_desc.ys[n]; tex_size(p, plane->w, plane->h, &plane->tex_w, &plane->tex_h); |