diff options
author | wm4 <wm4@nowhere> | 2015-01-21 19:29:18 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-01-21 19:29:18 +0100 |
commit | a0caadd512a6f531fd01638570883e629f9dc6e5 (patch) | |
tree | 9023c03a9229b1ef2e7c5fee0aea778fbf0c2edc /video/out | |
parent | 30ca30c0a16a7ee034d9e05280ba221427d48ba1 (diff) | |
download | mpv-a0caadd512a6f531fd01638570883e629f9dc6e5.tar.bz2 mpv-a0caadd512a6f531fd01638570883e629f9dc6e5.tar.xz |
vo_opengl: handle grayscale input better, add YA16 support
Simply clamp off the U/V components in the colormatrix, instead of doing
something special in the shader.
Also, since YA8/YA16 gave a plane_bits value of 16/32, and a colormatrix
calculation overflowed with 32, add a component_bits field to the image
format descriptor, which for YA8/YA16 returns 8/16 (the wrong value had
no bad consequences otherwise).
Diffstat (limited to 'video/out')
-rw-r--r-- | video/out/gl_video.c | 22 | ||||
-rw-r--r-- | video/out/gl_video_shaders.glsl | 5 |
2 files changed, 10 insertions, 17 deletions
diff --git a/video/out/gl_video.c b/video/out/gl_video.c index e991c85857..50be85d3fe 100644 --- a/video/out/gl_video.c +++ b/video/out/gl_video.c @@ -168,8 +168,7 @@ struct gl_video { float input_gamma, conv_gamma; - // per pixel (full pixel when packed, each component when planar) - int plane_bits; + int component_bits; // color bit depth for all components; 0 if unknown int plane_count; struct video_image image; @@ -291,10 +290,11 @@ struct packed_fmt_entry { }; static const struct packed_fmt_entry mp_packed_formats[] = { - // R G B A + // w R G B A {IMGFMT_Y8, 1, {1, 0, 0, 0}}, {IMGFMT_Y16, 2, {1, 0, 0, 0}}, {IMGFMT_YA8, 1, {1, 0, 0, 2}}, + {IMGFMT_YA16, 2, {1, 0, 0, 2}}, {IMGFMT_ARGB, 1, {2, 3, 4, 1}}, {IMGFMT_0RGB, 1, {2, 3, 4, 0}}, {IMGFMT_BGRA, 1, {3, 2, 1, 4}}, @@ -652,8 +652,9 @@ static void update_uniforms(struct gl_video *p, GLuint program) gl->UseProgram(program); struct mp_csp_params cparams = MP_CSP_PARAMS_DEFAULTS; - cparams.input_bits = p->plane_bits; - cparams.texture_bits = (p->plane_bits + 7) & ~7; + cparams.gray = p->is_yuv && !p->is_packed_yuv && p->plane_count == 1; + cparams.input_bits = p->component_bits; + cparams.texture_bits = (cparams.input_bits + 7) & ~7; mp_csp_set_image_params(&cparams, &p->image_params); mp_csp_copy_equalizer_values(&cparams, &p->video_eq); if (p->image_desc.flags & MP_IMGFLAG_XYZ) { @@ -1132,8 +1133,6 @@ static void compile_shaders(struct gl_video *p) if (p->color_swizzle[0]) shader_def(&header_conv, "USE_COLOR_SWIZZLE", p->color_swizzle); - shader_def_opt(&header_conv, "USE_YGRAY", p->is_yuv && !p->is_packed_yuv - && p->plane_count == 1); shader_def_opt(&header_conv, "USE_INPUT_GAMMA", use_input_gamma); shader_def_opt(&header_conv, "USE_COLORMATRIX", !p->is_rgb); shader_def_opt(&header_conv, "USE_CONV_GAMMA", use_conv_gamma); @@ -2413,15 +2412,14 @@ static bool init_format(int fmt, struct gl_video *init) const struct fmt_entry *plane_format[4] = {0}; init->image_format = fmt; - init->plane_bits = desc.bpp[0]; + init->component_bits = desc.component_bits; init->color_swizzle[0] = '\0'; init->has_alpha = false; // YUV/planar formats if (desc.flags & MP_IMGFLAG_YUV_P) { - int bits = desc.plane_bits; + int bits = desc.component_bits; if ((desc.flags & MP_IMGFLAG_NE) && bits >= 8 && bits <= 16) { - init->plane_bits = bits; init->has_alpha = desc.num_planes > 3; plane_format[0] = find_tex_format(gl, (bits + 7) / 8, 1); for (int p = 1; p < desc.num_planes; p++) @@ -2494,10 +2492,10 @@ static bool init_format(int fmt, struct gl_video *init) supported: // Stuff like IMGFMT_420AP10. Untested, most likely insane. - if (desc.num_planes == 4 && (init->plane_bits % 8) != 0) + if (desc.num_planes == 4 && (init->component_bits % 8) != 0) return false; - if (init->plane_bits > 8 && init->plane_bits < 16) { + if (init->component_bits > 8 && init->component_bits < 16) { if (init->texture_16bit_depth < 16) return false; } diff --git a/video/out/gl_video_shaders.glsl b/video/out/gl_video_shaders.glsl index 2f2986c9fa..51c444aa2e 100644 --- a/video/out/gl_video_shaders.glsl +++ b/video/out/gl_video_shaders.glsl @@ -381,11 +381,6 @@ void main() { #endif vec3 color = acolor.rgb; float alpha = acolor.a; -#ifdef USE_YGRAY - // NOTE: actually slightly wrong for 16 bit input video, and completely - // wrong for 9/10 bit input - color.gb = vec2(128.0/255.0); -#endif #ifdef USE_INPUT_GAMMA // Pre-colormatrix input gamma correction (eg. for MP_IMGFLAG_XYZ) color = pow(color, vec3(input_gamma)); |