comparison mupdf-source/thirdparty/brotli/c/enc/compound_dictionary.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 2017 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 #ifndef BROTLI_ENC_PREPARED_DICTIONARY_H_
8 #define BROTLI_ENC_PREPARED_DICTIONARY_H_
9
10 #include <brotli/shared_dictionary.h>
11 #include <brotli/types.h>
12
13 #include "../common/platform.h"
14 #include "../common/constants.h"
15 #include "memory.h"
16
17 /* "Fat" prepared dictionary, could be cooked outside of C implementation,
18 * e.g. on Java side. LZ77 data is copied inside PreparedDictionary struct. */
19 static const uint32_t kPreparedDictionaryMagic = 0xDEBCEDE0;
20
21 static const uint32_t kSharedDictionaryMagic = 0xDEBCEDE1;
22
23 static const uint32_t kManagedDictionaryMagic = 0xDEBCEDE2;
24
25 /* "Lean" prepared dictionary. LZ77 data is referenced. It is the responsibility
26 * of caller of "prepare dictionary" to keep the LZ77 data while prepared
27 * dictionary is in use. */
28 static const uint32_t kLeanPreparedDictionaryMagic = 0xDEBCEDE3;
29
30 static const uint64_t kPreparedDictionaryHashMul64Long =
31 BROTLI_MAKE_UINT64_T(0x1FE35A7Bu, 0xD3579BD3u);
32
33 typedef struct PreparedDictionary {
34 uint32_t magic;
35 uint32_t num_items;
36 uint32_t source_size;
37 uint32_t hash_bits;
38 uint32_t bucket_bits;
39 uint32_t slot_bits;
40
41 /* --- Dynamic size members --- */
42
43 /* uint32_t slot_offsets[1 << slot_bits]; */
44 /* uint16_t heads[1 << bucket_bits]; */
45 /* uint32_t items[variable]; */
46
47 /* [maybe] uint8_t* source_ref, depending on magic. */
48 /* [maybe] uint8_t source[source_size], depending on magic. */
49 } PreparedDictionary;
50
51 BROTLI_INTERNAL PreparedDictionary* CreatePreparedDictionary(MemoryManager* m,
52 const uint8_t* source, size_t source_size);
53
54 BROTLI_INTERNAL void DestroyPreparedDictionary(MemoryManager* m,
55 PreparedDictionary* dictionary);
56
57 typedef struct CompoundDictionary {
58 /* LZ77 prefix, compound dictionary */
59 size_t num_chunks;
60 size_t total_size;
61 /* Client instances. */
62 const PreparedDictionary* chunks[SHARED_BROTLI_MAX_COMPOUND_DICTS + 1];
63 const uint8_t* chunk_source[SHARED_BROTLI_MAX_COMPOUND_DICTS + 1];
64 size_t chunk_offsets[SHARED_BROTLI_MAX_COMPOUND_DICTS + 1];
65
66 size_t num_prepared_instances_;
67 /* Owned instances. */
68 PreparedDictionary* prepared_instances_[SHARED_BROTLI_MAX_COMPOUND_DICTS + 1];
69 } CompoundDictionary;
70
71 BROTLI_INTERNAL BROTLI_BOOL AttachPreparedDictionary(
72 CompoundDictionary* compound, const PreparedDictionary* dictionary);
73
74 #endif /* BROTLI_ENC_PREPARED_DICTIONARY */