diff --git a/DOCS/interface-changes.rst b/DOCS/interface-changes.rst index 2821e80d9d..0eebe9b2cb 100644 --- a/DOCS/interface-changes.rst +++ b/DOCS/interface-changes.rst @@ -33,6 +33,7 @@ Interface changes - remove option --target-brightness - replace vf_format's `peak` suboption by `sig-peak`, which is relative to the reference white level instead of in cd/m^2 + - renamed the TRCs `st2084` and `std-b67` to `pq` and `hlg` respectively --- mpv 0.25.0 --- - remove opengl-cb dxva2 dummy hwdec interop (see git "vo_opengl: remove dxva2 dummy hwdec backend") diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst index 0be1242063..a82871ebfc 100644 --- a/DOCS/man/options.rst +++ b/DOCS/man/options.rst @@ -4619,10 +4619,10 @@ The following video options are currently all specific to ``--vo=opengl`` and Pure power curve (gamma 2.8), also used for BT.470-BG prophoto ProPhoto RGB (ROMM) - st2084 - SMPTE ST2084 (HDR) curve, PQ OETF - std-b67 - ARIB STD-B67 (Hybrid Log-gamma) curve, also known as BBC/NHK HDR + pq + ITU-R BT.2100 PQ (Perceptual quantizer) curve, aka SMPTE ST2084 + hlg + ITU-R BT.2100 HLG (Hybrid Log-gamma) curve, aka ARIB STD-B67 v-log Panasonic V-Log (VARICAM) curve diff --git a/DOCS/man/vf.rst b/DOCS/man/vf.rst index 90488d2429..a76e327b8a 100644 --- a/DOCS/man/vf.rst +++ b/DOCS/man/vf.rst @@ -363,8 +363,8 @@ Available mpv-only filters are: :gamma2.2: Pure power curve (gamma 2.2) :gamma2.8: Pure power curve (gamma 2.8) :prophoto: ProPhoto RGB (ROMM) curve - :st2084: SMPTE ST2084 (HDR) curve - :std-b67: ARIB STD-B67 (Hybrid Log-gamma) curve + :pq: ITU-R BT.2100 PQ (Perceptual quantizer) curve + :hlg: ITU-R BT.2100 HLG (Hybrid Log-gamma) curve :v-log: Panasonic V-Log transfer curve ```` diff --git a/video/csputils.c b/video/csputils.c index 768314f938..51019a8164 100644 --- a/video/csputils.c +++ b/video/csputils.c @@ -78,8 +78,8 @@ const struct m_opt_choice_alternatives mp_csp_trc_names[] = { {"gamma2.2", MP_CSP_TRC_GAMMA22}, {"gamma2.8", MP_CSP_TRC_GAMMA28}, {"prophoto", MP_CSP_TRC_PRO_PHOTO}, - {"st2084", MP_CSP_TRC_SMPTE_ST2084}, - {"std-b67", MP_CSP_TRC_ARIB_STD_B67}, + {"pq", MP_CSP_TRC_PQ}, + {"hlg", MP_CSP_TRC_HLG}, {"v-log", MP_CSP_TRC_V_LOG}, {0} }; @@ -188,8 +188,8 @@ enum mp_csp_trc avcol_trc_to_mp_csp_trc(int avtrc) case AVCOL_TRC_LINEAR: return MP_CSP_TRC_LINEAR; case AVCOL_TRC_GAMMA22: return MP_CSP_TRC_GAMMA22; case AVCOL_TRC_GAMMA28: return MP_CSP_TRC_GAMMA28; - case AVCOL_TRC_SMPTEST2084: return MP_CSP_TRC_SMPTE_ST2084; - case AVCOL_TRC_ARIB_STD_B67: return MP_CSP_TRC_ARIB_STD_B67; + case AVCOL_TRC_SMPTEST2084: return MP_CSP_TRC_PQ; + case AVCOL_TRC_ARIB_STD_B67: return MP_CSP_TRC_HLG; default: return MP_CSP_TRC_AUTO; } } @@ -238,8 +238,8 @@ int mp_csp_trc_to_avcol_trc(enum mp_csp_trc trc) case MP_CSP_TRC_LINEAR: return AVCOL_TRC_LINEAR; case MP_CSP_TRC_GAMMA22: return AVCOL_TRC_GAMMA22; case MP_CSP_TRC_GAMMA28: return AVCOL_TRC_GAMMA28; - case MP_CSP_TRC_SMPTE_ST2084: return AVCOL_TRC_SMPTEST2084; - case MP_CSP_TRC_ARIB_STD_B67: return AVCOL_TRC_ARIB_STD_B67; + case MP_CSP_TRC_PQ: return AVCOL_TRC_SMPTEST2084; + case MP_CSP_TRC_HLG: return AVCOL_TRC_ARIB_STD_B67; default: return AVCOL_TRC_UNSPECIFIED; } } @@ -453,8 +453,8 @@ struct mp_csp_primaries mp_get_csp_primaries(enum mp_csp_prim spc) float mp_trc_nom_peak(enum mp_csp_trc trc) { switch (trc) { - case MP_CSP_TRC_SMPTE_ST2084: return 10000.0 / MP_REF_WHITE; - case MP_CSP_TRC_ARIB_STD_B67: return 12.0; + case MP_CSP_TRC_PQ: return 10000.0 / MP_REF_WHITE; + case MP_CSP_TRC_HLG: return 12.0; case MP_CSP_TRC_V_LOG: return 46.0855; } diff --git a/video/csputils.h b/video/csputils.h index ec7369fa67..8e120922d7 100644 --- a/video/csputils.h +++ b/video/csputils.h @@ -79,8 +79,8 @@ enum mp_csp_trc { MP_CSP_TRC_GAMMA22, MP_CSP_TRC_GAMMA28, MP_CSP_TRC_PRO_PHOTO, - MP_CSP_TRC_SMPTE_ST2084, - MP_CSP_TRC_ARIB_STD_B67, + MP_CSP_TRC_PQ, + MP_CSP_TRC_HLG, MP_CSP_TRC_V_LOG, MP_CSP_TRC_COUNT }; diff --git a/video/out/opengl/video.c b/video/out/opengl/video.c index 2cf5a41c0b..cdb4383011 100644 --- a/video/out/opengl/video.c +++ b/video/out/opengl/video.c @@ -2069,12 +2069,8 @@ static void pass_colormanage(struct gl_video *p, struct mp_colorspace src, bool // limitation reasons, so we use a gamma 2.2 input curve here instead. // We could pick any value we want here, the difference is just coding // efficiency. - if (trc_orig == MP_CSP_TRC_SMPTE_ST2084 || - trc_orig == MP_CSP_TRC_ARIB_STD_B67 || - trc_orig == MP_CSP_TRC_V_LOG) - { + if (mp_trc_is_hdr(trc_orig)) trc_orig = MP_CSP_TRC_GAMMA22; - } if (gl_video_get_lut3d(p, prim_orig, trc_orig)) { dst.primaries = prim_orig; diff --git a/video/out/opengl/video_shaders.c b/video/out/opengl/video_shaders.c index 4bacb12532..14120d434b 100644 --- a/video/out/opengl/video_shaders.c +++ b/video/out/opengl/video_shaders.c @@ -219,16 +219,16 @@ void pass_sample_oversample(struct gl_shader_cache *sc, struct scaler *scaler, } // Common constants for SMPTE ST.2084 (HDR) -static const float HDR_M1 = 2610./4096 * 1./4, - HDR_M2 = 2523./4096 * 128, - HDR_C1 = 3424./4096, - HDR_C2 = 2413./4096 * 32, - HDR_C3 = 2392./4096 * 32; +static const float PQ_M1 = 2610./4096 * 1./4, + PQ_M2 = 2523./4096 * 128, + PQ_C1 = 3424./4096, + PQ_C2 = 2413./4096 * 32, + PQ_C3 = 2392./4096 * 32; -// Common constants for ARIB STD-B67 (Hybrid Log-gamma) -static const float B67_A = 0.17883277, - B67_B = 0.28466892, - B67_C = 0.55991073; +// Common constants for ARIB STD-B67 (HLG) +static const float HLG_A = 0.17883277, + HLG_B = 0.28466892, + HLG_C = 0.55991073; // Common constants for Panasonic V-Log static const float VLOG_B = 0.00873, @@ -275,21 +275,21 @@ void pass_linearize(struct gl_shader_cache *sc, enum mp_csp_trc trc) pow(color.rgb, vec3(1.8)), lessThan(vec3(0.03125), color.rgb));) break; - case MP_CSP_TRC_SMPTE_ST2084: - GLSLF("color.rgb = pow(color.rgb, vec3(1.0/%f));\n", HDR_M2); + case MP_CSP_TRC_PQ: + GLSLF("color.rgb = pow(color.rgb, vec3(1.0/%f));\n", PQ_M2); GLSLF("color.rgb = max(color.rgb - vec3(%f), vec3(0.0)) \n" " / (vec3(%f) - vec3(%f) * color.rgb);\n", - HDR_C1, HDR_C2, HDR_C3); - GLSLF("color.rgb = pow(color.rgb, vec3(1.0/%f));\n", HDR_M1); + PQ_C1, PQ_C2, PQ_C3); + GLSLF("color.rgb = pow(color.rgb, vec3(1.0/%f));\n", PQ_M1); // PQ's output range is 0-10000, but we need it to be relative to to // MP_REF_WHITE instead, so rescale GLSLF("color.rgb *= vec3(%f);\n", 10000 / MP_REF_WHITE); break; - case MP_CSP_TRC_ARIB_STD_B67: + case MP_CSP_TRC_HLG: GLSLF("color.rgb = mix(vec3(4.0) * color.rgb * color.rgb,\n" " exp((color.rgb - vec3(%f)) / vec3(%f)) + vec3(%f),\n" " lessThan(vec3(0.5), color.rgb));\n", - B67_C, B67_A, B67_B); + HLG_C, HLG_A, HLG_B); break; case MP_CSP_TRC_V_LOG: GLSLF("color.rgb = mix((color.rgb - vec3(0.125)) / vec3(5.6), \n" @@ -342,19 +342,19 @@ void pass_delinearize(struct gl_shader_cache *sc, enum mp_csp_trc trc) pow(color.rgb, vec3(1.0/1.8)), lessThanEqual(vec3(0.001953), color.rgb));) break; - case MP_CSP_TRC_SMPTE_ST2084: + case MP_CSP_TRC_PQ: GLSLF("color.rgb /= vec3(%f);\n", 10000 / MP_REF_WHITE); - GLSLF("color.rgb = pow(color.rgb, vec3(%f));\n", HDR_M1); + GLSLF("color.rgb = pow(color.rgb, vec3(%f));\n", PQ_M1); GLSLF("color.rgb = (vec3(%f) + vec3(%f) * color.rgb) \n" " / (vec3(1.0) + vec3(%f) * color.rgb);\n", - HDR_C1, HDR_C2, HDR_C3); - GLSLF("color.rgb = pow(color.rgb, vec3(%f));\n", HDR_M2); + PQ_C1, PQ_C2, PQ_C3); + GLSLF("color.rgb = pow(color.rgb, vec3(%f));\n", PQ_M2); break; - case MP_CSP_TRC_ARIB_STD_B67: + case MP_CSP_TRC_HLG: GLSLF("color.rgb = mix(vec3(0.5) * sqrt(color.rgb),\n" " vec3(%f) * log(color.rgb - vec3(%f)) + vec3(%f),\n" " lessThan(vec3(1.0), color.rgb));\n", - B67_A, B67_B, B67_C); + HLG_A, HLG_B, HLG_C); break; case MP_CSP_TRC_V_LOG: GLSLF("color.rgb = mix(vec3(5.6) * color.rgb + vec3(0.125), \n"