changeset 773:8848af31706f libavutil

Add function to compute ceil(log2(x)). Patch by Thilo Borgmann <thilo.borgmann _at_ googlemail.com>
author jbr
date Sun, 30 Aug 2009 15:50:03 +0000
parents 988be4b2fd0c
children 1896cda0ecfc
files common.h
diffstat 1 files changed, 9 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/common.h	Sat Aug 29 22:38:48 2009 +0000
+++ b/common.h	Sun Aug 30 15:50:03 2009 +0000
@@ -225,6 +225,15 @@
     else               return a;
 }
 
+/** Computes ceil(log2(x)).
+ * @param x value used to compute ceil(log2(x))
+ * @return computed ceiling of log2(x)
+ */
+static inline av_const int av_ceil_log2(int x)
+{
+    return av_log2((x - 1) << 1);
+}
+
 #define MKTAG(a,b,c,d) (a | (b << 8) | (c << 16) | (d << 24))
 #define MKBETAG(a,b,c,d) (d | (c << 8) | (b << 16) | (a << 24))