Skip to content

Commit 08c2177

Browse files
committed
colorspace: match input/output luminance for SDR->SDR case
When doing SDR->SDR rendering, we in fact map display referred transfer, we don't really care about absolute luminance, all that matters is the lumiannce matches between input and output so we map image into full range. Note how in SDR->PQ case we still allow to specify arbitrary luminance, which is than effectively and hdr reference white value, at which luminance level this SDR input will be rendered at.
1 parent 94ca7bd commit 08c2177

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/colorspace.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -952,6 +952,7 @@ void pl_color_space_infer_map(struct pl_color_space *src,
952952
{
953953
bool unknown_src_contrast = !src->hdr.min_luma;
954954
bool unknown_dst_contrast = !dst->hdr.min_luma;
955+
bool unknown_src_luminance = !src->hdr.max_luma;
955956

956957
infer_both_ref(dst, src);
957958

@@ -970,6 +971,14 @@ void pl_color_space_infer_map(struct pl_color_space *src,
970971
if (unknown_dst_contrast && src_is_sdr && dst_is_sdr)
971972
dst->hdr.min_luma = src->hdr.min_luma;
972973

974+
// If both src and dst are SDR, match luminance, this input is display-referred.
975+
if (unknown_src_luminance && src_is_sdr && dst_is_sdr)
976+
src->hdr.max_luma = dst->hdr.max_luma;
977+
978+
// If SDR source has luminance, say from ICC profile, use it for target.
979+
if (!unknown_src_luminance && src_is_sdr && dst_is_sdr)
980+
dst->hdr.max_luma = src->hdr.max_luma;
981+
973982
// If the src is HLG and the output is HDR, tune the HLG peak to the output
974983
if (src->transfer == PL_COLOR_TRC_HLG && pl_color_space_is_hdr(dst))
975984
src->hdr.max_luma = dst->hdr.max_luma;

0 commit comments

Comments
 (0)