summaryrefslogtreecommitdiff
path: root/libavutil/intmath.h
diff options
context:
space:
mode:
authorGanesh Ajjanagadde <gajjanagadde@gmail.com>2015-12-16 13:28:39 -0500
committerGanesh Ajjanagadde <gajjanagadde@gmail.com>2015-12-19 09:35:34 -0800
commit0dd8a3d71e2c01d42e868d6c6b8974fadfcc529e (patch)
tree28e43f6732318a6cc93f8750258ba606cfab055b /libavutil/intmath.h
parent5484cbe9f765124f9e9c704467c6013731d71ed0 (diff)
downloadffmpeg-0dd8a3d71e2c01d42e868d6c6b8974fadfcc529e.tar.gz
lavu/intmath: add faster clz support
This should be useful for the sofalizer filter. Reviewed-by: Kieran Kunhya <kierank@ob-encoder.com> Reviewed-by: Clément Bœsch <u@pkh.me> Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
Diffstat (limited to 'libavutil/intmath.h')
-rw-r--r--libavutil/intmath.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/libavutil/intmath.h b/libavutil/intmath.h
index 20167230df..82193a6d7c 100644
--- a/libavutil/intmath.h
+++ b/libavutil/intmath.h
@@ -96,6 +96,9 @@ static av_always_inline av_const int ff_log2_16bit_c(unsigned int v)
#ifndef ff_ctzll
#define ff_ctzll(v) __builtin_ctzll(v)
#endif
+#ifndef ff_clz
+#define ff_clz(v) __builtin_clz(v)
+#endif
#endif
#endif
@@ -135,6 +138,21 @@ static av_always_inline av_const int ff_ctzll_c(long long v)
}
#endif
+#ifndef ff_clz
+#define ff_clz ff_clz_c
+static av_always_inline av_const unsigned ff_clz_c(unsigned x)
+{
+ unsigned i = sizeof(x) * 8;
+
+ while (x) {
+ x >>= 1;
+ i--;
+ }
+
+ return i;
+}
+#endif
+
/**
* @}
*/