Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions video/mp_image.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
17 changes: 0 additions & 17 deletions video/out/vo_gpu_next.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading