summaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2019-05-02 15:35:09 +0200
committerPaul B Mahol <onemda@gmail.com>2019-05-02 15:36:16 +0200
commitbf5d814f1082ea330ba78a591eb426c6c4263c0c (patch)
tree15550db06c8b004c383f1b5cd64b74981e6eb321 /libavcodec
parent7eba264513b3d633d5bdd517faa4910552e58910 (diff)
downloadffmpeg-bf5d814f1082ea330ba78a591eb426c6c4263c0c.tar.gz
avcodec/wavpackenc: use ff_clz()
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/wavpackenc.c20
-rw-r--r--libavcodec/wavpackenc.h11
2 files changed, 3 insertions, 28 deletions
diff --git a/libavcodec/wavpackenc.c b/libavcodec/wavpackenc.c
index 979b92165b..95f4b6530c 100644
--- a/libavcodec/wavpackenc.c
+++ b/libavcodec/wavpackenc.c
@@ -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;
diff --git a/libavcodec/wavpackenc.h b/libavcodec/wavpackenc.h
index 9dd2a01bbe..11914337cf 100644
--- a/libavcodec/wavpackenc.h
+++ b/libavcodec/wavpackenc.h
@@ -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 */