wayland_common: set luminances
This fixes --target-trc=linear output and makes our output luminance ranges more explicit.
This commit is contained in:
1 parent
fe9f917d8e
commit
66dcb2ba7b
2 files changed
+47
No files matched your search
@@ -2029,6 +2029,10 @@ static void supported_feature(void *data, struct wp_color_manager_v1 *color_mana
|
||||
MP_VERBOSE(wl, "Compositor supports setting mastering display primaries.\n");
|
||||
wl->supports_display_primaries = true;
|
||||
break;
|
||||
case WP_COLOR_MANAGER_V1_FEATURE_SET_LUMINANCES:
|
||||
MP_VERBOSE(wl, "Compositor supports setting primary color luminances.\n");
|
||||
wl->supports_set_luminances = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3515,6 +3519,48 @@ static void set_color_management(struct vo_wayland_state *wl, struct pl_color_sp
|
||||
wp_image_description_creator_params_v1_set_tf_named(image_creator_params, transfer);
|
||||
|
||||
struct pl_hdr_metadata hdr = color->hdr;
|
||||
|
||||
if (wl->supports_set_luminances) {
|
||||
switch (color->transfer) {
|
||||
case PL_COLOR_TRC_PQ:
|
||||
// Set min luminance to 0 for PQ as per SMPTE ST 2084
|
||||
wp_image_description_creator_params_v1_set_luminances(image_creator_params,
|
||||
0 * WAYLAND_MIN_LUM_FACTOR, 10000, PL_COLOR_SDR_WHITE);
|
||||
MP_VERBOSE(wl, "Setting PQ luminance range: min=0, max=10000, ref=%.2f\n",
|
||||
PL_COLOR_SDR_WHITE);
|
||||
// Mastering luminances will be set below
|
||||
break;
|
||||
case PL_COLOR_TRC_LINEAR:
|
||||
// Our linear output is absolute scaled, meaning the 0 is absolute
|
||||
// black, similar to PQ transfer. Configure it in the same way as PQ.
|
||||
if (hdr.max_luma) {
|
||||
wp_image_description_creator_params_v1_set_luminances(image_creator_params,
|
||||
0 * WAYLAND_MIN_LUM_FACTOR, hdr.max_luma, PL_COLOR_SDR_WHITE);
|
||||
MP_VERBOSE(wl, "Setting linear luminance range: min=0, max=%.5f, ref=%.2f\n",
|
||||
hdr.max_luma, PL_COLOR_SDR_WHITE);
|
||||
if (hdr.min_luma && hdr.max_luma) {
|
||||
wp_image_description_creator_params_v1_set_mastering_luminance(image_creator_params,
|
||||
lrintf(hdr.min_luma * WAYLAND_MIN_LUM_FACTOR), lrintf(hdr.max_luma));
|
||||
MP_VERBOSE(wl, "Setting linear luminace mastering range: min=%.5f, max=%.2f\n",
|
||||
hdr.min_luma, hdr.max_luma);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case PL_COLOR_TRC_HLG:
|
||||
// Leave default for HLG, we wouldn't output it directly, except for pass-through
|
||||
break;
|
||||
default:
|
||||
// Set SDR luminance range for all relative transfers
|
||||
if (hdr.min_luma && hdr.max_luma) {
|
||||
wp_image_description_creator_params_v1_set_luminances(image_creator_params,
|
||||
hdr.min_luma * WAYLAND_MIN_LUM_FACTOR, hdr.max_luma, PL_COLOR_SDR_WHITE);
|
||||
MP_VERBOSE(wl, "Setting relative luminance range: min=%.5f, max=%.2f, ref=%.2f\n",
|
||||
hdr.min_luma, hdr.max_luma, PL_COLOR_SDR_WHITE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool is_hdr = pl_color_transfer_is_hdr(color->transfer);
|
||||
bool use_metadata = hdr_metadata_valid(wl, &hdr);
|
||||
if (!use_metadata)
|
||||
|
||||
@@ -100,6 +100,7 @@ struct vo_wayland_state {
|
||||
struct mp_image_params current_params;
|
||||
bool supports_parametric;
|
||||
bool supports_display_primaries;
|
||||
bool supports_set_luminances;
|
||||
int primaries_map[PL_COLOR_PRIM_COUNT];
|
||||
int transfer_map[PL_COLOR_TRC_COUNT];
|
||||
void *icc_file;
|
||||
|
||||
Reference in new issue
Block a user