1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-23 15:22:09 +00:00

mp_image: align image allocation height

vo_vdpau actually reads past the image allocation when displaying a
non-mod 2 420p image. The vdpau API specifies that VdpVideoSurfacePutBitsYCbCr()
requires a height that is a multiple of 4, and surface allocations are
automatically rounded.

So allocate video images with rounded height. libavutil does the same,
so images coming directly from the decoder or from libavfilter are no
problem. (libavutil does this alginment explicitly, not just because the
decoded image size is aligned to macroblocks.)
This commit is contained in:
wm4 2013-05-17 23:45:55 +02:00
parent 883d03fffd
commit e40ae27a87

View File

@ -102,9 +102,10 @@ static void mp_image_alloc_planes(struct mp_image *mpi)
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];
int line_bytes = (mpi->plane_w[n] * mpi->fmt.bpp[n] + 7) / 8;
mpi->stride[n] = FFALIGN(line_bytes, SWS_MIN_BYTE_ALIGN);
plane_size[n] = mpi->stride[n] * mpi->plane_h[n];
plane_size[n] = mpi->stride[n] * alloc_h;
}
if (mpi->imgfmt == IMGFMT_PAL8)
plane_size[1] = MP_PALETTE_SIZE;