Skip to content

Commit d3caa67

Browse files
committed
Better divide by zero fix
1 parent 9e952a5 commit d3caa67

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

video/out/wayland_common.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +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;
308+
uint32_t reference_luminance;
309309
};
310310

311311
static bool single_output_spanned(struct vo_wayland_state *wl);
@@ -2199,12 +2199,7 @@ static void info_luminances(void *data, struct wp_image_description_info_v1 *ima
21992199
struct vo_wayland_preferred_description_info *wd = data;
22002200
if (!wd->is_parametric)
22012201
return;
2202-
if (reference_lum != 0) {
2203-
wd->reference_luminance = (float)reference_lum;
2204-
} else {
2205-
wd->reference_luminance = 203.0f;
2206-
}
2207-
2202+
wd->reference_luminance = reference_lum;
22082203
}
22092204

22102205
static void info_target_primaries(void *data, struct wp_image_description_info_v1 *image_description_info,
@@ -2231,7 +2226,11 @@ static void info_target_luminance(void *data, struct wp_image_description_info_v
22312226
if (!wd->is_parametric)
22322227
return;
22332228
wd->csp.hdr.min_luma = (float)min_lum / WAYLAND_MIN_LUM_FACTOR;
2234-
wd->csp.hdr.max_luma = (float)max_lum * (203.0f/wd->reference_luminance);
2229+
if (wd->reference_luminance) {
2230+
wd->csp.hdr.max_luma = (float)max_lum * (203.0f/(float)(wd->reference_luminance));
2231+
} else {
2232+
wd->csp.hdr.max_luma = (float)max_lum;
2233+
}
22352234
}
22362235

22372236
static void info_target_max_cll(void *data, struct wp_image_description_info_v1 *image_description_info,
@@ -2240,7 +2239,11 @@ static void info_target_max_cll(void *data, struct wp_image_description_info_v1
22402239
struct vo_wayland_preferred_description_info *wd = data;
22412240
if (!wd->is_parametric)
22422241
return;
2243-
wd->csp.hdr.max_cll = (float)max_cll * (203.0f/wd->reference_luminance);
2242+
if (wd->reference_luminance) {
2243+
wd->csp.hdr.max_cll = (float)max_cll * (203.0f/(float)(wd->reference_luminance));
2244+
} else {
2245+
wd->csp.hdr.max_cll = (float)max_cll;
2246+
}
22442247
}
22452248

22462249
static void info_target_max_fall(void *data, struct wp_image_description_info_v1 *image_description_info,

0 commit comments

Comments
 (0)