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