video/mp_image: fix vf=format colorspace override for XYZ

If format is RGB but flagged as XYZ it should be used instead.
This commit is contained in:
Kacper Michajłow 2024-11-17 10:21:16 +01:00
parent 638ada18f8
commit 4e5cc9cf1d
1 changed files with 10 additions and 3 deletions

View File

@ -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) 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; 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) 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) if (params->color.transfer == PL_COLOR_TRC_UNKNOWN)
params->color.transfer = PL_COLOR_TRC_BT_1886; params->color.transfer = PL_COLOR_TRC_BT_1886;
} else if (forced_csp == PL_COLOR_SYSTEM_RGB) { } else if (forced_csp == PL_COLOR_SYSTEM_RGB) {
params->repr.sys = PL_COLOR_SYSTEM_RGB; if (params->repr.sys == PL_COLOR_SYSTEM_UNKNOWN)
params->repr.levels = PL_COLOR_LEVELS_FULL; 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 // The majority of RGB content is either sRGB or (rarely) some other
// color space which we don't even handle, like AdobeRGB or // color space which we don't even handle, like AdobeRGB or