[flac-dev] [PATCH 2] more changes in bitmath.h

Erik de Castro Lopo mle+la at mega-nerd.com
Tue Dec 29 11:30:30 PST 2015


lvqcl wrote:

> 1) FLAC supports only MSVS 2005 and newer, so (_MSC_VER >= 1400)
> is always true and can be removed.
> 
> 
> 2) The argument for FLAC__clz_uint32() is of FLAC__uint32 type, so
> FLAC__clz_soft_uint32() should have the same argument type.
> 
> 
> 3) The patch removes unnecessary parentheses around 'word' variable.
> 
> 
> 4) It also replaces "sizeof(FLAC__uint32) * CHAR_BIT  - 1 - FLAC__clz_uint32(v)"
> with "FLAC__clz_uint32(v) ^ 31U" (and the same for 64-bit version).
> 
> "sizeof(FLAC__uint32) * CHAR_BIT" must be 32, or the code won't work.
> So it's simpler to use "31 - FLAC__clz_uint32(v)" or even better,
> "FLAC__clz_uint32(v) ^ 31".
> 
> Why XORing is better: gcc implements __builtin_clz as bsr^31, so
> FLAC__bitmath_ilog2() now calculates 31 - (bsr^31). GCC is unable
> to simplify it to just bsr. But it can do it for (bsr^31)^31.
> 
> 
> 5) The patch adds FLAC__U64L() for a big constant.


Applied. Thanks.

Erik
-- 
----------------------------------------------------------------------
Erik de Castro Lopo
http://www.mega-nerd.com/


More information about the flac-dev mailing list