]> git.sesse.net Git - movit/blobdiff - util.cpp
Add an FFT convolution effect.
[movit] / util.cpp
index 8162f712d02eed8f5b47b7f481b977b827f56f8f..310e7be7f6627bf58fc5f5556712eafab4a3fa3f 100644 (file)
--- a/util.cpp
+++ b/util.cpp
@@ -220,4 +220,17 @@ unsigned div_round_up(unsigned a, unsigned b)
        return (a + b - 1) / b;
 }
 
+// Algorithm from http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2.
+unsigned next_power_of_two(unsigned v)
+{
+       v--;
+       v |= v >> 1;
+       v |= v >> 2;
+       v |= v >> 4;
+       v |= v >> 8;
+       v |= v >> 16;
+       v++;
+       return v;
+}
+
 }  // namespace movit