From e6c18641bd52375bc3429ec2771f4fdfede5dc1e Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Thu, 24 Feb 2022 15:49:30 +0100 Subject: mp_image: fix mp_image_plane_w/h These helpers, for some reason, decided to round the returned values up to multiples of the nearest plane alignment. This logic makes no sense to me, and completely breaks any sort of oddly-sized mp_image. This logic was introduced, presumably in error and without real justification, as part of a major refactor commit (caee8748), As far as I can tell, removing it again doesn't regress anything. Fixes several serious bugs including buffer underflows and GPU crashes in vo_gpu and vo_gpu_next. --- video/mp_image.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/video/mp_image.c b/video/mp_image.c index 11539eb7c7..176497627e 100644 --- a/video/mp_image.c +++ b/video/mp_image.c @@ -218,15 +218,13 @@ int mp_chroma_div_up(int size, int shift) // Return the storage width in pixels of the given plane. int mp_image_plane_w(struct mp_image *mpi, int plane) { - return mp_chroma_div_up(MP_ALIGN_UP(mpi->w, mpi->fmt.align_x), - mpi->fmt.xs[plane]); + return mp_chroma_div_up(mpi->w, mpi->fmt.xs[plane]); } // Return the storage height in pixels of the given plane. int mp_image_plane_h(struct mp_image *mpi, int plane) { - return mp_chroma_div_up(MP_ALIGN_UP(mpi->h, mpi->fmt.align_y), - mpi->fmt.ys[plane]); + return mp_chroma_div_up(mpi->h, mpi->fmt.ys[plane]); } // Caller has to make sure this doesn't exceed the allocated plane data/strides. -- cgit v1.2.3