From 19b0b1df51c1b0d898880dce1d5f48485e4acc2d Mon Sep 17 00:00:00 2001 From: Bin Jin Date: Sat, 5 Dec 2015 16:37:22 +0000 Subject: vo_opengl: improve boundary check for polar filters If the sampling point is placed diagonally, the radius difference could be as large as sqrt(2.0). And a loosened check with (radius - 1) would potentially include pixels out of the range. Fix the check to handle those corner case properly to avoid unnecessary texture lookup and improve the performance a bit. --- video/out/opengl/video_shaders.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'video') diff --git a/video/out/opengl/video_shaders.c b/video/out/opengl/video_shaders.c index 3af200b87c..34948f4fe8 100644 --- a/video/out/opengl/video_shaders.c +++ b/video/out/opengl/video_shaders.c @@ -139,7 +139,7 @@ void pass_sample_polar(struct gl_shader_cache *sc, struct scaler *scaler) continue; GLSLF("d = length(vec2(%d.0, %d.0) - fcoord)/%f;\n", x, y, radius); // Check for samples that might be skippable - if (dmax >= radius - 1) + if (dmax >= radius - M_SQRT2) GLSLF("if (d < 1.0) {\n"); if (scaler->gl_target == GL_TEXTURE_1D) { GLSL(w = texture1D(lut, d).r;) @@ -153,7 +153,7 @@ void pass_sample_polar(struct gl_shader_cache *sc, struct scaler *scaler) GLSL(lo = min(lo, c);) GLSL(hi = max(hi, c);) } - if (dmax >= radius -1) + if (dmax >= radius - M_SQRT2) GLSLF("}\n"); } } -- cgit v1.2.3