/* 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
}
}
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)