From 4e5cc9cf1dd7471eca3c9c43c60fbf680dea2aa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= Date: Sun, 17 Nov 2024 10:21:16 +0100 Subject: [PATCH] video/mp_image: fix vf=format colorspace override for XYZ If format is RGB but flagged as XYZ it should be used instead. --- video/mp_image.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/video/mp_image.c b/video/mp_image.c index 83fa7e9ea6..b1d32e8615 100644 --- a/video/mp_image.c +++ b/video/mp_image.c @@ -488,7 +488,12 @@ void mp_image_copy(struct mp_image *dst, struct mp_image *src) static enum pl_color_system mp_image_params_get_forced_csp(struct mp_image_params *params) { int imgfmt = params->hw_subfmt ? params->hw_subfmt : params->imgfmt; - return mp_imgfmt_get_forced_csp(imgfmt); + enum pl_color_system csp = mp_imgfmt_get_forced_csp(imgfmt); + + if (csp == PL_COLOR_SYSTEM_RGB && params->repr.sys == PL_COLOR_SYSTEM_XYZ) + csp = PL_COLOR_SYSTEM_XYZ; + + return csp; } static void assign_bufref(AVBufferRef **dst, AVBufferRef *new) @@ -955,8 +960,10 @@ void mp_image_params_guess_csp(struct mp_image_params *params) if (params->color.transfer == PL_COLOR_TRC_UNKNOWN) params->color.transfer = PL_COLOR_TRC_BT_1886; } else if (forced_csp == PL_COLOR_SYSTEM_RGB) { - params->repr.sys = PL_COLOR_SYSTEM_RGB; - params->repr.levels = PL_COLOR_LEVELS_FULL; + if (params->repr.sys == PL_COLOR_SYSTEM_UNKNOWN) + params->repr.sys = PL_COLOR_SYSTEM_RGB; + if (params->repr.levels == PL_COLOR_LEVELS_UNKNOWN) + params->repr.levels = PL_COLOR_LEVELS_FULL; // The majority of RGB content is either sRGB or (rarely) some other // color space which we don't even handle, like AdobeRGB or