Skip to content

Commit cb9e230

Browse files
committed
vo_gpu_next: add an option to control bitmap 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 cb9e230

3 files changed

Lines changed: 27 additions & 1 deletion

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: 20 additions & 1 deletion
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,
@@ -368,14 +372,29 @@ static void update_overlays(struct vo *vo, struct mp_osd_res res,
368372
// Seems like HDR subtitles are targeting SDR white
369373
if (pl_color_transfer_is_hdr(ol->color.transfer)) {
370374
ol->color.hdr = (struct pl_hdr_metadata) {
371-
.max_luma = PL_COLOR_SDR_WHITE,
375+
int subs_hdr_peak = p->next_opts->subs_hdr_peak;
376+
if (subs_hdr_peak == 0) {
377+
.max_luma = PL_COLOR_SDR_WHITE;
378+
} else if (subs_hdr_peak != -1) {
379+
.max_luma = subs_hdr_peak;
380+
}
372381
};
373382
}
374383
}
375384
break;
376385
case SUBBITMAP_LIBASS:
377386
if (src && item->video_color_space && !pl_color_space_is_hdr(&src->params.color))
378387
ol->color = src->params.color;
388+
if (pl_color_transfer_is_hdr(ol->color.transfer)) {
389+
ol->color.hdr = (struct pl_hdr_metadata) {
390+
int subs_hdr_peak = p->next_opts->subs_hdr_peak;
391+
if (subs_hdr_peak == 0) {
392+
.max_luma = PL_COLOR_SDR_WHITE;
393+
} else if (subs_hdr_peak != -1) {
394+
.max_luma = subs_hdr_peak;
395+
}
396+
};
397+
}
379398
ol->mode = PL_OVERLAY_MONOCHROME;
380399
ol->repr.alpha = PL_ALPHA_INDEPENDENT;
381400
break;

0 commit comments

Comments
 (0)