[vlc-devel] vlc_math.h ?
fcvlcdev at free.fr
Fri Dec 11 18:13:52 CET 2015
Le 11/12/2015 11:22, Rémi Denis-Courmont a écrit :
> Le 2015-12-11 00:59, Francois Cartegnie a écrit :
>> I need log2 and log2_ceil which are already duplicated in some modules:
> log2 is a standard function so you can use it, so I fail to see why you
> would need to wrap that.
> log2_ceil is best implemented with clz family of functions, rather than
> floating point maths.
static inline uint8_t vlc_log2( uint32_t val )
return 31 - clz(val);
static inline uint8_t vlc_ceil_log2( uint32_t val )
uint8_t n = vlc_log2( val );
if ((1U << n) != val)
in vlc_common.h might be the simpliest.
More information about the vlc-devel