| 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_cxx . . $ `c/enc/compress_fragment_two_pass.h:14:9`! |
| 15 | |
| 16 | #include "../common/constants.h"cxx . . $ `<file>/c/common/constants.h`/ |
| 17 | #include "../common/platform.h"cxx . . $ `<file>/c/common/platform.h`/ |
| 18 | #include "entropy_encode.h"cxx . . $ `<file>/c/enc/entropy_encode.h`/ |
| 19 | |
| 20 | #if defined(__cplusplus) || defined(c_plusplus) |
| 21 | extern "C" { |
| 22 | #endif |
| 23 | |
| 24 | /* TODO(eustas): turn to macro. */ |
| 25 | static const size_t kCompressFragmentTwoPassBlockSizecxx . . $ kCompressFragmentTwoPassBlockSize. = 1 << 17; |
| 26 | |
| 27 | typedef struct BrotliTwoPassArenacxx . . $ BrotliTwoPassArena# { |
| 28 | uint32_tcxx . . $ uint32_t# lit_histocxx . . $ BrotliTwoPassArena#lit_histo.[256]; |
| 29 | uint8_tcxx . . $ uint8_t# lit_depthcxx . . $ BrotliTwoPassArena#lit_depth.[256]; |
| 30 | uint16_tcxx . . $ uint16_t# lit_bitscxx . . $ BrotliTwoPassArena#lit_bits.[256]; |
| 31 | |
| 32 | uint32_tcxx . . $ uint32_t# cmd_histocxx . . $ BrotliTwoPassArena#cmd_histo.[128]; |
| 33 | uint8_tcxx . . $ uint8_t# cmd_depthcxx . . $ BrotliTwoPassArena#cmd_depth.[128]; |
| 34 | uint16_tcxx . . $ uint16_t# cmd_bitscxx . . $ BrotliTwoPassArena#cmd_bits.[128]; |
| 35 | |
| 36 | /* BuildAndStoreCommandPrefixCode */ |
| 37 | HuffmanTreecxx . . $ HuffmanTree# tmp_treecxx . . $ BrotliTwoPassArena#tmp_tree.[2 * BROTLI_NUM_LITERAL_SYMBOLScxx . . $ `c/common/constants.h:24:9`! + 1]; |
| 38 | uint8_tcxx . . $ uint8_t# tmp_depthcxx . . $ BrotliTwoPassArena#tmp_depth.[BROTLI_NUM_COMMAND_SYMBOLScxx . . $ `c/common/constants.h:25:9`!]; |
| 39 | uint16_tcxx . . $ uint16_t# tmp_bitscxx . . $ BrotliTwoPassArena#tmp_bits.[64]; |
| 40 | } BrotliTwoPassArenacxx . . $ BrotliTwoPassArena#; |
| 41 | |
| 42 | /* Compresses "input" string to the "*storage" buffer as one or more complete |
| 43 | meta-blocks, and updates the "*storage_ix" bit position. |
| 44 | |
| 45 | If "is_last" is 1, emits an additional empty last meta-block. |
| 46 | |
| 47 | REQUIRES: "input_size" is greater than zero, or "is_last" is 1. |
| 48 | REQUIRES: "input_size" is less or equal to maximal metablock size (1 << 24). |
| 49 | REQUIRES: "command_buf" and "literal_buf" point to at least |
| 50 | kCompressFragmentTwoPassBlockSize long arrays. |
| 51 | REQUIRES: All elements in "table[0..table_size-1]" are initialized to zero. |
| 52 | REQUIRES: "table_size" is a power of two |
| 53 | OUTPUT: maximal copy distance <= |input_size| |
| 54 | OUTPUT: maximal copy distance <= BROTLI_MAX_BACKWARD_LIMIT(18) */ |
| 55 | BROTLI_INTERNALcxx . . $ `c/include/brotli/port.h:252:9`! void BrotliCompressFragmentTwoPasscxx . . $ BrotliCompressFragmentTwoPass(2a2699b994050dec).(BrotliTwoPassArenacxx . . $ BrotliTwoPassArena#* s, |
| 56 | const uint8_tcxx . . $ uint8_t#* input, |
| 57 | size_t input_size, |
| 58 | BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! is_last, |
| 59 | uint32_tcxx . . $ uint32_t#* command_buf, |
| 60 | uint8_tcxx . . $ uint8_t#* literal_buf, |
| 61 | int* table, |
| 62 | size_t table_size, |
| 63 | size_t* storage_ix, |
| 64 | uint8_tcxx . . $ uint8_t#* storage); |
| 65 | |
| 66 | #if defined(__cplusplus) || defined(c_plusplus) |
| 67 | } /* extern "C" */ |
| 68 | #endif |
| 69 | |
| 70 | #endif /* BROTLI_ENC_COMPRESS_FRAGMENT_TWO_PASS_H_ */ |