diff options
author | Niklas Haas <git@haasn.xyz> | 2018-11-18 05:47:43 +0100 |
---|---|---|
committer | Jan Ekström <jeebjp@gmail.com> | 2019-04-21 23:55:22 +0300 |
commit | 9f7dcc0726ab635fb34fb7310e54b1aec9467f14 (patch) | |
tree | 101680ce8c4e729f6eba6bc67db3e5f33a12c160 /video/mp_image.c | |
parent | a3c808c6c8db685b492bd61fe4af01cb42ceaf18 (diff) | |
download | mpv-9f7dcc0726ab635fb34fb7310e54b1aec9467f14.tar.bz2 mpv-9f7dcc0726ab635fb34fb7310e54b1aec9467f14.tar.xz |
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).
Diffstat (limited to 'video/mp_image.c')
-rw-r--r-- | video/mp_image.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/video/mp_image.c b/video/mp_image.c index 92c3e57b95..b5780b08a0 100644 --- a/video/mp_image.c +++ b/video/mp_image.c @@ -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) |