Mercurial > hgrepos > Python2 > PyMuPDF
comparison mupdf-source/thirdparty/brotli/c/enc/metablock.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 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 <brotli/types.h> | |
| 14 | |
| 15 #include "../common/context.h" | |
| 16 #include "../common/platform.h" | |
| 17 #include "block_splitter.h" | |
| 18 #include "command.h" | |
| 19 #include "histogram.h" | |
| 20 #include "memory.h" | |
| 21 #include "quality.h" | |
| 22 | |
| 23 #if defined(__cplusplus) || defined(c_plusplus) | |
| 24 extern "C" { | |
| 25 #endif | |
| 26 | |
| 27 #define BROTLI_MAX_STATIC_CONTEXTS 13 | |
| 28 | |
| 29 typedef struct MetaBlockSplit { | |
| 30 BlockSplit literal_split; | |
| 31 BlockSplit command_split; | |
| 32 BlockSplit distance_split; | |
| 33 uint32_t* literal_context_map; | |
| 34 size_t literal_context_map_size; | |
| 35 uint32_t* distance_context_map; | |
| 36 size_t distance_context_map_size; | |
| 37 HistogramLiteral* literal_histograms; | |
| 38 size_t literal_histograms_size; | |
| 39 HistogramCommand* command_histograms; | |
| 40 size_t command_histograms_size; | |
| 41 HistogramDistance* distance_histograms; | |
| 42 size_t distance_histograms_size; | |
| 43 } MetaBlockSplit; | |
| 44 | |
| 45 static BROTLI_INLINE void InitMetaBlockSplit(MetaBlockSplit* mb) { | |
| 46 BrotliInitBlockSplit(&mb->literal_split); | |
| 47 BrotliInitBlockSplit(&mb->command_split); | |
| 48 BrotliInitBlockSplit(&mb->distance_split); | |
| 49 mb->literal_context_map = 0; | |
| 50 mb->literal_context_map_size = 0; | |
| 51 mb->distance_context_map = 0; | |
| 52 mb->distance_context_map_size = 0; | |
| 53 mb->literal_histograms = 0; | |
| 54 mb->literal_histograms_size = 0; | |
| 55 mb->command_histograms = 0; | |
| 56 mb->command_histograms_size = 0; | |
| 57 mb->distance_histograms = 0; | |
| 58 mb->distance_histograms_size = 0; | |
| 59 } | |
| 60 | |
| 61 static BROTLI_INLINE void DestroyMetaBlockSplit( | |
| 62 MemoryManager* m, MetaBlockSplit* mb) { | |
| 63 BrotliDestroyBlockSplit(m, &mb->literal_split); | |
| 64 BrotliDestroyBlockSplit(m, &mb->command_split); | |
| 65 BrotliDestroyBlockSplit(m, &mb->distance_split); | |
| 66 BROTLI_FREE(m, mb->literal_context_map); | |
| 67 BROTLI_FREE(m, mb->distance_context_map); | |
| 68 BROTLI_FREE(m, mb->literal_histograms); | |
| 69 BROTLI_FREE(m, mb->command_histograms); | |
| 70 BROTLI_FREE(m, mb->distance_histograms); | |
| 71 } | |
| 72 | |
| 73 /* Uses the slow shortest-path block splitter and does context clustering. | |
| 74 The distance parameters are dynamically selected based on the commands | |
| 75 which get recomputed under the new distance parameters. The new distance | |
| 76 parameters are stored into *params. */ | |
| 77 BROTLI_INTERNAL void BrotliBuildMetaBlock(MemoryManager* m, | |
| 78 const uint8_t* ringbuffer, | |
| 79 const size_t pos, | |
| 80 const size_t mask, | |
| 81 BrotliEncoderParams* params, | |
| 82 uint8_t prev_byte, | |
| 83 uint8_t prev_byte2, | |
| 84 Command* cmds, | |
| 85 size_t num_commands, | |
| 86 ContextType literal_context_mode, | |
| 87 MetaBlockSplit* mb); | |
| 88 | |
| 89 /* Uses a fast greedy block splitter that tries to merge current block with the | |
| 90 last or the second last block and uses a static context clustering which | |
| 91 is the same for all block types. */ | |
| 92 BROTLI_INTERNAL void BrotliBuildMetaBlockGreedy( | |
| 93 MemoryManager* m, const uint8_t* ringbuffer, size_t pos, size_t mask, | |
| 94 uint8_t prev_byte, uint8_t prev_byte2, ContextLut literal_context_lut, | |
| 95 size_t num_contexts, const uint32_t* static_context_map, | |
| 96 const Command* commands, size_t n_commands, MetaBlockSplit* mb); | |
| 97 | |
| 98 BROTLI_INTERNAL void BrotliOptimizeHistograms(uint32_t num_distance_codes, | |
| 99 MetaBlockSplit* mb); | |
| 100 | |
| 101 BROTLI_INTERNAL void BrotliInitDistanceParams(BrotliDistanceParams* params, | |
| 102 uint32_t npostfix, uint32_t ndirect, BROTLI_BOOL large_window); | |
| 103 | |
| 104 #if defined(__cplusplus) || defined(c_plusplus) | |
| 105 } /* extern "C" */ | |
| 106 #endif | |
| 107 | |
| 108 #endif /* BROTLI_ENC_METABLOCK_H_ */ |
