From d06e0fc014b8557556951a78ae4c07b5bba2052f Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sun, 18 Oct 2009 15:28:06 +0200 Subject: [PATCH] save one level of indentation in build_table(). --- bitstream.c | 45 ++++++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/bitstream.c b/bitstream.c index e6360e6a..dedcdead 100644 --- a/bitstream.c +++ b/bitstream.c @@ -83,29 +83,29 @@ static int build_table(struct vlc *vlc, int table_nb_bits, int nb_codes, /* if code matches the prefix, it is in the table */ n -= n_prefix; code_prefix2 = code >> n; - if (n > 0 && code_prefix2 == code_prefix) { - if (n <= table_nb_bits) { - /* no need to add another table */ - j = (code << (table_nb_bits - n)) & (table_size - 1); - nb = 1 << (table_nb_bits - n); - for (k = 0; k < nb; k++) { - if (table[j][1] /* bits */ != 0) { - PARA_EMERG_LOG("detected incorrect code\n"); - exit(EXIT_FAILURE); - } - table[j][1] = n; //bits - table[j][0] = symbol; - j++; + if (n <= 0 || code_prefix2 != code_prefix) + continue; + if (n <= table_nb_bits) { + /* no need to add another table */ + j = (code << (table_nb_bits - n)) & (table_size - 1); + nb = 1 << (table_nb_bits - n); + for (k = 0; k < nb; k++) { + if (table[j][1] /* bits */ != 0) { + PARA_EMERG_LOG("incorrect code\n"); + exit(EXIT_FAILURE); } - } else { - n -= table_nb_bits; - j = (code >> n) & ((1 << table_nb_bits) - 1); - /* compute table size */ - n1 = -table[j][1]; //bits - if (n > n1) - n1 = n; - table[j][1] = -n1; //bits + table[j][1] = n; //bits + table[j][0] = symbol; + j++; } + } else { + n -= table_nb_bits; + j = (code >> n) & ((1 << table_nb_bits) - 1); + /* compute table size */ + n1 = -table[j][1]; //bits + if (n > n1) + n1 = n; + table[j][1] = -n1; //bits } } @@ -156,8 +156,7 @@ void init_vlc(struct vlc *vlc, int nb_bits, int nb_codes, const void *bits, vlc->table = NULL; vlc->table_allocated = 0; vlc->table_size = 0; - build_table(vlc, nb_bits, nb_codes, bits, - codes, codes_size, 0, 0); + build_table(vlc, nb_bits, nb_codes, bits, codes, codes_size, 0, 0); } void free_vlc(struct vlc *vlc) -- 2.39.5