Skip to content

Commit 0d337e6

Browse files
committed
Account for reference luminance adjustment done by the compositor when setting hdr metadata.
I'm very unfamiliar with wayland, in C especially, so this probably needs to be redone in a less janky way.
1 parent b9b3106 commit 0d337e6

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

video/out/wayland_common.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ struct vo_wayland_preferred_description_info {
305305
struct pl_color_space csp;
306306
void *icc_file;
307307
uint32_t icc_size;
308+
float reference_luminance;
308309
};
309310

310311
static bool single_output_spanned(struct vo_wayland_state *wl);
@@ -2195,6 +2196,10 @@ static void info_tf_named(void *data, struct wp_image_description_info_v1 *image
21952196
static void info_luminances(void *data, struct wp_image_description_info_v1 *image_description_info,
21962197
uint32_t min_lum, uint32_t max_lum, uint32_t reference_lum)
21972198
{
2199+
struct vo_wayland_preferred_description_info *wd = data;
2200+
if (!wd->is_parametric)
2201+
return;
2202+
wd->reference_luminance = (float)reference_lum;
21982203
}
21992204

22002205
static void info_target_primaries(void *data, struct wp_image_description_info_v1 *image_description_info,
@@ -2221,7 +2226,7 @@ static void info_target_luminance(void *data, struct wp_image_description_info_v
22212226
if (!wd->is_parametric)
22222227
return;
22232228
wd->csp.hdr.min_luma = (float)min_lum / WAYLAND_MIN_LUM_FACTOR;
2224-
wd->csp.hdr.max_luma = (float)max_lum;
2229+
wd->csp.hdr.max_luma = (float)max_lum * (203.0/wd->reference_luminance);
22252230
}
22262231

22272232
static void info_target_max_cll(void *data, struct wp_image_description_info_v1 *image_description_info,
@@ -2230,7 +2235,7 @@ static void info_target_max_cll(void *data, struct wp_image_description_info_v1
22302235
struct vo_wayland_preferred_description_info *wd = data;
22312236
if (!wd->is_parametric)
22322237
return;
2233-
wd->csp.hdr.max_cll = (float)max_cll;
2238+
wd->csp.hdr.max_cll = (float)max_cll * (203.0/wd->reference_luminance);
22342239
}
22352240

22362241
static void info_target_max_fall(void *data, struct wp_image_description_info_v1 *image_description_info,
@@ -4702,4 +4707,4 @@ void vo_wayland_wakeup(struct vo *vo)
47024707
{
47034708
struct vo_wayland_state *wl = vo->wl;
47044709
(void)write(wl->wakeup_pipe[1], &(char){0}, 1);
4705-
}
4710+
}

0 commit comments

Comments
 (0)