Skip to content

Commit b5c538a

Browse files
committed
vo_gpu_next: add --hdr-reference-white
1 parent 92aeb63 commit b5c538a

5 files changed

Lines changed: 26 additions & 0 deletions

File tree

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

DOCS/man/options.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7342,6 +7342,18 @@ them.
73427342
encoding into the target colorspace, so after the application of
73437343
``--target-trc``. (Only for ``--vo=gpu-next``)
73447344

7345+
``--hdr-reference-white=<auto|10-1000000>``
7346+
Specifies the assumed peak brightness of the mastering display for SDR
7347+
content, in cd/m² (nits). This is used as HDR diffuse white level for SDR
7348+
content. Essentially this is the SDR brightness in HDR container.
7349+
Default is 203 cd/m². (Only for ``--vo=gpu-next``)
7350+
7351+
.. note::
7352+
7353+
This option overrides the ``--target-peak`` if is set and the target
7354+
transfer function is SDR. This way you can control SDR output separately
7355+
from HDR output.
7356+
73457357
``--tone-mapping=<value>``
73467358
Specifies the algorithm used for tone-mapping images onto the target
73477359
display. This is relevant for both HDR->SDR conversion as well as gamut

video/out/gpu/video.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,8 @@ const struct m_sub_options gl_video_conf = {
443443
{"target-trc", OPT_CHOICE_C(target_trc, pl_csp_trc_names)},
444444
{"target-peak", OPT_CHOICE(target_peak, {"auto", 0}),
445445
M_RANGE(10, 10000)},
446+
{"hdr-reference-white", OPT_CHOICE(hdr_reference_white, {"auto", 0}),
447+
M_RANGE(10, 10000)},
446448
{"target-contrast", OPT_CHOICE(target_contrast, {"auto", 0}, {"inf", -1}),
447449
M_RANGE(10, 1000000)},
448450
{"target-gamut", OPT_CHOICE_C(target_gamut, pl_csp_prim_names)},

video/out/gpu/video.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ struct gl_video_opts {
138138
int target_prim;
139139
int target_trc;
140140
int target_peak;
141+
int hdr_reference_white;
141142
int target_contrast;
142143
int target_gamut;
143144
struct gl_tone_map_opts tone_map;

video/out/vo_gpu_next.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)