mirror of
https://github.com/mpv-player/mpv
synced 2025-02-18 22:06:59 +00:00
mp_image: align stride to multiple of texel size
This helps with compatibility and/or performance in particular for oddly-sized formats like rgb24. We use a loop to avoid having to calculate the lcm (or waste bytes in the extremely common case of the byte size and the stride align having shared factors).
This commit is contained in:
parent
a3c808c6c8
commit
9f7dcc0726
@ -72,6 +72,9 @@ static int mp_image_layout(int imgfmt, int w, int h, int stride_align,
|
||||
int alloc_h = MP_ALIGN_UP(h, 32) >> desc.ys[n];
|
||||
int line_bytes = (alloc_w * desc.bpp[n] + 7) / 8;
|
||||
out_stride[n] = MP_ALIGN_UP(line_bytes, stride_align);
|
||||
// also align to a multiple of desc.bytes[n]
|
||||
while (desc.bytes[n] && out_stride[n] % desc.bytes[n])
|
||||
out_stride[n] += stride_align;
|
||||
out_plane_size[n] = out_stride[n] * alloc_h;
|
||||
}
|
||||
if (desc.flags & MP_IMGFLAG_PAL)
|
||||
|
Loading…
Reference in New Issue
Block a user