From fe1227883a865b845c0c271bafd281f288404acb Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Tue, 13 Jun 2017 17:09:02 +0200 Subject: csputils: rename HDR curves st2084 and std-b67 are really weird names for PQ and HLG, which is what everybody else (including e.g. the ITU-R) calls them. Follow their example. I decided against naming them bt2020-pq and bt2020-hlg because it's not necessary in this case. The standard name is only used for the other colorspaces etc. because those literally have no other names. --- video/csputils.c | 16 +++++++-------- video/csputils.h | 4 ++-- video/out/opengl/video.c | 6 +----- video/out/opengl/video_shaders.c | 42 ++++++++++++++++++++-------------------- 4 files changed, 32 insertions(+), 36 deletions(-) (limited to 'video') 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" -- cgit v1.2.3