@@ -165,6 +165,7 @@ static void update_lut(struct priv *p, struct user_lut *lut);
165165
166166struct gl_next_opts {
167167 bool delayed_peak ;
168+ int subs_hdr_peak ;
168169 int border_background ;
169170 float corner_rounding ;
170171 bool inter_preserve ;
@@ -186,6 +187,8 @@ const struct m_opt_choice_alternatives lut_types[] = {
186187#define OPT_BASE_STRUCT struct gl_next_opts
187188const struct m_sub_options gl_next_conf = {
188189 .opts = (const struct m_option []) {
190+ {"subs-hdr-peak" , OPT_CHOICE (subs_hdr_peak , {"sdr" , 0 }, {"video" , -1 }),
191+ M_RANGE (100 , 10000 )},
189192 {"allow-delayed-peak-detect" , OPT_BOOL (delayed_peak )},
190193 {"border-background" , OPT_CHOICE (border_background ,
191194 {"none" , BACKGROUND_NONE },
@@ -206,6 +209,7 @@ const struct m_sub_options gl_next_conf = {
206209 .defaults = & (struct gl_next_opts ) {
207210 .border_background = BACKGROUND_COLOR ,
208211 .inter_preserve = true,
212+ .subs_hdr_peak = 0 ,
209213 },
210214 .size = sizeof (struct gl_next_opts ),
211215 .change_flags = UPDATE_VIDEO ,
@@ -293,6 +297,7 @@ static void update_overlays(struct vo *vo, struct mp_osd_res res,
293297 struct priv * p = vo -> priv ;
294298 double pts = src ? src -> pts : 0 ;
295299 struct sub_bitmap_list * subs = osd_render (vo -> osd , res , pts , flags , mp_draw_sub_formats );
300+ int subs_hdr_peak = p -> next_opts -> subs_hdr_peak ;
296301
297302 frame -> overlays = state -> overlays ;
298303 frame -> num_overlays = 0 ;
@@ -365,17 +370,21 @@ static void update_overlays(struct vo *vo, struct mp_osd_res res,
365370 // Infer bitmap colorspace from source
366371 if (src ) {
367372 ol -> color = src -> params .color ;
368- // Seems like HDR subtitles are targeting SDR white
369- if (pl_color_transfer_is_hdr (ol -> color .transfer )) {
373+ if (pl_color_transfer_is_hdr (ol -> color .transfer ) && subs_hdr_peak != -1 ) {
370374 ol -> color .hdr = (struct pl_hdr_metadata ) {
371- .max_luma = PL_COLOR_SDR_WHITE ,
375+ .max_luma = ( subs_hdr_peak == 0 ) ? PL_COLOR_SDR_WHITE : subs_hdr_peak ,
372376 };
373377 }
374378 }
375379 break ;
376380 case SUBBITMAP_LIBASS :
377381 if (src && item -> video_color_space && !pl_color_space_is_hdr (& src -> params .color ))
378382 ol -> color = src -> params .color ;
383+ if (subs_hdr_peak != -1 ) {
384+ ol -> color .hdr = (struct pl_hdr_metadata ) {
385+ .max_luma = (subs_hdr_peak == 0 ) ? PL_COLOR_SDR_WHITE : subs_hdr_peak ,
386+ };
387+ }
379388 ol -> mode = PL_OVERLAY_MONOCHROME ;
380389 ol -> repr .alpha = PL_ALPHA_INDEPENDENT ;
381390 break ;
0 commit comments