summaryrefslogtreecommitdiffstats
path: root/video/csputils.c
diff options
context:
space:
mode:
authorNiklas Haas <git@nand.wakku.to>2015-02-28 00:59:09 +0100
committerNiklas Haas <git@nand.wakku.to>2015-02-28 01:07:35 +0100
commitfbacd5de31de964f7cd562304ab1c9b4a0d76015 (patch)
treecce495e7699f98ae64103b87459008b7d8503e0d /video/csputils.c
parent076b3d13855870df9eb599b7a26e708f9b8d1ace (diff)
downloadmpv-fbacd5de31de964f7cd562304ab1c9b4a0d76015.tar.bz2
mpv-fbacd5de31de964f7cd562304ab1c9b4a0d76015.tar.xz
csputils: add missing gamma support
We have MP_CSP_TRC defined, but it wasn't being used by practically anything. This commit adds missing conversion logic, adds it to mp_image, and moves the auto-guessing logic to where it should be, in mp_image_params_guess_csp (and out of vo_opengl). Note that this also fixes a minor bug: csp_prim was not being copied between mp_image structs if the format was not YUV in both cases, but this is wrong - the primaries are always relevant.
Diffstat (limited to 'video/csputils.c')
-rw-r--r--video/csputils.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/video/csputils.c b/video/csputils.c
index 90eec39d36..cbd9734819 100644
--- a/video/csputils.c
+++ b/video/csputils.c
@@ -65,6 +65,13 @@ const char *const mp_csp_prim_names[MP_CSP_PRIM_COUNT] = {
"BT.470 M",
};
+const char *const mp_csp_trc_names[MP_CSP_TRC_COUNT] = {
+ "Autoselect",
+ "BT.1886 (SD, HD, UHD)",
+ "sRGB (IEC 61966-2-1)",
+ "Linear light",
+};
+
const char *const mp_csp_equalizer_names[MP_CSP_EQ_COUNT] = {
"brightness",
"contrast",
@@ -142,6 +149,21 @@ enum mp_csp_prim avcol_pri_to_mp_csp_prim(int avpri)
}
}
+enum mp_csp_trc avcol_trc_to_mp_csp_trc(int avtrc)
+{
+ switch (avtrc) {
+ case AVCOL_TRC_BT709:
+ case AVCOL_TRC_SMPTE170M:
+ case AVCOL_TRC_SMPTE240M:
+ case AVCOL_TRC_BT1361_ECG:
+ case AVCOL_TRC_BT2020_10:
+ case AVCOL_TRC_BT2020_12: return MP_CSP_TRC_BT_1886;
+ case AVCOL_TRC_IEC61966_2_1: return MP_CSP_TRC_SRGB;
+ case AVCOL_TRC_LINEAR: return MP_CSP_TRC_LINEAR;
+ default: return MP_CSP_TRC_AUTO;
+ }
+}
+
int mp_csp_to_avcol_spc(enum mp_csp colorspace)
{
switch (colorspace) {
@@ -181,6 +203,17 @@ int mp_csp_prim_to_avcol_pri(enum mp_csp_prim prim)
}
}
+int mp_csp_trc_to_avcol_trc(enum mp_csp_trc trc)
+{
+ switch (trc) {
+ // We just call it BT.1886 since we're decoding, but it's still BT.709
+ case MP_CSP_TRC_BT_1886: return AVCOL_TRC_BT709;
+ case MP_CSP_TRC_SRGB: return AVCOL_TRC_IEC61966_2_1;
+ case MP_CSP_TRC_LINEAR: return AVCOL_TRC_LINEAR;
+ default: return AVCOL_TRC_UNSPECIFIED;
+ }
+}
+
enum mp_csp mp_csp_guess_colorspace(int width, int height)
{
return width >= 1280 || height > 576 ? MP_CSP_BT_709 : MP_CSP_BT_601;