diff --git a/video/mp_image.c b/video/mp_image.c index 83fa7e9ea6c8b..b1d32e8615005 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 diff --git a/video/out/vo_gpu_next.c b/video/out/vo_gpu_next.c index 0663777376044..b57b671b81226 100644 --- a/video/out/vo_gpu_next.c +++ b/video/out/vo_gpu_next.c @@ -625,23 +625,6 @@ static bool map_frame(pl_gpu gpu, pl_tex *tex, const struct pl_source_frame *src .user_data = mpi, }; - // mp_image, like AVFrame, likes communicating RGB/XYZ/YCbCr status - // implicitly via the image format, rather than the actual tagging. - switch (mp_imgfmt_get_forced_csp(par->imgfmt)) { - case PL_COLOR_SYSTEM_RGB: - frame->repr.sys = PL_COLOR_SYSTEM_RGB; - frame->repr.levels = PL_COLOR_LEVELS_FULL; - break; - case PL_COLOR_SYSTEM_XYZ: - frame->repr.sys = PL_COLOR_SYSTEM_XYZ; - break; - case PL_COLOR_SYSTEM_UNKNOWN: - if (!frame->repr.sys) - frame->repr.sys = pl_color_system_guess_ycbcr(par->w, par->h); - break; - default: break; - } - if (fp->hwdec) { struct mp_imgfmt_desc desc = mp_imgfmt_get_desc(par->imgfmt);