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.
This commit is contained in:
Niklas Haas 2022-02-24 15:49:30 +01:00 committed by Niklas Haas
parent 57f42cee84
commit e6c18641bd
1 changed files with 2 additions and 4 deletions

View File

@ -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.