OLD | NEW |
1 /* Copyright 2013 Google Inc. All Rights Reserved. | 1 /* Copyright 2013 Google Inc. All Rights Reserved. |
2 | 2 |
3 Distributed under MIT license. | 3 Distributed under MIT license. |
4 See file LICENSE for detail or copy at https://opensource.org/licenses/MIT | 4 See file LICENSE for detail or copy at https://opensource.org/licenses/MIT |
5 */ | 5 */ |
6 | 6 |
7 // Block split point selection utilities. | 7 /* Block split point selection utilities. */ |
8 | 8 |
9 #ifndef BROTLI_ENC_BLOCK_SPLITTER_H_ | 9 #ifndef BROTLI_ENC_BLOCK_SPLITTER_H_ |
10 #define BROTLI_ENC_BLOCK_SPLITTER_H_ | 10 #define BROTLI_ENC_BLOCK_SPLITTER_H_ |
11 | 11 |
12 #include <vector> | 12 #include <brotli/types.h> |
| 13 #include "./command.h" |
| 14 #include "./memory.h" |
| 15 #include "./port.h" |
| 16 #include "./quality.h" |
13 | 17 |
14 #include "./command.h" | 18 #if defined(__cplusplus) || defined(c_plusplus) |
15 #include "./metablock.h" | 19 extern "C" { |
16 #include "./types.h" | 20 #endif |
17 | 21 |
18 namespace brotli { | 22 typedef struct BlockSplit { |
| 23 size_t num_types; /* Amount of distinct types */ |
| 24 size_t num_blocks; /* Amount of values in types and length */ |
| 25 uint8_t* types; |
| 26 uint32_t* lengths; |
19 | 27 |
20 struct BlockSplitIterator { | 28 size_t types_alloc_size; |
21 explicit BlockSplitIterator(const BlockSplit& split) | 29 size_t lengths_alloc_size; |
22 : split_(split), idx_(0), type_(0), length_(0) { | 30 } BlockSplit; |
23 if (!split.lengths.empty()) { | |
24 length_ = split.lengths[0]; | |
25 } | |
26 } | |
27 | 31 |
28 void Next(void) { | 32 BROTLI_INTERNAL void BrotliInitBlockSplit(BlockSplit* self); |
29 if (length_ == 0) { | 33 BROTLI_INTERNAL void BrotliDestroyBlockSplit(MemoryManager* m, |
30 ++idx_; | 34 BlockSplit* self); |
31 type_ = split_.types[idx_]; | |
32 length_ = split_.lengths[idx_]; | |
33 } | |
34 --length_; | |
35 } | |
36 | 35 |
37 const BlockSplit& split_; | 36 BROTLI_INTERNAL void BrotliSplitBlock(MemoryManager* m, |
38 size_t idx_; | 37 const Command* cmds, |
39 size_t type_; | 38 const size_t num_commands, |
40 size_t length_; | 39 const uint8_t* data, |
41 }; | 40 const size_t offset, |
| 41 const size_t mask, |
| 42 const BrotliEncoderParams* params, |
| 43 BlockSplit* literal_split, |
| 44 BlockSplit* insert_and_copy_split, |
| 45 BlockSplit* dist_split); |
42 | 46 |
43 void CopyLiteralsToByteArray(const Command* cmds, | 47 #if defined(__cplusplus) || defined(c_plusplus) |
44 const size_t num_commands, | 48 } /* extern "C" */ |
45 const uint8_t* data, | 49 #endif |
46 const size_t offset, | |
47 const size_t mask, | |
48 std::vector<uint8_t>* literals); | |
49 | 50 |
50 void SplitBlock(const Command* cmds, | 51 #endif /* BROTLI_ENC_BLOCK_SPLITTER_H_ */ |
51 const size_t num_commands, | |
52 const uint8_t* data, | |
53 const size_t offset, | |
54 const size_t mask, | |
55 BlockSplit* literal_split, | |
56 BlockSplit* insert_and_copy_split, | |
57 BlockSplit* dist_split); | |
58 | |
59 } // namespace brotli | |
60 | |
61 #endif // BROTLI_ENC_BLOCK_SPLITTER_H_ | |
OLD | NEW |