Add comments about OD_ILOG_NZ.
Also remove the internal macros OD_CLZ0 and OD_CLZ. They are not useful
in the simplified version of odintrin.h in libaom. (odintrin.h is
originally from Daala.)
BUG=aomedia:2063
Change-Id: I7b0919d2698a263df91b88cd073d8cbf8ec63425
diff --git a/aom_dsp/entdec.c b/aom_dsp/entdec.c
index b8e9078..d1764c4 100644
--- a/aom_dsp/entdec.c
+++ b/aom_dsp/entdec.c
@@ -112,6 +112,7 @@
int ret) {
int d;
assert(rng <= 65535U);
+ // The number of leading zeros in the 16-bit binary representation of rng.
d = 16 - OD_ILOG_NZ(rng);
dec->cnt -= d;
/*This is equivalent to shifting in 1's instead of 0's.*/
diff --git a/aom_dsp/entenc.c b/aom_dsp/entenc.c
index 6866de9..a61da26 100644
--- a/aom_dsp/entenc.c
+++ b/aom_dsp/entenc.c
@@ -60,6 +60,7 @@
int s;
c = enc->cnt;
assert(rng <= 65535U);
+ // The number of leading zeros in the 16-bit binary representation of rng.
d = 16 - OD_ILOG_NZ(rng);
s = c + d;
/*TODO: Right now we flush every time we have at least one byte available.
diff --git a/av1/common/odintrin.h b/av1/common/odintrin.h
index e87c5a0..c55cb28 100644
--- a/av1/common/odintrin.h
+++ b/av1/common/odintrin.h
@@ -46,9 +46,9 @@
#define OD_MAXI AOMMAX
#define OD_CLAMPI(min, val, max) (OD_MAXI(min, OD_MINI(val, max)))
-#define OD_CLZ0 (1)
-#define OD_CLZ(x) (-get_msb(x))
-#define OD_ILOG_NZ(x) (OD_CLZ0 - OD_CLZ(x))
+/*Integer logarithm (base 2) of a nonzero unsigned 32-bit integer.
+ OD_ILOG_NZ(x) = (int)floor(log2(x)) + 1.*/
+#define OD_ILOG_NZ(x) (1 + get_msb(x))
/*Enable special features for gcc and compatible compilers.*/
#if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__)