diff options
author | Zoltan Szabadka <szabadka@google.com> | 2013-10-17 12:41:36 +0200 |
---|---|---|
committer | Zoltan Szabadka <szabadka@google.com> | 2013-10-17 12:41:36 +0200 |
commit | 9c62eb3e1eec4c10b5aa8db2103b27e66fd237ed (patch) | |
tree | 6094864d9b820d1937de1e25597d35e1c33e270a | |
parent | 7efdf8e114cd4667389605df5a1b5ed498ce0386 (diff) | |
download | src-9c62eb3e1eec4c10b5aa8db2103b27e66fd237ed.tar.gz |
Fix name collisions with libwebp.
Prefix all externally visible function names with Brotli and
make all other functions static.
-rw-r--r-- | brotli/dec/decode.c | 43 | ||||
-rw-r--r-- | brotli/dec/huffman.c | 33 | ||||
-rw-r--r-- | brotli/dec/huffman.h | 26 |
3 files changed, 51 insertions, 51 deletions
diff --git a/brotli/dec/decode.c b/brotli/dec/decode.c index 85f906a..2db4e3f 100644 --- a/brotli/dec/decode.c +++ b/brotli/dec/decode.c @@ -141,8 +141,8 @@ static int ReadHuffmanCodeLengths( int prev_code_len = kDefaultCodeLength; HuffmanTree tree; - if (!HuffmanTreeBuildImplicit(&tree, code_length_code_lengths, - CODE_LENGTH_CODES)) { + if (!BrotliHuffmanTreeBuildImplicit(&tree, code_length_code_lengths, + CODE_LENGTH_CODES)) { printf("[ReadHuffmanCodeLengths] Building code length tree failed: "); PrintIntVector(code_length_code_lengths, CODE_LENGTH_CODES); return 0; @@ -199,7 +199,7 @@ static int ReadHuffmanCodeLengths( ok = 1; End: - HuffmanTreeRelease(&tree); + BrotliHuffmanTreeRelease(&tree); return ok; } @@ -281,8 +281,8 @@ static int ReadHuffmanCode(int alphabet_size, BROTLI_LOG_UINT(first_symbol_len_code); BROTLI_LOG_UINT(symbols[0]); BROTLI_LOG_UINT(symbols[1]); - ok = HuffmanTreeBuildExplicit(tree, code_lengths, codes, symbols, - alphabet_size, num_symbols); + ok = BrotliHuffmanTreeBuildExplicit(tree, code_lengths, codes, symbols, + alphabet_size, num_symbols); if (!ok) { printf("[ReadHuffmanCode] HuffmanTreeBuildExplicit failed: "); PrintIntVector(code_lengths, num_symbols); @@ -312,7 +312,7 @@ static int ReadHuffmanCode(int alphabet_size, code_lengths, br) && RepairHuffmanCodeLengths(alphabet_size, code_lengths); if (ok) { - ok = HuffmanTreeBuildImplicit(tree, code_lengths, alphabet_size); + ok = BrotliHuffmanTreeBuildImplicit(tree, code_lengths, alphabet_size); if (!ok) { printf("[ReadHuffmanCode] HuffmanTreeBuildImplicit failed: "); PrintIntVector(code_lengths, alphabet_size); @@ -422,22 +422,23 @@ typedef struct { HuffmanTree* htrees; } HuffmanTreeGroup; -void HuffmanTreeGroupInit(HuffmanTreeGroup* group, int alphabet_size, - int ntrees) { +static void HuffmanTreeGroupInit(HuffmanTreeGroup* group, int alphabet_size, + int ntrees) { group->alphabet_size = alphabet_size; group->num_htrees = ntrees; group->htrees = (HuffmanTree*)malloc(sizeof(HuffmanTree) * ntrees); } -void HuffmanTreeGroupRelease(HuffmanTreeGroup* group) { +static void HuffmanTreeGroupRelease(HuffmanTreeGroup* group) { int i; for (i = 0; i < group->num_htrees; ++i) { - HuffmanTreeRelease(&group->htrees[i]); + BrotliHuffmanTreeRelease(&group->htrees[i]); } free(group->htrees); } -int HuffmanTreeGroupDecode(HuffmanTreeGroup* group, BrotliBitReader* br) { +static int HuffmanTreeGroupDecode(HuffmanTreeGroup* group, + BrotliBitReader* br) { int i; for (i = 0; i < group->num_htrees; ++i) { ReadHuffmanCode(group->alphabet_size, &group->htrees[i], br); @@ -445,13 +446,13 @@ int HuffmanTreeGroupDecode(HuffmanTreeGroup* group, BrotliBitReader* br) { return 1; } -int DecodeContextMap(int num_block_types, - int stream_type, - int* context_mode, - int* contexts_per_block, - int* num_htrees, - uint8_t** context_map, - BrotliBitReader* br) { +static int DecodeContextMap(int num_block_types, + int stream_type, + int* context_mode, + int* contexts_per_block, + int* num_htrees, + uint8_t** context_map, + BrotliBitReader* br) { int use_context = BrotliReadBits(br, 1); if (!use_context) { *context_mode = 0; @@ -522,7 +523,7 @@ int DecodeContextMap(int num_block_types, (*context_map)[i] = ReadSymbol(&tree_index_htree, br); } } - HuffmanTreeRelease(&tree_index_htree); + BrotliHuffmanTreeRelease(&tree_index_htree); if (BrotliReadBits(br, 1)) { InverseMoveToFrontTransform(*context_map, context_map_size); } @@ -775,8 +776,8 @@ int BrotliDecompressBuffer(size_t encoded_size, free(dist_context_map); for (i = 0; i < 3; ++i) { HuffmanTreeGroupRelease(&hgroup[i]); - HuffmanTreeRelease(&block_type_trees[i]); - HuffmanTreeRelease(&block_len_trees[i]); + BrotliHuffmanTreeRelease(&block_type_trees[i]); + BrotliHuffmanTreeRelease(&block_len_trees[i]); } } diff --git a/brotli/dec/huffman.c b/brotli/dec/huffman.c index 5f37df4..1e11aec 100644 --- a/brotli/dec/huffman.c +++ b/brotli/dec/huffman.c @@ -72,7 +72,7 @@ static int TreeInit(HuffmanTree* const tree, int num_leaves) { return 1; } -void HuffmanTreeRelease(HuffmanTree* const tree) { +void BrotliHuffmanTreeRelease(HuffmanTree* const tree) { if (tree != NULL) { free(tree->root_); tree->root_ = NULL; @@ -81,8 +81,12 @@ void HuffmanTreeRelease(HuffmanTree* const tree) { } } -int HuffmanCodeLengthsToCodes(const int* const code_lengths, - int code_lengths_size, int* const huff_codes) { +// Utility: converts Huffman code lengths to corresponding Huffman codes. +// 'huff_codes' should be pre-allocated. +// Returns false in case of error (memory allocation, invalid codes). +static int HuffmanCodeLengthsToCodes(const int* const code_lengths, + int code_lengths_size, + int* const huff_codes) { int symbol; int code_len; int code_length_hist[MAX_ALLOWED_CODE_LENGTH + 1] = { 0 }; @@ -201,9 +205,9 @@ static int TreeAddSymbol(HuffmanTree* const tree, return 1; } -int HuffmanTreeBuildImplicit(HuffmanTree* const tree, - const int* const code_lengths, - int code_lengths_size) { +int BrotliHuffmanTreeBuildImplicit(HuffmanTree* const tree, + const int* const code_lengths, + int code_lengths_size) { int symbol; int num_symbols = 0; int root_symbol = 0; @@ -227,7 +231,7 @@ int HuffmanTreeBuildImplicit(HuffmanTree* const tree, if (num_symbols == 1) { // Trivial case. const int max_symbol = code_lengths_size; if (root_symbol < 0 || root_symbol >= max_symbol) { - HuffmanTreeRelease(tree); + BrotliHuffmanTreeRelease(tree); return 0; } return TreeAddSymbol(tree, root_symbol, 0, 0); @@ -255,16 +259,17 @@ int HuffmanTreeBuildImplicit(HuffmanTree* const tree, End: free(codes); ok = ok && IsFull(tree); - if (!ok) HuffmanTreeRelease(tree); + if (!ok) BrotliHuffmanTreeRelease(tree); return ok; } } -int HuffmanTreeBuildExplicit(HuffmanTree* const tree, - const int* const code_lengths, - const int* const codes, - const int* const symbols, int max_symbol, - int num_symbols) { +int BrotliHuffmanTreeBuildExplicit(HuffmanTree* const tree, + const int* const code_lengths, + const int* const codes, + const int* const symbols, + int max_symbol, + int num_symbols) { int ok = 0; int i; @@ -290,7 +295,7 @@ int HuffmanTreeBuildExplicit(HuffmanTree* const tree, ok = 1; End: ok = ok && IsFull(tree); - if (!ok) HuffmanTreeRelease(tree); + if (!ok) BrotliHuffmanTreeRelease(tree); return ok; } diff --git a/brotli/dec/huffman.h b/brotli/dec/huffman.h index 2c21fdd..be4bd46 100644 --- a/brotli/dec/huffman.h +++ b/brotli/dec/huffman.h @@ -60,29 +60,23 @@ static BROTLI_INLINE const HuffmanTreeNode* HuffmanTreeNextNode( // Releases the nodes of the Huffman tree. // Note: It does NOT free 'tree' itself. -void HuffmanTreeRelease(HuffmanTree* const tree); +void BrotliHuffmanTreeRelease(HuffmanTree* const tree); // Builds Huffman tree assuming code lengths are implicitly in symbol order. // Returns false in case of error (invalid tree or memory error). -int HuffmanTreeBuildImplicit(HuffmanTree* const tree, - const int* const code_lengths, - int code_lengths_size); +int BrotliHuffmanTreeBuildImplicit(HuffmanTree* const tree, + const int* const code_lengths, + int code_lengths_size); // Build a Huffman tree with explicitly given lists of code lengths, codes // and symbols. Verifies that all symbols added are smaller than max_symbol. // Returns false in case of an invalid symbol, invalid tree or memory error. -int HuffmanTreeBuildExplicit(HuffmanTree* const tree, - const int* const code_lengths, - const int* const codes, - const int* const symbols, int max_symbol, - int num_symbols); - -// Utility: converts Huffman code lengths to corresponding Huffman codes. -// 'huff_codes' should be pre-allocated. -// Returns false in case of error (memory allocation, invalid codes). -int HuffmanCodeLengthsToCodes(const int* const code_lengths, - int code_lengths_size, int* const huff_codes); - +int BrotliHuffmanTreeBuildExplicit(HuffmanTree* const tree, + const int* const code_lengths, + const int* const codes, + const int* const symbols, + int max_symbol, + int num_symbols); #if defined(__cplusplus) || defined(c_plusplus) } // extern "C" |