Mercurial > hgrepos > Python2 > PyMuPDF
comparison mupdf-source/thirdparty/brotli/c/enc/compress_fragment_two_pass.h @ 3:2c135c81b16c
MERGE: upstream PyMuPDF 1.26.4 with MuPDF 1.26.7
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 15 Sep 2025 11:44:09 +0200 |
| parents | b50eed0cc0ef |
| children |
comparison
equal
deleted
inserted
replaced
| 0:6015a75abc2d | 3:2c135c81b16c |
|---|---|
| 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 /* Function for fast encoding of an input fragment, independently from the input | |
| 8 history. This function uses two-pass processing: in the first pass we save | |
| 9 the found backward matches and literal bytes into a buffer, and in the | |
| 10 second pass we emit them into the bit stream using prefix codes built based | |
| 11 on the actual command and literal byte histograms. */ | |
| 12 | |
| 13 #ifndef BROTLI_ENC_COMPRESS_FRAGMENT_TWO_PASS_H_ | |
| 14 #define BROTLI_ENC_COMPRESS_FRAGMENT_TWO_PASS_H_ | |
| 15 | |
| 16 #include <brotli/types.h> | |
| 17 | |
| 18 #include "../common/constants.h" | |
| 19 #include "../common/platform.h" | |
| 20 #include "entropy_encode.h" | |
| 21 | |
| 22 #if defined(__cplusplus) || defined(c_plusplus) | |
| 23 extern "C" { | |
| 24 #endif | |
| 25 | |
| 26 /* TODO(eustas): turn to macro. */ | |
| 27 static const size_t kCompressFragmentTwoPassBlockSize = 1 << 17; | |
| 28 | |
| 29 typedef struct BrotliTwoPassArena { | |
| 30 uint32_t lit_histo[256]; | |
| 31 uint8_t lit_depth[256]; | |
| 32 uint16_t lit_bits[256]; | |
| 33 | |
| 34 uint32_t cmd_histo[128]; | |
| 35 uint8_t cmd_depth[128]; | |
| 36 uint16_t cmd_bits[128]; | |
| 37 | |
| 38 /* BuildAndStoreCommandPrefixCode */ | |
| 39 HuffmanTree tmp_tree[2 * BROTLI_NUM_LITERAL_SYMBOLS + 1]; | |
| 40 uint8_t tmp_depth[BROTLI_NUM_COMMAND_SYMBOLS]; | |
| 41 uint16_t tmp_bits[64]; | |
| 42 } BrotliTwoPassArena; | |
| 43 | |
| 44 /* Compresses "input" string to the "*storage" buffer as one or more complete | |
| 45 meta-blocks, and updates the "*storage_ix" bit position. | |
| 46 | |
| 47 If "is_last" is 1, emits an additional empty last meta-block. | |
| 48 | |
| 49 REQUIRES: "input_size" is greater than zero, or "is_last" is 1. | |
| 50 REQUIRES: "input_size" is less or equal to maximal metablock size (1 << 24). | |
| 51 REQUIRES: "command_buf" and "literal_buf" point to at least | |
| 52 kCompressFragmentTwoPassBlockSize long arrays. | |
| 53 REQUIRES: All elements in "table[0..table_size-1]" are initialized to zero. | |
| 54 REQUIRES: "table_size" is a power of two | |
| 55 OUTPUT: maximal copy distance <= |input_size| | |
| 56 OUTPUT: maximal copy distance <= BROTLI_MAX_BACKWARD_LIMIT(18) */ | |
| 57 BROTLI_INTERNAL void BrotliCompressFragmentTwoPass(BrotliTwoPassArena* s, | |
| 58 const uint8_t* input, | |
| 59 size_t input_size, | |
| 60 BROTLI_BOOL is_last, | |
| 61 uint32_t* command_buf, | |
| 62 uint8_t* literal_buf, | |
| 63 int* table, | |
| 64 size_t table_size, | |
| 65 size_t* storage_ix, | |
| 66 uint8_t* storage); | |
| 67 | |
| 68 #if defined(__cplusplus) || defined(c_plusplus) | |
| 69 } /* extern "C" */ | |
| 70 #endif | |
| 71 | |
| 72 #endif /* BROTLI_ENC_COMPRESS_FRAGMENT_TWO_PASS_H_ */ |
