]> rtime.felk.cvut.cz Git - frescor/ffmpeg.git/commitdiff
Add function to compute ceil(log2(x)).
authorjbr <jbr@9553f0bf-9b14-0410-a0b8-cfaf0461ba5b>
Sun, 30 Aug 2009 15:50:03 +0000 (15:50 +0000)
committerjbr <jbr@9553f0bf-9b14-0410-a0b8-cfaf0461ba5b>
Sun, 30 Aug 2009 15:50:03 +0000 (15:50 +0000)
Patch by Thilo Borgmann <thilo.borgmann _at_ googlemail.com>

git-svn-id: file:///var/local/repositories/ffmpeg/trunk@19747 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b

libavutil/common.h

index 9fac1c0aa49b827c3d9a1a3f698ff48d6879af55..0797a79ac05eb871276e89c5c48bebcce4ae3b41 100644 (file)
@@ -225,6 +225,15 @@ static inline av_const float av_clipf(float a, float amin, float amax)
     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))