From a1380f394597e06e04195b1812300550f3c2df40 Mon Sep 17 00:00:00 2001 From: cantabile Date: Tue, 21 Aug 2012 00:03:59 +0300 Subject: 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. --- libvo/csputils.c | 31 +++++++++++++++++++++++++++++++ libvo/csputils.h | 5 +++++ 2 files changed, 36 insertions(+) (limited to 'libvo') 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 +#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); -- cgit v1.2.3