0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
+const deInt8 g_ctzLUT[256] =
+{
+ 8, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
+ 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
+ 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
+ 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
+ 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
+ 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
+ 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
+ 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
+ 7, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
+ 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
+ 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
+ 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
+ 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
+ 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
+ 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
+ 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0
+};
+
/*--------------------------------------------------------------------*//*!
* \brief Compute the reciprocal of an integer.
* \param a Input value.
return (void*)((val + align - 1) & ~(align - 1));
}
+extern const deInt8 g_clzLUT[256];
+
/*--------------------------------------------------------------------*//*!
* \brief Compute number of leading zeros in an integer.
* \param a Input value.
* \return The number of leading zero bits in the input.
*//*--------------------------------------------------------------------*/
-extern const deInt8 g_clzLUT[256];
-
DE_INLINE int deClz32 (deUint32 a)
{
#if (DE_COMPILER == DE_COMPILER_MSC)
#endif
}
+extern const deInt8 g_ctzLUT[256];
+
+/*--------------------------------------------------------------------*//*!
+ * \brief Compute number of trailing zeros in an integer.
+ * \param a Input value.
+ * \return The number of trailing zero bits in the input.
+ *//*--------------------------------------------------------------------*/
+DE_INLINE int deCtz32 (deUint32 a)
+{
+#if (DE_COMPILER == DE_COMPILER_MSC)
+ unsigned long i;
+ if (_BitScanForward(&i, (unsigned long)a) == 0)
+ return 32;
+ else
+ return i;
+#elif (DE_COMPILER == DE_COMPILER_GCC) || (DE_COMPILER == DE_COMPILER_CLANG)
+ if (a == 0)
+ return 32;
+ else
+ return __builtin_ctz((unsigned int)a);
+#else
+ if ((a & 0x00FFFFFFu) == 0)
+ return (int)g_ctzLUT[a >> 24] + 24;
+ if ((a & 0x0000FFFFu) == 0)
+ return (int)g_ctzLUT[(a >> 16) & 0xffu] + 16;
+ if ((a & 0x000000FFu) == 0)
+ return (int)g_ctzLUT[(a >> 8) & 0xffu] + 8;
+ return (int)g_ctzLUT[a & 0xffu];
+#endif
+}
+
/*--------------------------------------------------------------------*//*!
* \brief Compute integer 'floor' of 'log2' for a positive integer.
* \param a Input value.