From bfbe1342f7f9eebaf0fce7237f92e94987411528 Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Mon, 30 Mar 2015 14:54:52 +0200 Subject: csputils: add some missing colorspaces With target-prim and target-trc it makes sense to include some common colorspaces that aren't strictly speaking used for video. --- video/csputils.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 53 insertions(+), 8 deletions(-) (limited to 'video/csputils.c') diff --git a/video/csputils.c b/video/csputils.c index 3282e3b8ed..52deb6793f 100644 --- a/video/csputils.c +++ b/video/csputils.c @@ -66,15 +66,23 @@ const struct m_opt_choice_alternatives mp_csp_prim_names[] = { {"bt.709", MP_CSP_PRIM_BT_709}, {"bt.2020", MP_CSP_PRIM_BT_2020}, {"bt.470m", MP_CSP_PRIM_BT_470M}, + {"apple", MP_CSP_PRIM_APPLE}, + {"adobe", MP_CSP_PRIM_ADOBE}, + {"prophoto", MP_CSP_PRIM_PRO_PHOTO}, + {"cie1931", MP_CSP_PRIM_CIE_1931}, {0} }; -const char *const mp_csp_trc_names[MP_CSP_TRC_COUNT] = { - "auto", - "bt.1886", - "srgb", - "linear", - "gamma2.2", +const struct m_opt_choice_alternatives mp_csp_trc_names[] = { + {"auto", MP_CSP_TRC_AUTO}, + {"bt.1886", MP_CSP_TRC_BT_1886}, + {"srgb", MP_CSP_TRC_SRGB}, + {"linear", MP_CSP_TRC_LINEAR}, + {"gamma1.8", MP_CSP_TRC_GAMMA18}, + {"gamma2.2", MP_CSP_TRC_GAMMA22}, + {"gamma2.8", MP_CSP_TRC_GAMMA28}, + {"prophoto", MP_CSP_TRC_PRO_PHOTO}, + {0} }; const char *const mp_csp_equalizer_names[MP_CSP_EQ_COUNT] = { @@ -162,6 +170,7 @@ enum mp_csp_trc avcol_trc_to_mp_csp_trc(int avtrc) case AVCOL_TRC_IEC61966_2_1: return MP_CSP_TRC_SRGB; 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; default: return MP_CSP_TRC_AUTO; } } @@ -209,6 +218,7 @@ int mp_csp_trc_to_avcol_trc(enum mp_csp_trc trc) case MP_CSP_TRC_SRGB: return AVCOL_TRC_IEC61966_2_1; 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; default: return AVCOL_TRC_UNSPECIFIED; } } @@ -317,9 +327,16 @@ struct mp_csp_primaries mp_get_csp_primaries(enum mp_csp_prim spc) https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.601-7-201103-I!!PDF-E.pdf https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.709-5-200204-I!!PDF-E.pdf https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.2020-0-201208-I!!PDF-E.pdf + + Other colorspaces from https://en.wikipedia.org/wiki/RGB_color_space#Specifications */ - static const struct mp_csp_col_xy d65 = {0.3127, 0.3290}; + // CIE standard illuminant series + static const struct mp_csp_col_xy + d50 = {0.34577, 0.35850}, + d65 = {0.31271, 0.32902}, + c = {0.31006, 0.31616}, + e = {1.0/3.0, 1.0/3.0}; switch (spc) { case MP_CSP_PRIM_BT_470M: @@ -327,7 +344,7 @@ struct mp_csp_primaries mp_get_csp_primaries(enum mp_csp_prim spc) .red = {0.670, 0.330}, .green = {0.210, 0.710}, .blue = {0.140, 0.080}, - .white = {0.310, 0.316} // Illuminant C + .white = c }; case MP_CSP_PRIM_BT_601_525: return (struct mp_csp_primaries) { @@ -360,6 +377,34 @@ struct mp_csp_primaries mp_get_csp_primaries(enum mp_csp_prim spc) .blue = {0.131, 0.046}, .white = d65 }; + case MP_CSP_PRIM_APPLE: + return (struct mp_csp_primaries) { + .red = {0.625, 0.340}, + .green = {0.280, 0.595}, + .blue = {0.115, 0.070}, + .white = d65 + }; + case MP_CSP_PRIM_ADOBE: + return (struct mp_csp_primaries) { + .red = {0.640, 0.330}, + .green = {0.210, 0.710}, + .blue = {0.150, 0.060}, + .white = d65 + }; + case MP_CSP_PRIM_PRO_PHOTO: + return (struct mp_csp_primaries) { + .red = {0.7347, 0.2653}, + .green = {0.1596, 0.8404}, + .blue = {0.0366, 0.0001}, + .white = d50 + }; + case MP_CSP_PRIM_CIE_1931: + return (struct mp_csp_primaries) { + .red = {0.7347, 0.2653}, + .green = {0.2738, 0.7174}, + .blue = {0.1666, 0.0089}, + .white = e + }; default: return (struct mp_csp_primaries) {{0}}; } -- cgit v1.2.3