comparison mupdf-source/thirdparty/brotli/c/enc/brotli_bit_stream.h @ 2:b50eed0cc0ef upstream

ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4. The directory name has changed: no version number in the expanded directory now.
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 15 Sep 2025 11:43:07 +0200
parents
children
comparison
equal deleted inserted replaced
1:1d09e1dec1d9 2:b50eed0cc0ef
1 /* Copyright 2014 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 /* Functions to convert brotli-related data structures into the
8 brotli bit stream. The functions here operate under
9 assumption that there is enough space in the storage, i.e., there are
10 no out-of-range checks anywhere.
11
12 These functions do bit addressing into a byte array. The byte array
13 is called "storage" and the index to the bit is called storage_ix
14 in function arguments. */
15
16 #ifndef BROTLI_ENC_BROTLI_BIT_STREAM_H_
17 #define BROTLI_ENC_BROTLI_BIT_STREAM_H_
18
19 #include <brotli/types.h>
20
21 #include "../common/context.h"
22 #include "../common/platform.h"
23 #include "command.h"
24 #include "entropy_encode.h"
25 #include "memory.h"
26 #include "metablock.h"
27
28 #if defined(__cplusplus) || defined(c_plusplus)
29 extern "C" {
30 #endif
31
32 /* All Store functions here will use a storage_ix, which is always the bit
33 position for the current storage. */
34
35 BROTLI_INTERNAL void BrotliStoreHuffmanTree(const uint8_t* depths, size_t num,
36 HuffmanTree* tree, size_t* storage_ix, uint8_t* storage);
37
38 BROTLI_INTERNAL void BrotliBuildAndStoreHuffmanTreeFast(
39 HuffmanTree* tree, const uint32_t* histogram, const size_t histogram_total,
40 const size_t max_bits, uint8_t* depth, uint16_t* bits, size_t* storage_ix,
41 uint8_t* storage);
42
43 /* REQUIRES: length > 0 */
44 /* REQUIRES: length <= (1 << 24) */
45 BROTLI_INTERNAL void BrotliStoreMetaBlock(MemoryManager* m,
46 const uint8_t* input, size_t start_pos, size_t length, size_t mask,
47 uint8_t prev_byte, uint8_t prev_byte2, BROTLI_BOOL is_last,
48 const BrotliEncoderParams* params, ContextType literal_context_mode,
49 const Command* commands, size_t n_commands, const MetaBlockSplit* mb,
50 size_t* storage_ix, uint8_t* storage);
51
52 /* Stores the meta-block without doing any block splitting, just collects
53 one histogram per block category and uses that for entropy coding.
54 REQUIRES: length > 0
55 REQUIRES: length <= (1 << 24) */
56 BROTLI_INTERNAL void BrotliStoreMetaBlockTrivial(MemoryManager* m,
57 const uint8_t* input, size_t start_pos, size_t length, size_t mask,
58 BROTLI_BOOL is_last, const BrotliEncoderParams* params,
59 const Command* commands, size_t n_commands,
60 size_t* storage_ix, uint8_t* storage);
61
62 /* Same as above, but uses static prefix codes for histograms with a only a few
63 symbols, and uses static code length prefix codes for all other histograms.
64 REQUIRES: length > 0
65 REQUIRES: length <= (1 << 24) */
66 BROTLI_INTERNAL void BrotliStoreMetaBlockFast(MemoryManager* m,
67 const uint8_t* input, size_t start_pos, size_t length, size_t mask,
68 BROTLI_BOOL is_last, const BrotliEncoderParams* params,
69 const Command* commands, size_t n_commands,
70 size_t* storage_ix, uint8_t* storage);
71
72 /* This is for storing uncompressed blocks (simple raw storage of
73 bytes-as-bytes).
74 REQUIRES: length > 0
75 REQUIRES: length <= (1 << 24) */
76 BROTLI_INTERNAL void BrotliStoreUncompressedMetaBlock(
77 BROTLI_BOOL is_final_block, const uint8_t* BROTLI_RESTRICT input,
78 size_t position, size_t mask, size_t len,
79 size_t* BROTLI_RESTRICT storage_ix, uint8_t* BROTLI_RESTRICT storage);
80
81 #if defined(BROTLI_TEST)
82 void GetBlockLengthPrefixCodeForTest(uint32_t, size_t*, uint32_t*, uint32_t*);
83 #endif
84
85 #if defined(__cplusplus) || defined(c_plusplus)
86 } /* extern "C" */
87 #endif
88
89 #endif /* BROTLI_ENC_BROTLI_BIT_STREAM_H_ */