summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorNiklas Haas <git@haasn.dev>2022-11-19 14:12:24 +0100
committersfan5 <sfan5@live.de>2023-01-24 15:56:56 +0100
commit5fb7a23d378ee8f84d35e1dbf92a54ce88069fb9 (patch)
tree5d4191cc503b3581762d826c7dd5cffe115fd482 /video
parentf593186e7da949bf9951dcdb9cadf08b1cd3416a (diff)
downloadmpv-5fb7a23d378ee8f84d35e1dbf92a54ce88069fb9.tar.bz2
mpv-5fb7a23d378ee8f84d35e1dbf92a54ce88069fb9.tar.xz
vo_gpu_next: fix undefined behavior on alpha-first formats
When the alpha channel is the first component, this code block gets skipped by the continue, meaning the check for c==0 never passes. Fix it by explicitly keeping track of whether bits have been set.
Diffstat (limited to 'video')
-rw-r--r--video/out/vo_gpu_next.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/video/out/vo_gpu_next.c b/video/out/vo_gpu_next.c
index 0536abcea1..2830120629 100644
--- a/video/out/vo_gpu_next.c
+++ b/video/out/vo_gpu_next.c
@@ -344,7 +344,9 @@ static int plane_data_from_imgfmt(struct pl_plane_data out_data[4],
if ((desc.flags & MP_IMGFLAG_TYPE_FLOAT) && (desc.flags & MP_IMGFLAG_YUV))
return 0; // Floating-point YUV (currently) unsupported
+ bool has_bits = false;
bool any_padded = false;
+
for (int p = 0; p < desc.num_planes; p++) {
struct pl_plane_data *data = &out_data[p];
struct mp_imgfmt_comp_desc sorted[MP_NUM_COMPONENTS];
@@ -390,8 +392,9 @@ static int plane_data_from_imgfmt(struct pl_plane_data out_data[4],
.bit_shift = MPMAX(sorted[c].pad, 0),
};
- if (p == 0 && c == 0) {
+ if (!has_bits) {
*out_bits = bits;
+ has_bits = true;
} else {
if (!pl_bit_encoding_equal(out_bits, &bits)) {
// Bit encoding differs between components/planes,