@@ -671,6 +671,10 @@ static bool map_frame(pl_gpu gpu, pl_tex *tex, const struct pl_source_frame *src
671671 .user_data = mpi ,
672672 };
673673
674+ const struct gl_video_opts * opts = p -> opts_cache -> opts ;
675+ if (opts -> hdr_reference_white && !pl_color_transfer_is_hdr (frame -> color .transfer ))
676+ frame -> color .hdr .max_luma = opts -> hdr_reference_white ;
677+
674678 if (fp -> hwdec ) {
675679
676680 struct mp_imgfmt_desc desc = mp_imgfmt_get_desc (par .imgfmt );
@@ -871,6 +875,10 @@ static void apply_target_options(struct priv *p, struct pl_frame *target,
871875 target -> color .transfer = opts -> target_trc ;
872876 if (opts -> target_peak && (!target -> color .hdr .max_luma || !hint ))
873877 target -> color .hdr .max_luma = opts -> target_peak ;
878+ if (opts -> hdr_reference_white && (!target -> color .hdr .max_luma || !hint ) &&
879+ !pl_color_transfer_is_hdr (target -> color .transfer )) {
880+ target -> color .hdr .max_luma = opts -> hdr_reference_white ;
881+ }
874882 if ((!target -> color .hdr .min_luma || !hint ))
875883 apply_target_contrast (p , & target -> color , min_luma );
876884 if (opts -> target_gamut ) {
@@ -1172,6 +1180,8 @@ static bool draw_frame(struct vo *vo, struct vo_frame *frame)
11721180 hint .transfer = opts -> target_trc ;
11731181 if (opts -> target_peak )
11741182 hint .hdr .max_luma = opts -> target_peak ;
1183+ if (opts -> hdr_reference_white && !pl_color_transfer_is_hdr (hint .transfer ))
1184+ hint .hdr .max_luma = opts -> hdr_reference_white ;
11751185 // Always set maxCLL, display uses this metadata and we shouldn't let it
11761186 // fallback to default value.
11771187 if (!hint .hdr .max_cll )
0 commit comments