diff options
author | cantabile <cantabile.desu@gmail.com> | 2012-08-21 00:03:59 +0300 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2012-08-21 18:17:41 +0200 |
commit | a1380f394597e06e04195b1812300550f3c2df40 (patch) | |
tree | db2303737c451586f1f427e0f3b562f1c7f0dade /libvo | |
parent | 27262dec1be623618a2e55ab1dbc35371e0ec758 (diff) | |
download | mpv-a1380f394597e06e04195b1812300550f3c2df40.tar.bz2 mpv-a1380f394597e06e04195b1812300550f3c2df40.tar.xz |
video: honor the video's colormatrix and color range flags
If either of them is not defined, the old behavior is used:
- the colormatrix is guessed based on resolution.
- the color range is assumed to be tv aka limited range.
Diffstat (limited to 'libvo')
-rw-r--r-- | libvo/csputils.c | 31 | ||||
-rw-r--r-- | libvo/csputils.h | 5 |
2 files changed, 36 insertions, 0 deletions
diff --git a/libvo/csputils.c b/libvo/csputils.c index 3bd6e48f67..d6aed97864 100644 --- a/libvo/csputils.c +++ b/libvo/csputils.c @@ -47,6 +47,37 @@ char * const mp_csp_equalizer_names[MP_CSP_EQ_COUNT] = { "gamma", }; +enum mp_csp avcol_spc_to_mp_csp(enum AVColorSpace colorspace) +{ + switch (colorspace) { + case AVCOL_SPC_BT709: + return MP_CSP_BT_709; + break; + case AVCOL_SPC_BT470BG: + case AVCOL_SPC_SMPTE170M: + return MP_CSP_BT_601; + break; + case AVCOL_SPC_SMPTE240M: + return MP_CSP_SMPTE_240M; + break; + default: + return MP_CSP_AUTO; + } +} + +enum mp_csp_levels avcol_range_to_mp_csp_levels(enum AVColorRange range) +{ + switch (range) { + case AVCOL_RANGE_MPEG: + return MP_CSP_LEVELS_TV; + break; + case AVCOL_RANGE_JPEG: + return MP_CSP_LEVELS_PC; + break; + default: + return MP_CSP_LEVELS_AUTO; + } +} enum mp_csp mp_csp_guess_colorspace(int width, int height) { diff --git a/libvo/csputils.h b/libvo/csputils.h index 434be4a9a1..da826e84da 100644 --- a/libvo/csputils.h +++ b/libvo/csputils.h @@ -26,6 +26,7 @@ #include <stdint.h> +#include "libavcodec/avcodec.h" /* NOTE: the csp and levels AUTO values are converted to specific ones * above vf/vo level. At least vf_scale relies on all valid settings being @@ -111,6 +112,10 @@ int mp_csp_equalizer_set(struct mp_csp_equalizer *eq, const char *property, int mp_csp_equalizer_get(struct mp_csp_equalizer *eq, const char *property, int *out_value); +enum mp_csp avcol_spc_to_mp_csp(enum AVColorSpace colorspace); + +enum mp_csp_levels avcol_range_to_mp_csp_levels(enum AVColorRange range); + enum mp_csp mp_csp_guess_colorspace(int width, int height); void mp_gen_gamma_map(unsigned char *map, int size, float gamma); |