| OLD | NEW |
| (Empty) | |
| 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 <vector> |
| 14 |
| 15 #include "./command.h" |
| 16 #include "./histogram.h" |
| 17 |
| 18 namespace brotli { |
| 19 |
| 20 struct BlockSplit { |
| 21 BlockSplit(void) : num_types(0) {} |
| 22 |
| 23 size_t num_types; |
| 24 std::vector<uint8_t> types; |
| 25 std::vector<uint32_t> lengths; |
| 26 }; |
| 27 |
| 28 struct MetaBlockSplit { |
| 29 BlockSplit literal_split; |
| 30 BlockSplit command_split; |
| 31 BlockSplit distance_split; |
| 32 std::vector<uint32_t> literal_context_map; |
| 33 std::vector<uint32_t> distance_context_map; |
| 34 std::vector<HistogramLiteral> literal_histograms; |
| 35 std::vector<HistogramCommand> command_histograms; |
| 36 std::vector<HistogramDistance> distance_histograms; |
| 37 }; |
| 38 |
| 39 // Uses the slow shortest-path block splitter and does context clustering. |
| 40 void BuildMetaBlock(const uint8_t* ringbuffer, |
| 41 const size_t pos, |
| 42 const size_t mask, |
| 43 uint8_t prev_byte, |
| 44 uint8_t prev_byte2, |
| 45 const Command* cmds, |
| 46 size_t num_commands, |
| 47 ContextType literal_context_mode, |
| 48 MetaBlockSplit* mb); |
| 49 |
| 50 // Uses a fast greedy block splitter that tries to merge current block with the |
| 51 // last or the second last block and does not do any context modeling. |
| 52 void BuildMetaBlockGreedy(const uint8_t* ringbuffer, |
| 53 size_t pos, |
| 54 size_t mask, |
| 55 const Command *commands, |
| 56 size_t n_commands, |
| 57 MetaBlockSplit* mb); |
| 58 |
| 59 // Uses a fast greedy block splitter that tries to merge current block with the |
| 60 // last or the second last block and uses a static context clustering which |
| 61 // is the same for all block types. |
| 62 void BuildMetaBlockGreedyWithContexts(const uint8_t* ringbuffer, |
| 63 size_t pos, |
| 64 size_t mask, |
| 65 uint8_t prev_byte, |
| 66 uint8_t prev_byte2, |
| 67 ContextType literal_context_mode, |
| 68 size_t num_contexts, |
| 69 const uint32_t* static_context_map, |
| 70 const Command *commands, |
| 71 size_t n_commands, |
| 72 MetaBlockSplit* mb); |
| 73 |
| 74 void OptimizeHistograms(size_t num_direct_distance_codes, |
| 75 size_t distance_postfix_bits, |
| 76 MetaBlockSplit* mb); |
| 77 |
| 78 } // namespace brotli |
| 79 |
| 80 #endif // BROTLI_ENC_METABLOCK_H_ |
| OLD | NEW |