From ac266da6588f25a449a739f7a6a3d2c69ca80e19 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 8 Jun 2013 02:15:24 +0200 Subject: vo_opengl: handle chroma location Use the video decoder chroma location flags and render chroma locations other than centered. Until now, we've always used the intuitive and obvious centered chroma location, but H.264 uses something else. FFmpeg provides a small overview in libavcodec/avcodec.h: ----------- /** * X X 3 4 X X are luma samples, * 1 2 1-6 are possible chroma positions * X X 5 6 X 0 is undefined/unknown position */ enum AVChromaLocation{ AVCHROMA_LOC_UNSPECIFIED = 0, AVCHROMA_LOC_LEFT = 1, ///< mpeg2/4, h264 default AVCHROMA_LOC_CENTER = 2, ///< mpeg1, jpeg, h263 AVCHROMA_LOC_TOPLEFT = 3, ///< DV AVCHROMA_LOC_TOP = 4, AVCHROMA_LOC_BOTTOMLEFT = 5, AVCHROMA_LOC_BOTTOM = 6, AVCHROMA_LOC_NB , ///< Not part of ABI }; ----------- The visual difference is literally minimal, but since videophiles apparently consider this detail as quality mark of a video renderer, support it anyway. We don't bother with chroma locations other than centered and left, though. Not sure about correctness, but it's probably ok. --- video/csputils.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'video/csputils.h') diff --git a/video/csputils.h b/video/csputils.h index d11e85e38b..af510299cf 100644 --- a/video/csputils.h +++ b/video/csputils.h @@ -87,6 +87,12 @@ struct mp_csp_params { .rgamma = 1, .ggamma = 1, .bgamma = 1, \ .texture_bits = 8, .input_bits = 8} +enum mp_chroma_location { + MP_CHROMA_AUTO, + MP_CHROMA_LEFT, // mpeg2/4, h264 + MP_CHROMA_CENTER, // mpeg1, jpeg +}; + enum mp_csp_equalizer_param { MP_CSP_EQ_BRIGHTNESS, MP_CSP_EQ_CONTRAST, @@ -136,6 +142,10 @@ enum AVColorRange mp_csp_levels_to_avcol_range(enum mp_csp_levels range); enum mp_csp mp_csp_guess_colorspace(int width, int height); +enum mp_chroma_location avchroma_location_to_mp(enum AVChromaLocation loc); + +void mp_get_chroma_location(enum mp_chroma_location loc, int *x, int *y); + void mp_gen_gamma_map(unsigned char *map, int size, float gamma); #define ROW_R 0 #define ROW_G 1 -- cgit v1.2.3