This matches the behavior of mpv's own drm backend when setting hdr metadata, as well as Mesa's vulkan wsi's behavior when communicating VK_EXT_hdr_metadata values to the compositor
Unified · Split
| @@ -2624,18 +2624,24 @@ static void set_color_management(struct vo_wayland_state *wl) · 2623 unmodified lines | |||
| 2624 | struct pl_hdr_metadata hdr = wl->target_params.color.hdr; | 2624 | struct pl_hdr_metadata hdr = wl->target_params.color.hdr; |
| 2625 | if (wl->supports_display_primaries) { | 2625 | if (wl->supports_display_primaries) { |
| 2626 | wp_image_description_creator_params_v1_set_mastering_display_primaries(image_creator_params, | 2626 | wp_image_description_creator_params_v1_set_mastering_display_primaries(image_creator_params, |
| 2627 | hdr.prim.red.x * WAYLAND_COLOR_FACTOR, hdr.prim.red.y * WAYLAND_COLOR_FACTOR, hdr.prim.green.x * WAYLAND_COLOR_FACTOR, | 2627 | lrintf(hdr.prim.red.x * WAYLAND_COLOR_FACTOR), |
| 2628 | hdr.prim.green.y * WAYLAND_COLOR_FACTOR, hdr.prim.blue.x * WAYLAND_COLOR_FACTOR, hdr.prim.blue.y * WAYLAND_COLOR_FACTOR, | 2628 | lrintf(hdr.prim.red.y * WAYLAND_COLOR_FACTOR), |
| 2629 | hdr.prim.white.x * WAYLAND_COLOR_FACTOR, hdr.prim.white.y * WAYLAND_COLOR_FACTOR); | 2629 | lrintf(hdr.prim.green.x * WAYLAND_COLOR_FACTOR), |
| 2630 | lrintf(hdr.prim.green.y * WAYLAND_COLOR_FACTOR), | ||
| 2631 | lrintf(hdr.prim.blue.x * WAYLAND_COLOR_FACTOR), | ||
| 2632 | lrintf(hdr.prim.blue.y * WAYLAND_COLOR_FACTOR), | ||
| 2633 | lrintf(hdr.prim.white.x * WAYLAND_COLOR_FACTOR), | ||
| 2634 | lrintf(hdr.prim.white.y * WAYLAND_COLOR_FACTOR)); | ||
| 2630 | 2635 | ||
| 2631 | if (hdr.min_luma < hdr.max_luma) | 2636 | if (hdr.min_luma < hdr.max_luma) |
| 2632 | wp_image_description_creator_params_v1_set_mastering_luminance(image_creator_params, hdr.min_luma * WAYLAND_MIN_LUM_FACTOR, hdr.max_luma); | 2637 | wp_image_description_creator_params_v1_set_mastering_luminance(image_creator_params, |
| 2638 | lrintf(hdr.min_luma * WAYLAND_MIN_LUM_FACTOR), lrintf(hdr.max_luma)); | ||
| 2633 | 2639 | ||
| 2634 | if (hdr.max_cll > hdr.min_luma && hdr.max_cll <= hdr.max_luma) | 2640 | if (hdr.max_cll > hdr.min_luma && hdr.max_cll <= hdr.max_luma) |
| 2635 | wp_image_description_creator_params_v1_set_max_cll(image_creator_params, hdr.max_cll); | 2641 | wp_image_description_creator_params_v1_set_max_cll(image_creator_params, lrintf(hdr.max_cll)); |
| 2636 | 2642 | ||
| 2637 | if (hdr.max_fall > hdr.min_luma && hdr.max_fall <= hdr.max_luma && hdr.max_fall <= hdr.max_cll) | 2643 | if (hdr.max_fall > hdr.min_luma && hdr.max_fall <= hdr.max_luma && hdr.max_fall <= hdr.max_cll) |
| 2638 | wp_image_description_creator_params_v1_set_max_fall(image_creator_params, hdr.max_fall); | 2644 | wp_image_description_creator_params_v1_set_max_fall(image_creator_params, lrintf(hdr.max_fall)); |
| 2639 | } | 2645 | } |
| 2640 | struct wp_image_description_v1 *image_description = wp_image_description_creator_params_v1_create(image_creator_params); | 2646 | struct wp_image_description_v1 *image_description = wp_image_description_creator_params_v1_create(image_creator_params); |
| 2641 | wp_image_description_v1_add_listener(image_description, &image_description_listener, wl); | 2647 | wp_image_description_v1_add_listener(image_description, &image_description_listener, wl); |