From 375810ebdd8c56d8d5c3bc64a3054363c1e6ce60 Mon Sep 17 00:00:00 2001 From: Josh Coalson Date: Tue, 9 Nov 2004 01:22:35 +0000 Subject: [PATCH] add FLAC__bitmath_ilog2_wide() --- src/libFLAC/bitmath.c | 11 ++++++++++- src/libFLAC/include/private/bitmath.h | 3 ++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/libFLAC/bitmath.c b/src/libFLAC/bitmath.c index 5ace20b9..6b4912ea 100644 --- a/src/libFLAC/bitmath.c +++ b/src/libFLAC/bitmath.c @@ -54,7 +54,16 @@ * ilog2(17) = 4 * ilog2(18) = 4 */ -unsigned FLAC__bitmath_ilog2(unsigned v) +unsigned FLAC__bitmath_ilog2(FLAC__uint32 v) +{ + unsigned l = 0; + FLAC__ASSERT(v > 0); + while(v >>= 1) + l++; + return l; +} + +unsigned FLAC__bitmath_ilog2_wide(FLAC__uint64 v) { unsigned l = 0; FLAC__ASSERT(v > 0); diff --git a/src/libFLAC/include/private/bitmath.h b/src/libFLAC/include/private/bitmath.h index ce4eeaa0..6e39ecce 100644 --- a/src/libFLAC/include/private/bitmath.h +++ b/src/libFLAC/include/private/bitmath.h @@ -34,7 +34,8 @@ #include "FLAC/ordinals.h" -unsigned FLAC__bitmath_ilog2(unsigned v); +unsigned FLAC__bitmath_ilog2(FLAC__uint32 v); +unsigned FLAC__bitmath_ilog2_wide(FLAC__uint64 v); unsigned FLAC__bitmath_silog2(int v); unsigned FLAC__bitmath_silog2_wide(FLAC__int64 v);