Skip to content

Commit

Permalink
Clean up definition of COUNT_ZERO_MSBS
Browse files Browse the repository at this point in the history
This is derived from a patch both Fedora and OpenSUSE carry that
refactors a lot of code in bitreader.c.
  • Loading branch information
toofishes committed Mar 23, 2012
1 parent 7a3ad7b commit 945d80d
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/libFLAC/bitreader.c
Expand Up @@ -72,13 +72,12 @@ typedef FLAC__uint32 brword;
#endif
/* counts the # of zero MSBs in a word */
#define COUNT_ZERO_MSBS(word) ( \
(word) <= 0xffff ? \
( (word) <= 0xff? byte_to_unary_table[word] + 24 : byte_to_unary_table[(word) >> 8] + 16 ) : \
( (word) <= 0xffffff? byte_to_unary_table[word >> 16] + 8 : byte_to_unary_table[(word) >> 24] ) \
word > 0xffffff ? byte_to_unary_table[(word) >> 24] : \
!word ? 32 : \
word > 0xffff ? byte_to_unary_table[word >> 16] + 8 : \
word > 0xff ? byte_to_unary_table[(word) >> 8] + 16 : \
byte_to_unary_table[word] + 24 \
)
/* this alternate might be slightly faster on some systems/compilers: */
#define COUNT_ZERO_MSBS2(word) ( (word) <= 0xff ? byte_to_unary_table[word] + 24 : ((word) <= 0xffff ? byte_to_unary_table[(word) >> 8] + 16 : ((word) <= 0xffffff ? byte_to_unary_table[(word) >> 16] + 8 : byte_to_unary_table[(word) >> 24])) )


/*
* This should be at least twice as large as the largest number of words
Expand Down

0 comments on commit 945d80d

Please sign in to comment.