summaryrefslogtreecommitdiff
path: root/libavcodec/cllc.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-10-25 00:56:42 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-12-08 17:51:44 +0100
commit09062eece2e8f188330adab9ddd873341dcf9862 (patch)
tree91edf4d57fd48050e8cf397d2aec723b319d7d63 /libavcodec/cllc.c
parent4df5144102fb45f74ea46cc9c2a5750a7882dfdd (diff)
downloadffmpeg-09062eece2e8f188330adab9ddd873341dcf9862.tar.gz
avcodec/cllc: Improve creating VLCs
One can offload the computation of the codes to ff_init_vlc_from_lengths(); this also improves performance: The number of decicycles for one call to read_code_table() decreased from 198343 to 148338 with the sample sample-cllc-rgb.avi from the FATE suite; it has been looped 100 times and the test repeated ten times to test it sufficiently often. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavcodec/cllc.c')
-rw-r--r--libavcodec/cllc.c14
1 files changed, 3 insertions, 11 deletions
diff --git a/libavcodec/cllc.c b/libavcodec/cllc.c
index 8b1bc75faa..837e04f173 100644
--- a/libavcodec/cllc.c
+++ b/libavcodec/cllc.c
@@ -46,11 +46,9 @@ static int read_code_table(CLLCContext *ctx, GetBitContext *gb, VLC *vlc)
{
uint8_t symbols[256];
uint8_t bits[256];
- uint16_t codes[256];
- int num_lens, num_codes, num_codes_sum, prefix;
+ int num_lens, num_codes, num_codes_sum;
int i, j, count;
- prefix = 0;
count = 0;
num_codes_sum = 0;
@@ -74,19 +72,13 @@ static int read_code_table(CLLCContext *ctx, GetBitContext *gb, VLC *vlc)
for (j = 0; j < num_codes; j++) {
symbols[count] = get_bits(gb, 8);
bits[count] = i + 1;
- codes[count] = prefix++;
count++;
}
- if (prefix > (65535 - 256)/2) {
- return AVERROR_INVALIDDATA;
- }
-
- prefix <<= 1;
}
- return ff_init_vlc_sparse(vlc, VLC_BITS, count, bits, 1, 1,
- codes, 2, 2, symbols, 1, 1, 0);
+ return ff_init_vlc_from_lengths(vlc, VLC_BITS, count, bits, 1,
+ symbols, 1, 1, 0, 0, ctx->avctx);
}
/*