Debian Codegraph @

c/enc/entropy_encode.h

raw symbols SCIP
1 /* Copyright 2010 Google Inc. All Rights Reserved.
2
3 Distributed under MIT license.
4 See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
5 */
6
7 /* Entropy encoding (Huffman) utilities. */
8
9 #ifndef BROTLI_ENC_ENTROPY_ENCODE_H_
10 #define BROTLI_ENC_ENTROPY_ENCODE_H_cxx . . $ `c/enc/entropy_encode.h:10:9`!
11
12 #include "../common/platform.h"cxx . . $ `<file>/c/common/platform.h`/
13
14 #if defined(__cplusplus) || defined(c_plusplus)
15 extern "C" {
16 #endif
17
18 /* A node of a Huffman tree. */
19 typedef struct HuffmanTreecxx . . $ HuffmanTree# {
20 uint32_tcxx . . $ uint32_t# total_count_cxx . . $ HuffmanTree#total_count_.;
21 int16_tcxx . . $ int16_t# index_left_cxx . . $ HuffmanTree#index_left_.;
22 int16_tcxx . . $ int16_t# index_right_or_value_cxx . . $ HuffmanTree#index_right_or_value_.;
23 } HuffmanTreecxx . . $ HuffmanTree#;
24
25 static BROTLI_INLINEcxx . . $ `c/common/platform.h:119:9`! void InitHuffmanTreecxx . . $ InitHuffmanTree(e357aa9f8b4b4544).(HuffmanTreecxx . . $ HuffmanTree#* self, uint32_tcxx . . $ uint32_t# count,
26 int16_tcxx . . $ int16_t# left, int16_tcxx . . $ int16_t# right) {
27 self->total_count_cxx . . $ HuffmanTree#total_count_. = count;
28 self->index_left_cxx . . $ HuffmanTree#index_left_. = left;
29 self->index_right_or_value_cxx . . $ HuffmanTree#index_right_or_value_. = right;
30 }
31
32 /* Returns 1 is assignment of depths succeeded, otherwise 0. */
33 BROTLI_INTERNALcxx . . $ `c/include/brotli/port.h:252:9`! BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! BrotliSetDepthcxx . . $ BrotliSetDepth(ead3c68a25274c25).(
34 int p, HuffmanTreecxx . . $ HuffmanTree#* pool, uint8_tcxx . . $ uint8_t#* depth, int max_depth);
35
36 /* This function will create a Huffman tree.
37
38 The (data,length) contains the population counts.
39 The tree_limit is the maximum bit depth of the Huffman codes.
40
41 The depth contains the tree, i.e., how many bits are used for
42 the symbol.
43
44 The actual Huffman tree is constructed in the tree[] array, which has to
45 be at least 2 * length + 1 long.
46
47 See http://en.wikipedia.org/wiki/Huffman_coding */
48 BROTLI_INTERNALcxx . . $ `c/include/brotli/port.h:252:9`! void BrotliCreateHuffmanTreecxx . . $ BrotliCreateHuffmanTree(84acd5421a2fe552).(const uint32_tcxx . . $ uint32_t#* data,
49 const size_t length,
50 const int tree_limit,
51 HuffmanTreecxx . . $ HuffmanTree#* tree,
52 uint8_tcxx . . $ uint8_t#* depth);
53
54 /* Change the population counts in a way that the consequent
55 Huffman tree compression, especially its RLE-part will be more
56 likely to compress this data more efficiently.
57
58 length contains the size of the histogram.
59 counts contains the population counts.
60 good_for_rle is a buffer of at least length size */
61 BROTLI_INTERNALcxx . . $ `c/include/brotli/port.h:252:9`! void BrotliOptimizeHuffmanCountsForRlecxx . . $ BrotliOptimizeHuffmanCountsForRle(c1200953a35bc128).(
62 size_t length, uint32_tcxx . . $ uint32_t#* counts, uint8_tcxx . . $ uint8_t#* good_for_rle);
63
64 /* Write a Huffman tree from bit depths into the bit-stream representation
65 of a Huffman tree. The generated Huffman tree is to be compressed once
66 more using a Huffman tree */
67 BROTLI_INTERNALcxx . . $ `c/include/brotli/port.h:252:9`! void BrotliWriteHuffmanTreecxx . . $ BrotliWriteHuffmanTree(33fe0f2ae1daff41).(const uint8_tcxx . . $ uint8_t#* depth,
68 size_t length,
69 size_t* tree_size,
70 uint8_tcxx . . $ uint8_t#* tree,
71 uint8_tcxx . . $ uint8_t#* extra_bits_data);
72
73 /* Get the actual bit values for a tree of bit depths. */
74 BROTLI_INTERNALcxx . . $ `c/include/brotli/port.h:252:9`! void BrotliConvertBitDepthsToSymbolscxx . . $ BrotliConvertBitDepthsToSymbols(4b6fce73272d3f29).(const uint8_tcxx . . $ uint8_t#* depth,
75 size_t len,
76 uint16_tcxx . . $ uint16_t#* bits);
77
78 BROTLI_INTERNALcxx . . $ `c/include/brotli/port.h:252:9`! extern BROTLI_MODELcxx . . $ `c/common/platform.h:674:9`!("small") const size_t kBrotliShellGapscxx . . $ kBrotliShellGaps.[6];
79 /* Input size optimized Shell sort. */
80 typedef BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! (*HuffmanTreeComparatorcxx . . $ HuffmanTreeComparator#)(
81 const HuffmanTreecxx . . $ HuffmanTree#*, const HuffmanTreecxx . . $ HuffmanTree#*);
82 static BROTLI_INLINEcxx . . $ `c/common/platform.h:119:9`! void SortHuffmanTreeItemscxx . . $ SortHuffmanTreeItems(391bcd312c3cedbf).(HuffmanTreecxx . . $ HuffmanTree#* items,
83 const size_t n, HuffmanTreeComparatorcxx . . $ HuffmanTreeComparator# comparator) {
84 if (n < 13) {
85 /* Insertion sort. */
86 size_t i;
87 for (i = 1; i < n; ++i) {
88 HuffmanTreecxx . . $ HuffmanTree# tmp = items[i];
89 size_t k = i;
90 size_t j = i - 1;
91 while (comparator(&tmp, &items[j])) {
92 items[k] = items[j];
93 k = j;
94 if (!j--) break;
95 }
96 items[k] = tmp;
97 }
98 return;
99 } else {
100 /* Shell sort. */
101 int g = n < 57 ? 2 : 0;
102 for (; g < 6; ++g) {
103 size_t gap = kBrotliShellGapscxx . . $ kBrotliShellGaps.[g];
104 size_t i;
105 for (i = gap; i < n; ++i) {
106 size_t j = i;
107 HuffmanTreecxx . . $ HuffmanTree# tmp = items[i];
108 for (; j >= gap && comparator(&tmp, &items[j - gap]); j -= gap) {
109 items[j] = items[j - gap];
110 }
111 items[j] = tmp;
112 }
113 }
114 }
115 }
116
117 #if defined(__cplusplus) || defined(c_plusplus)
118 } /* extern "C" */
119 #endif
120
121 #endif /* BROTLI_ENC_ENTROPY_ENCODE_H_ */