diff options
author | wm4 <wm4@nowhere> | 2013-09-19 16:55:56 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-09-19 17:03:03 +0200 |
commit | 93feffad15fe68dc97278df9e6726135e31b6474 (patch) | |
tree | 7a487a30eedd5064bc09e7c3801d8db738867a84 /video | |
parent | 69e272dad707aae1ae99dabdf45bb82d3bf7a905 (diff) | |
download | mpv-93feffad15fe68dc97278df9e6726135e31b6474.tar.bz2 mpv-93feffad15fe68dc97278df9e6726135e31b6474.tar.xz |
vo_opengl: blend alpha components by default
Improves display of images and video with alpha channel, especially if
the transparent regions contain (supposed to be invisible) garbage
color values.
Diffstat (limited to 'video')
-rw-r--r-- | video/out/gl_video.c | 14 | ||||
-rw-r--r-- | video/out/gl_video.h | 2 | ||||
-rw-r--r-- | video/out/gl_video_shaders.glsl | 3 | ||||
-rw-r--r-- | video/out/vo_opengl.c | 2 |
4 files changed, 15 insertions, 6 deletions
diff --git a/video/out/gl_video.c b/video/out/gl_video.c index ff5bbc7d47..21efc6dd56 100644 --- a/video/out/gl_video.c +++ b/video/out/gl_video.c @@ -271,6 +271,7 @@ static const struct gl_video_opts gl_video_opts_def = { .scale_sep = 1, .scalers = { "bilinear", "bilinear" }, .scaler_params = {NAN, NAN}, + .alpha_mode = 2, }; @@ -319,7 +320,10 @@ const struct m_sub_options gl_video_conf = { ({"auto", MP_CHROMA_AUTO}, {"center", MP_CHROMA_CENTER}, {"left", MP_CHROMA_LEFT})), - OPT_FLAG("alpha", enable_alpha, 0), + OPT_CHOICE("alpha", alpha_mode, M_OPT_OPTIONAL_PARAM, + ({"no", 0}, + {"yes", 1}, {"", 1}, + {"blend", 2})), {0} }, .size = sizeof(struct gl_video_opts), @@ -779,8 +783,8 @@ static void compile_shaders(struct gl_video *p) shader_prelude, PRELUDE_END); // Need to pass alpha through the whole chain. (Not needed for OSD shaders.) - bool use_alpha = p->opts.enable_alpha && p->has_alpha; - shader_def_opt(&header, "USE_ALPHA", use_alpha); + if (p->opts.alpha_mode == 1) + shader_def_opt(&header, "USE_ALPHA", p->has_alpha); char *header_osd = talloc_strdup(tmp, header); shader_def_opt(&header_osd, "USE_OSD_LINEAR_CONV", p->opts.srgb && @@ -831,8 +835,10 @@ static void compile_shaders(struct gl_video *p) shader_def_opt(&header_conv, "USE_INPUT_GAMMA", convert_input_gamma); shader_def_opt(&header_conv, "USE_COLORMATRIX", !p->is_rgb); shader_def_opt(&header_conv, "USE_CONV_GAMMA", convert_input_to_linear); - if (use_alpha && p->plane_count > 3) + if (p->opts.alpha_mode > 0 && p->has_alpha && p->plane_count > 3) shader_def(&header_conv, "USE_ALPHA_PLANE", "3"); + if (p->opts.alpha_mode == 2 && p->has_alpha) + shader_def(&header_conv, "USE_ALPHA_BLEND", "1"); shader_def_opt(&header_final, "USE_LINEAR_CONV_INV", p->use_lut_3d); shader_def_opt(&header_final, "USE_GAMMA_POW", p->opts.gamma); diff --git a/video/out/gl_video.h b/video/out/gl_video.h index bc21310498..3b21edc223 100644 --- a/video/out/gl_video.h +++ b/video/out/gl_video.h @@ -44,7 +44,7 @@ struct gl_video_opts { int temporal_dither; int fbo_format; int stereo_mode; - int enable_alpha; + int alpha_mode; int chroma_location; }; diff --git a/video/out/gl_video_shaders.glsl b/video/out/gl_video_shaders.glsl index 8ca6739bf4..b0df20b544 100644 --- a/video/out/gl_video_shaders.glsl +++ b/video/out/gl_video_shaders.glsl @@ -387,6 +387,9 @@ void main() { color = floor(color * dither_quantization + dither_value + dither_center) / dither_quantization; #endif +#ifdef USE_ALPHA_BLEND + color = color * alpha; +#endif #ifdef USE_ALPHA out_color = vec4(color, alpha); #else diff --git a/video/out/vo_opengl.c b/video/out/vo_opengl.c index 7f4c05ac58..03d1689667 100644 --- a/video/out/vo_opengl.c +++ b/video/out/vo_opengl.c @@ -144,7 +144,7 @@ static bool config_window(struct gl_priv *p, uint32_t d_width, if (p->renderer_opts->stereo_mode == GL_3D_QUADBUFFER) flags |= VOFLAG_STEREO; - if (p->renderer_opts->enable_alpha) + if (p->renderer_opts->alpha_mode == 1) flags |= VOFLAG_ALPHA; if (p->use_gl_debug) |