aboutsummaryrefslogtreecommitdiff
path: root/brotli/dec/decode.c
diff options
context:
space:
mode:
authorZoltan Szabadka <szabadka@google.com>2014-01-08 12:28:28 +0100
committerZoltan Szabadka <szabadka@google.com>2014-01-08 12:28:28 +0100
commit4c8c7fd31c6a9e03c6531b8ddc34fd071f6c9348 (patch)
tree2c0e6096ed820a5b699eb6b66321504b1edb6b14 /brotli/dec/decode.c
parentefbc1a896593be75066ba8769915f19a6c1d7485 (diff)
downloadsrc-4c8c7fd31c6a9e03c6531b8ddc34fd071f6c9348.tar.gz
Brotli format change: small improvement to the encoding of Huffman codes
Combine the HSKIP and the simple/complex Huffman code type bits.
Diffstat (limited to 'brotli/dec/decode.c')
-rw-r--r--brotli/dec/decode.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/brotli/dec/decode.c b/brotli/dec/decode.c
index 4dce7bb..df2e1f9 100644
--- a/brotli/dec/decode.c
+++ b/brotli/dec/decode.c
@@ -234,7 +234,7 @@ static int ReadHuffmanCode(int alphabet_size,
HuffmanTree* tree,
BrotliBitReader* br) {
int ok = 1;
- int simple_code;
+ int simple_code_or_skip;
uint8_t* code_lengths = NULL;
code_lengths =
@@ -247,9 +247,12 @@ static int ReadHuffmanCode(int alphabet_size,
printf("[ReadHuffmanCode] Unexpected end of input.\n");
return 0;
}
- simple_code = BrotliReadBits(br, 1);
- BROTLI_LOG_UINT(simple_code);
- if (simple_code) { /* Read symbols, codes & code lengths directly. */
+ /* simple_code_or_skip is used as follows:
+ 1 for simple code;
+ 0 for no skipping, 2 skips 2 code lengths, 3 skips 3 code lengths */
+ simple_code_or_skip = BrotliReadBits(br, 2);
+ BROTLI_LOG_UINT(simple_code_or_skip);
+ if (simple_code_or_skip == 1) { /* Read symbols, codes & code lengths directly. */
int i;
int max_bits_counter = alphabet_size - 1;
int max_bits = 0;
@@ -286,7 +289,7 @@ static int ReadHuffmanCode(int alphabet_size,
int i;
uint8_t code_length_code_lengths[CODE_LENGTH_CODES] = { 0 };
int space = 32;
- for (i = BrotliReadBits(br, 1) * 2;
+ for (i = simple_code_or_skip;
i < CODE_LENGTH_CODES && space > 0; ++i) {
int code_len_idx = kCodeLengthCodeOrder[i];
int v = BrotliReadBits(br, 2);