avcodec/wavpackenc: use ff_clz()

This commit is contained in:
Paul B Mahol 2019-05-02 15:35:09 +02:00
parent 7eba264513
commit bf5d814f10
2 changed files with 3 additions and 28 deletions

View File

@ -637,21 +637,15 @@ static void reverse_mono_decorr(struct Decorr *dpp)
}
}
#define count_bits(av) ((av) ? 32 - ff_clz(av) : 0)
static uint32_t log2sample(uint32_t v, int limit, uint32_t *result)
{
uint32_t dbits;
uint32_t dbits = count_bits(v);
if ((v += v >> 9) < (1 << 8)) {
dbits = nbits_table[v];
*result += (dbits << 8) + wp_log2_table[(v << (9 - dbits)) & 0xff];
} else {
if (v < (1 << 16))
dbits = nbits_table[v >> 8] + 8;
else if (v < (1 << 24))
dbits = nbits_table[v >> 16] + 16;
else
dbits = nbits_table[v >> 24] + 24;
*result += dbits = (dbits << 8) + wp_log2_table[(v >> (dbits - 9)) & 0xff];
if (limit && dbits >= limit)
@ -1969,14 +1963,6 @@ static int wv_stereo(WavPackEncodeContext *s,
return 0;
}
#define count_bits(av) ( \
(av) < (1 << 8) ? nbits_table[av] : \
( \
(av) < (1 << 16) ? nbits_table[(av) >> 8] + 8 : \
((av) < (1 << 24) ? nbits_table[(av) >> 16] + 16 : nbits_table[(av) >> 24] + 24) \
) \
)
static void encode_flush(WavPackEncodeContext *s)
{
WavPackWords *w = &s->w;

View File

@ -650,15 +650,4 @@ static const uint16_t decorr_filter_sizes[] = {
static const uint8_t decorr_filter_nterms[] = { 2, 5, 10, 16 };
static const int8_t nbits_table[] = {
0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8
};
#endif /* AVCODEC_WAVPACKENC_H */