]> git.sesse.net Git - nageru/commitdiff
Fix the patch out-of-bounds check in motion search (it was all broken).
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 24 Jul 2018 21:37:16 +0000 (23:37 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 24 Jul 2018 21:37:16 +0000 (23:37 +0200)
motion_search.frag

index d407c0d7ea2a2a29889f5a4b5075d7286c0b0528..a32868b21669ba4b761dbb93852d517975c86511 100644 (file)
@@ -139,11 +139,12 @@ void main()
        // Also reject if the patch goes out-of-bounds (the paper does not mention this,
        // but the code does, and it seems to be critical to avoid really bad behavior
        // at the edges).
+       vec2 patch_center = (base * image_size - 0.5f) + patch_size * 0.5f + u;
        if (length(u - initial_u) > (patch_size * 0.5f) ||
-           u.x < -(patch_size * 0.5f) ||
-           image_size.x - u.x < -(patch_size * 0.5f) ||
-           u.y < -(patch_size * 0.5f) ||
-           image_size.y - u.y < -(patch_size * 0.5f)) {
+           patch_center.x < -(patch_size * 0.5f) ||
+           image_size.x - patch_center.x < -(patch_size * 0.5f) ||
+           patch_center.y < -(patch_size * 0.5f) ||
+           image_size.y - patch_center.y < -(patch_size * 0.5f)) {
                u = initial_u;
                mean_diff = first_mean_diff;
        }