| OLD | NEW |
| 1 /* Copyright 2013 Google Inc. All Rights Reserved. | 1 /* Copyright 2013 Google Inc. All Rights Reserved. |
| 2 | 2 |
| 3 Distributed under MIT license. | 3 Distributed under MIT license. |
| 4 See file LICENSE for detail or copy at https://opensource.org/licenses/MIT | 4 See file LICENSE for detail or copy at https://opensource.org/licenses/MIT |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 /* Utilities for building Huffman decoding tables. */ | 7 /* Utilities for building Huffman decoding tables. */ |
| 8 | 8 |
| 9 #include "./huffman.h" | 9 #include "./huffman.h" |
| 10 | 10 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 int left = 1 << (len - root_bits); | 92 int left = 1 << (len - root_bits); |
| 93 while (len < BROTLI_HUFFMAN_MAX_CODE_LENGTH) { | 93 while (len < BROTLI_HUFFMAN_MAX_CODE_LENGTH) { |
| 94 left -= count[len]; | 94 left -= count[len]; |
| 95 if (left <= 0) break; | 95 if (left <= 0) break; |
| 96 ++len; | 96 ++len; |
| 97 left <<= 1; | 97 left <<= 1; |
| 98 } | 98 } |
| 99 return len - root_bits; | 99 return len - root_bits; |
| 100 } | 100 } |
| 101 | 101 |
| 102 | |
| 103 void BrotliBuildCodeLengthsHuffmanTable(HuffmanCode* table, | 102 void BrotliBuildCodeLengthsHuffmanTable(HuffmanCode* table, |
| 104 const uint8_t* const code_lengths, | 103 const uint8_t* const code_lengths, |
| 105 uint16_t* count) { | 104 uint16_t* count) { |
| 106 HuffmanCode code; /* current table entry */ | 105 HuffmanCode code; /* current table entry */ |
| 107 int symbol; /* symbol index in original or sorted table */ | 106 int symbol; /* symbol index in original or sorted table */ |
| 108 uint32_t key; /* prefix code */ | 107 uint32_t key; /* prefix code */ |
| 109 uint32_t key_step; /* prefix code addend */ | 108 uint32_t key_step; /* prefix code addend */ |
| 110 int step; /* step size to replicate values in current table */ | 109 int step; /* step size to replicate values in current table */ |
| 111 int table_size; /* size of current table */ | 110 int table_size; /* size of current table */ |
| 112 int sorted[18]; /* symbols sorted by code length */ | 111 int sorted[18]; /* symbols sorted by code length */ |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 memcpy(&table[table_size], &table[0], | 347 memcpy(&table[table_size], &table[0], |
| 349 (size_t)table_size * sizeof(table[0])); | 348 (size_t)table_size * sizeof(table[0])); |
| 350 table_size <<= 1; | 349 table_size <<= 1; |
| 351 } | 350 } |
| 352 return goal_size; | 351 return goal_size; |
| 353 } | 352 } |
| 354 | 353 |
| 355 #if defined(__cplusplus) || defined(c_plusplus) | 354 #if defined(__cplusplus) || defined(c_plusplus) |
| 356 } /* extern "C" */ | 355 } /* extern "C" */ |
| 357 #endif | 356 #endif |
| OLD | NEW |