summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorHaihua Hu <jared.hu@nxp.com>2016-06-14 13:48:09 +0800
committerMatthew Waters <matthew@centricular.com>2016-06-15 19:18:15 +1000
commit5e8a650130d932a10b9dd8ae4f2cf7b4b714e472 (patch)
tree05666acca53444ac510873774d088c3da8cf53f8 /ext
parent861ce43cd864b97718fd1477d1d1f2aff7ce154d (diff)
downloadgstreamer-plugins-bad-5e8a650130d932a10b9dd8ae4f2cf7b4b714e472.tar.gz
gleffects: fix little rectangle that appears at the center of squeeze and tunnel effects
These two shader will calculate the vector length and use it as denominator. But length could be zero which will cause undefine behaviour. Add protection for this condition https://bugzilla.gnome.org/show_bug.cgi?id=767635
Diffstat (limited to 'ext')
-rw-r--r--ext/gl/effects/gstgleffectssources.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/ext/gl/effects/gstgleffectssources.c b/ext/gl/effects/gstgleffectssources.c
index 8059abafd..b83e1d7cc 100644
--- a/ext/gl/effects/gstgleffectssources.c
+++ b/ext/gl/effects/gstgleffectssources.c
@@ -100,7 +100,8 @@ const gchar *squeeze_fragment_source_gles2 =
"void main () {"
" vec2 texturecoord = v_texcoord.xy;"
" vec2 normcoord = texturecoord - 0.5;"
- " float r = length (normcoord);"
+ /* Add a very small value to length otherwise it could be 0 */
+ " float r = length (normcoord)+0.01;"
" r = pow(r, 0.40)*1.3;"
" normcoord = normcoord / r;"
" texturecoord = (normcoord + 0.5);"
@@ -136,7 +137,8 @@ const gchar *tunnel_fragment_source_gles2 =
* rect textures */
" normcoord = (texturecoord - 0.5);"
" float r = length(normcoord);"
- " normcoord *= clamp (r, 0.0, 0.275) / r;"
+ " if (r > 0.0)"
+ " normcoord *= clamp (r, 0.0, 0.275) / r;"
" texturecoord = normcoord + 0.5;"
" gl_FragColor = texture2D (tex, texturecoord);"
"}";