Skip to content

Commit 64bc5a6

Browse files
committed
vo_gpu_next: add an option to control subtitles peak for HDR
Users may want to have darker subtitle brightness for HDR viewing Don't apply it for video screenshots Closed #13680
1 parent 6b178e4 commit 64bc5a6

3 files changed

Lines changed: 19 additions & 3 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
add `--subs-hdr-peak` option

DOCS/man/options.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2779,6 +2779,12 @@ Subtitles
27792779
canvas size. Can be useful to test broken subtitles, which often happen
27802780
when the video was transcoded, while attempting to keep the old subtitles.
27812781

2782+
``--subs-hdr-peak=<sdr|video|100-10000>``
2783+
Controls the subtitle peak of hdr videos, sdr means ``PL_COLOR_SDR_WHITE``,
2784+
video uses video data,you can also specify a value. (``--vo=gpu-next`` only)
2785+
2786+
Default: sdr.
2787+
27822788
``--sub-ass=<yes|no>``
27832789
Render ASS subtitles natively (default: yes).
27842790

video/out/vo_gpu_next.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ static void update_lut(struct priv *p, struct user_lut *lut);
165165

166166
struct 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
187188
const 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

Comments
 (0)