summaryrefslogtreecommitdiffstats
path: root/video/out/gl_video_shaders.glsl
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-06-08 02:15:24 +0200
committerwm4 <wm4@nowhere>2013-06-28 21:20:41 +0200
commitac266da6588f25a449a739f7a6a3d2c69ca80e19 (patch)
tree6fc863452bec6fd07b05d057d093946772ba96c7 /video/out/gl_video_shaders.glsl
parent3382a6f6e48c7e093c2b7e0e4a0e28b60a084358 (diff)
downloadmpv-ac266da6588f25a449a739f7a6a3d2c69ca80e19.tar.bz2
mpv-ac266da6588f25a449a739f7a6a3d2c69ca80e19.tar.xz
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.
Diffstat (limited to 'video/out/gl_video_shaders.glsl')
-rw-r--r--video/out/gl_video_shaders.glsl8
1 files changed, 5 insertions, 3 deletions
diff --git a/video/out/gl_video_shaders.glsl b/video/out/gl_video_shaders.glsl
index 47be240571..6337822c02 100644
--- a/video/out/gl_video_shaders.glsl
+++ b/video/out/gl_video_shaders.glsl
@@ -114,6 +114,7 @@ void main() {
#!section frag_video
uniform sampler2D textures[4];
uniform vec2 textures_size[4];
+uniform vec2 chroma_center_offset;
uniform sampler1D lut_c_1d;
uniform sampler1D lut_l_1d;
uniform sampler2D lut_c_2d;
@@ -321,17 +322,18 @@ vec4 sample_sharpen5(sampler2D tex, vec2 texsize, vec2 texcoord) {
}
void main() {
+ vec2 chr_texcoord = texcoord + chroma_center_offset;
#ifndef USE_CONV
#define USE_CONV 0
#endif
#if USE_CONV == CONV_PLANAR
vec3 color = vec3(SAMPLE_L(textures[0], textures_size[0], texcoord).r,
- SAMPLE_C(textures[1], textures_size[1], texcoord).r,
- SAMPLE_C(textures[2], textures_size[2], texcoord).r);
+ SAMPLE_C(textures[1], textures_size[1], chr_texcoord).r,
+ SAMPLE_C(textures[2], textures_size[2], chr_texcoord).r);
float alpha = 1.0;
#elif USE_CONV == CONV_NV12
vec3 color = vec3(SAMPLE_L(textures[0], textures_size[0], texcoord).r,
- SAMPLE_C(textures[1], textures_size[1], texcoord).rg);
+ SAMPLE_C(textures[1], textures_size[1], chr_texcoord).rg);
float alpha = 1.0;
#else
vec4 acolor = SAMPLE_L(textures[0], textures_size[0], texcoord);