]>
Commit | Line | Data |
---|---|---|
11b7501a SB |
1 | /* Copyright 2014 Google Inc. All Rights Reserved.\r |
2 | \r | |
3 | Distributed under MIT license.\r | |
4 | See file LICENSE for detail or copy at https://opensource.org/licenses/MIT\r | |
5 | */\r | |
6 | \r | |
7 | /* Functions to convert brotli-related data structures into the\r | |
8 | brotli bit stream. The functions here operate under\r | |
9 | assumption that there is enough space in the storage, i.e., there are\r | |
10 | no out-of-range checks anywhere.\r | |
11 | \r | |
12 | These functions do bit addressing into a byte array. The byte array\r | |
13 | is called "storage" and the index to the bit is called storage_ix\r | |
14 | in function arguments. */\r | |
15 | \r | |
16 | #ifndef BROTLI_ENC_BROTLI_BIT_STREAM_H_\r | |
17 | #define BROTLI_ENC_BROTLI_BIT_STREAM_H_\r | |
18 | \r | |
dd4f667e LG |
19 | #include "../common/context.h"\r |
20 | #include "../common/platform.h"\r | |
21 | #include <brotli/types.h>\r | |
11b7501a | 22 | #include "./command.h"\r |
11b7501a SB |
23 | #include "./entropy_encode.h"\r |
24 | #include "./memory.h"\r | |
25 | #include "./metablock.h"\r | |
11b7501a SB |
26 | \r |
27 | #if defined(__cplusplus) || defined(c_plusplus)\r | |
28 | extern "C" {\r | |
29 | #endif\r | |
30 | \r | |
31 | /* All Store functions here will use a storage_ix, which is always the bit\r | |
32 | position for the current storage. */\r | |
33 | \r | |
34 | BROTLI_INTERNAL void BrotliStoreHuffmanTree(const uint8_t* depths, size_t num,\r | |
dd4f667e | 35 | HuffmanTree* tree, size_t* storage_ix, uint8_t* storage);\r |
11b7501a SB |
36 | \r |
37 | BROTLI_INTERNAL void BrotliBuildAndStoreHuffmanTreeFast(\r | |
38 | MemoryManager* m, const uint32_t* histogram, const size_t histogram_total,\r | |
39 | const size_t max_bits, uint8_t* depth, uint16_t* bits, size_t* storage_ix,\r | |
40 | uint8_t* storage);\r | |
41 | \r | |
42 | /* REQUIRES: length > 0 */\r | |
43 | /* REQUIRES: length <= (1 << 24) */\r | |
44 | BROTLI_INTERNAL void BrotliStoreMetaBlock(MemoryManager* m,\r | |
dd4f667e LG |
45 | const uint8_t* input, size_t start_pos, size_t length, size_t mask,\r |
46 | uint8_t prev_byte, uint8_t prev_byte2, BROTLI_BOOL is_last,\r | |
47 | const BrotliEncoderParams* params, ContextType literal_context_mode,\r | |
48 | const Command* commands, size_t n_commands, const MetaBlockSplit* mb,\r | |
49 | size_t* storage_ix, uint8_t* storage);\r | |
11b7501a SB |
50 | \r |
51 | /* Stores the meta-block without doing any block splitting, just collects\r | |
52 | one histogram per block category and uses that for entropy coding.\r | |
53 | REQUIRES: length > 0\r | |
54 | REQUIRES: length <= (1 << 24) */\r | |
55 | BROTLI_INTERNAL void BrotliStoreMetaBlockTrivial(MemoryManager* m,\r | |
dd4f667e LG |
56 | const uint8_t* input, size_t start_pos, size_t length, size_t mask,\r |
57 | BROTLI_BOOL is_last, const BrotliEncoderParams* params,\r | |
58 | const Command* commands, size_t n_commands,\r | |
59 | size_t* storage_ix, uint8_t* storage);\r | |
11b7501a SB |
60 | \r |
61 | /* Same as above, but uses static prefix codes for histograms with a only a few\r | |
62 | symbols, and uses static code length prefix codes for all other histograms.\r | |
63 | REQUIRES: length > 0\r | |
64 | REQUIRES: length <= (1 << 24) */\r | |
65 | BROTLI_INTERNAL void BrotliStoreMetaBlockFast(MemoryManager* m,\r | |
dd4f667e LG |
66 | const uint8_t* input, size_t start_pos, size_t length, size_t mask,\r |
67 | BROTLI_BOOL is_last, const BrotliEncoderParams* params,\r | |
68 | const Command* commands, size_t n_commands,\r | |
69 | size_t* storage_ix, uint8_t* storage);\r | |
11b7501a SB |
70 | \r |
71 | /* This is for storing uncompressed blocks (simple raw storage of\r | |
72 | bytes-as-bytes).\r | |
73 | REQUIRES: length > 0\r | |
74 | REQUIRES: length <= (1 << 24) */\r | |
75 | BROTLI_INTERNAL void BrotliStoreUncompressedMetaBlock(\r | |
dd4f667e LG |
76 | BROTLI_BOOL is_final_block, const uint8_t* BROTLI_RESTRICT input,\r |
77 | size_t position, size_t mask, size_t len,\r | |
78 | size_t* BROTLI_RESTRICT storage_ix, uint8_t* BROTLI_RESTRICT storage);\r | |
11b7501a SB |
79 | \r |
80 | #if defined(__cplusplus) || defined(c_plusplus)\r | |
81 | } /* extern "C" */\r | |
82 | #endif\r | |
83 | \r | |
84 | #endif /* BROTLI_ENC_BROTLI_BIT_STREAM_H_ */\r |