From f7f96cf4bcc369730bb945e993bec53881e212f5 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Mon, 16 Jun 2014 18:46:14 +0200 Subject: [PATCH] avcodec/bitstream: fill invalid vlc tables entries as last pass instead of first This avoids writing entries twice Signed-off-by: Michael Niedermayer --- libavcodec/bitstream.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/libavcodec/bitstream.c b/libavcodec/bitstream.c index 2d3f6067d3..c61243e7a6 100644 --- a/libavcodec/bitstream.c +++ b/libavcodec/bitstream.c @@ -174,11 +174,6 @@ static int build_table(VLC *vlc, int table_nb_bits, int nb_codes, return table_index; table = &vlc->table[table_index]; - for (i = 0; i < table_size; i++) { - table[i][1] = 0; //bits - table[i][0] = -1; //codes - } - /* first pass: map codes and compute auxiliary table sizes */ for (i = 0; i < nb_codes; i++) { n = codes[i].bits; @@ -237,6 +232,12 @@ static int build_table(VLC *vlc, int table_nb_bits, int nb_codes, i = k-1; } } + + for (i = 0; i < table_size; i++) { + if (table[i][1] == 0) //bits + table[i][0] = -1; //codes + } + return table_index; }