/src/ghostpdl/brotli/c/enc/metablock.h
Line | Count | Source |
1 | | /* Copyright 2015 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 | | /* Algorithms for distributing the literals and commands of a metablock between |
8 | | block types and contexts. */ |
9 | | |
10 | | #ifndef BROTLI_ENC_METABLOCK_H_ |
11 | | #define BROTLI_ENC_METABLOCK_H_ |
12 | | |
13 | | #include "block_splitter.h" |
14 | | #include "command.h" |
15 | | #include "hash.h" |
16 | | #include "histogram.h" |
17 | | #include "memory.h" |
18 | | #include "params.h" |
19 | | #include "../common/context.h" |
20 | | #include "../common/platform.h" |
21 | | |
22 | | #if defined(__cplusplus) || defined(c_plusplus) |
23 | | extern "C" { |
24 | | #endif |
25 | | |
26 | 0 | #define BROTLI_MAX_STATIC_CONTEXTS 13 |
27 | | |
28 | | typedef struct MetaBlockSplit { |
29 | | BlockSplit literal_split; |
30 | | BlockSplit command_split; |
31 | | BlockSplit distance_split; |
32 | | uint32_t* literal_context_map; |
33 | | size_t literal_context_map_size; |
34 | | uint32_t* distance_context_map; |
35 | | size_t distance_context_map_size; |
36 | | HistogramLiteral* literal_histograms; |
37 | | size_t literal_histograms_size; |
38 | | HistogramCommand* command_histograms; |
39 | | size_t command_histograms_size; |
40 | | HistogramDistance* distance_histograms; |
41 | | size_t distance_histograms_size; |
42 | | uint8_t literal_is_base64[32]; |
43 | | } MetaBlockSplit; |
44 | | |
45 | 0 | static BROTLI_INLINE void InitMetaBlockSplit(MetaBlockSplit* mb) { |
46 | 0 | BrotliInitBlockSplit(&mb->literal_split); |
47 | 0 | BrotliInitBlockSplit(&mb->command_split); |
48 | 0 | BrotliInitBlockSplit(&mb->distance_split); |
49 | 0 | mb->literal_context_map = 0; |
50 | 0 | mb->literal_context_map_size = 0; |
51 | 0 | mb->distance_context_map = 0; |
52 | 0 | mb->distance_context_map_size = 0; |
53 | 0 | mb->literal_histograms = 0; |
54 | 0 | mb->literal_histograms_size = 0; |
55 | 0 | mb->command_histograms = 0; |
56 | 0 | mb->command_histograms_size = 0; |
57 | 0 | mb->distance_histograms = 0; |
58 | 0 | mb->distance_histograms_size = 0; |
59 | 0 | memset(mb->literal_is_base64, 0, sizeof(mb->literal_is_base64)); |
60 | 0 | } Unexecuted instantiation: encode.c:InitMetaBlockSplit Unexecuted instantiation: metablock.c:InitMetaBlockSplit Unexecuted instantiation: brotli_bit_stream.c:InitMetaBlockSplit Unexecuted instantiation: compress_fragment.c:InitMetaBlockSplit Unexecuted instantiation: compress_fragment_two_pass.c:InitMetaBlockSplit |
61 | | |
62 | | static BROTLI_INLINE void DestroyMetaBlockSplit( |
63 | 0 | MemoryManager* m, MetaBlockSplit* mb) { |
64 | 0 | BrotliDestroyBlockSplit(m, &mb->literal_split); |
65 | 0 | BrotliDestroyBlockSplit(m, &mb->command_split); |
66 | 0 | BrotliDestroyBlockSplit(m, &mb->distance_split); |
67 | 0 | BROTLI_FREE(m, mb->literal_context_map); |
68 | 0 | BROTLI_FREE(m, mb->distance_context_map); |
69 | 0 | BROTLI_FREE(m, mb->literal_histograms); |
70 | 0 | BROTLI_FREE(m, mb->command_histograms); |
71 | | BROTLI_FREE(m, mb->distance_histograms); |
72 | 0 | } Unexecuted instantiation: encode.c:DestroyMetaBlockSplit Unexecuted instantiation: metablock.c:DestroyMetaBlockSplit Unexecuted instantiation: brotli_bit_stream.c:DestroyMetaBlockSplit Unexecuted instantiation: compress_fragment.c:DestroyMetaBlockSplit Unexecuted instantiation: compress_fragment_two_pass.c:DestroyMetaBlockSplit |
73 | | |
74 | | /* Uses the slow shortest-path block splitter and does context clustering. |
75 | | The distance parameters are dynamically selected based on the commands |
76 | | which get recomputed under the new distance parameters. The new distance |
77 | | parameters are stored into *params. */ |
78 | | BROTLI_INTERNAL void BrotliBuildMetaBlock( |
79 | | MemoryManager* m, const uint8_t* ringbuffer, const size_t pos, |
80 | | const size_t mask, const Base64Region* base64_regions, |
81 | | size_t num_base64_regions, BrotliEncoderParams* params, uint8_t prev_byte, |
82 | | uint8_t prev_byte2, Command* cmds, size_t num_commands, |
83 | | ContextType literal_context_mode, MetaBlockSplit* mb); |
84 | | |
85 | | /* Uses a fast greedy block splitter that tries to merge current block with the |
86 | | last or the second last block and uses a static context clustering which |
87 | | is the same for all block types. */ |
88 | | BROTLI_INTERNAL void BrotliBuildMetaBlockGreedy( |
89 | | MemoryManager* m, const uint8_t* ringbuffer, size_t pos, size_t mask, |
90 | | const Base64Region* base64_regions, size_t num_base64_regions, |
91 | | uint8_t prev_byte, uint8_t prev_byte2, ContextLut literal_context_lut, |
92 | | size_t num_contexts, const uint32_t* static_context_map, |
93 | | const Command* commands, size_t n_commands, MetaBlockSplit* mb); |
94 | | |
95 | | BROTLI_INTERNAL void BrotliOptimizeHistograms(uint32_t num_distance_codes, |
96 | | MetaBlockSplit* mb); |
97 | | |
98 | | BROTLI_INTERNAL void BrotliInitDistanceParams(BrotliDistanceParams* params, |
99 | | uint32_t npostfix, uint32_t ndirect, BROTLI_BOOL large_window); |
100 | | |
101 | | #if defined(__cplusplus) || defined(c_plusplus) |
102 | | } /* extern "C" */ |
103 | | #endif |
104 | | |
105 | | #endif /* BROTLI_ENC_METABLOCK_H_ */ |