-
Notifications
You must be signed in to change notification settings - Fork 3k
vo_gpu_next: implement target_csp for wayland and automatic color space switching #16321
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
base: master
Are you sure you want to change the base?
Conversation
This implements target_csp in terms of the preferred color description of the video surface.
? sw->fns->target_csp(sw) | ||
: (struct pl_color_space){ .transfer = PL_COLOR_TRC_PQ }; | ||
? sw->fns->target_csp(sw, &target_csp_is_preferred) | ||
: DEFAULT_TARGET_CSP; | ||
if (!pl_color_transfer_is_hdr(target_csp.transfer)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this should also be guarded by !target_csp_is_preferred
. My concern here is that these values are not accurate for SDR displays.
struct vo_wayland_preferred_description_info *wd = data; | ||
if (!wd->is_parametric) | ||
return; | ||
wd->csp.primaries = map_primaries(primaries); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
KDE does not send named primaries so this is ineffective there. Maybe pl_color_space
could be enhanced to also support primaries by value.
@@ -984,12 +984,13 @@ static bool draw_frame(struct vo *vo, struct vo_frame *frame) | |||
struct ra_swapchain *sw = p->ra_ctx->swapchain; | |||
|
|||
bool pass_colorspace = false; | |||
bool target_csp_is_preferred = false; | |||
struct pl_color_space target_csp; | |||
// Assume HDR is supported, if query is not available | |||
// TODO: Implement this for all backends |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This basically resolves this TODO
Fixes: #16305 |
This patch allows vo_gpu_next to automatically switch to the preferred primaries and transfer function of the current output without the user having to specify them on the command line. Without this patch, libplacebo will always pick an HDR color space that will require the compositor to perform tone and gamut mapping on SDR outputs. This will likely be of lower quality than what libplacebo can achieve when it instead picks an SDR color space.
enum pl_color_primaries primaries = opts->target_prim ? opts->target_prim : target_csp.primaries; | ||
if (primaries) | ||
hint.primaries = primaries; | ||
enum pl_color_transfer transfer = opts->target_trc ? opts->target_trc : target_csp.transfer; | ||
if (transfer) | ||
hint.transfer = transfer; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it also make sense to copy the hdr metadata from the target_csp?
Download the artifacts for this pull request: Windows |
This patch allows vo_gpu_next to automatically switch to the preferred
primaries and transfer function of the current output without the user
having to specify them on the command line.
Without this patch, libplacebo will always pick an HDR color space that
will require the compositor to perform tone and gamut mapping on SDR
outputs. This will likely be of lower quality than what libplacebo can
achieve when it instead picks an SDR color space.
I've tested this in Jay and KDE with https://4kmedia.org/lg-new-york-hdr-uhd-4k-demo. Jay currently does not do any tone mapping but even the tone mapping on KDE is not as good as libplacebo. At the start of the video, you can see the clouds getting blown out without this patch. With this patch, the clouds look good.
When moving the window between outputs with different color spaces, you should see logs similar to