aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-11-01 16:21:32 +0100
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-12-08 17:51:46 +0100
commitcfc473ef10ec9a924d1cd6d1c462697b31fb444d (patch)
tree5f50e7ad2f9d7fbde13576cff28219e4221efb7b /libavcodec
parent7a7295a8ce87e8b8d9f3dade5f7e05342ffba881 (diff)
downloadffmpeg-cfc473ef10ec9a924d1cd6d1c462697b31fb444d.tar.gz
avcodec/atrac3plus: Simplify creating VLCs
Use ff_init_vlc_from_lengths() to offload the computation of the codes. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/atrac3plus.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/libavcodec/atrac3plus.c b/libavcodec/atrac3plus.c
index 6b046a887e..f527d3b9fc 100644
--- a/libavcodec/atrac3plus.c
+++ b/libavcodec/atrac3plus.c
@@ -51,9 +51,7 @@ static av_cold void build_canonical_huff(const uint8_t *cb, const uint8_t *xlat,
int *tab_offset, VLC *out_vlc)
{
int i, b;
- uint16_t codes[256];
uint8_t bits[256];
- unsigned code = 0;
int index = 0;
int min_len = *cb++; // get shortest codeword length
int max_len = *cb++; // get longest codeword length
@@ -62,17 +60,15 @@ static av_cold void build_canonical_huff(const uint8_t *cb, const uint8_t *xlat,
for (i = *cb++; i > 0; i--) {
av_assert0(index < 256);
bits[index] = b;
- codes[index] = code++;
index++;
}
- code <<= 1;
}
out_vlc->table = &tables_data[*tab_offset];
out_vlc->table_allocated = 1 << max_len;
- ff_init_vlc_sparse(out_vlc, max_len, index, bits, 1, 1, codes, 2, 2,
- xlat, 1, 1, INIT_VLC_USE_NEW_STATIC);
+ ff_init_vlc_from_lengths(out_vlc, max_len, index, bits, 1,
+ xlat, 1, 1, 0, INIT_VLC_USE_NEW_STATIC, NULL);
*tab_offset += 1 << max_len;
}