| 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 one-pass processing: when we find a backward |
| 9 | match, we immediately emit the corresponding command and literal codes to |
| 10 | the bit stream. */ |
| 11 | |
| 12 | #ifndef BROTLI_ENC_COMPRESS_FRAGMENT_H_ |
| 13 | #define BROTLI_ENC_COMPRESS_FRAGMENT_H_cxx . . $ `c/enc/compress_fragment.h:13:9`! |
| 14 | |
| 15 | #include "../common/constants.h"cxx . . $ `<file>/c/common/constants.h`/ |
| 16 | #include "../common/platform.h"cxx . . $ `<file>/c/common/platform.h`/ |
| 17 | #include "entropy_encode.h"cxx . . $ `<file>/c/enc/entropy_encode.h`/ |
| 18 | |
| 19 | #if defined(__cplusplus) || defined(c_plusplus) |
| 20 | extern "C" { |
| 21 | #endif |
| 22 | |
| 23 | typedef struct BrotliOnePassArenacxx . . $ BrotliOnePassArena# { |
| 24 | uint8_tcxx . . $ uint8_t# lit_depthcxx . . $ BrotliOnePassArena#lit_depth.[256]; |
| 25 | uint16_tcxx . . $ uint16_t# lit_bitscxx . . $ BrotliOnePassArena#lit_bits.[256]; |
| 26 | |
| 27 | /* Command and distance prefix codes (each 64 symbols, stored back-to-back) |
| 28 | used for the next block. The command prefix code is over a smaller alphabet |
| 29 | with the following 64 symbols: |
| 30 | 0 - 15: insert length code 0, copy length code 0 - 15, same distance |
| 31 | 16 - 39: insert length code 0, copy length code 0 - 23 |
| 32 | 40 - 63: insert length code 0 - 23, copy length code 0 |
| 33 | Note that symbols 16 and 40 represent the same code in the full alphabet, |
| 34 | but we do not use either of them. */ |
| 35 | uint8_tcxx . . $ uint8_t# cmd_depthcxx . . $ BrotliOnePassArena#cmd_depth.[128]; |
| 36 | uint16_tcxx . . $ uint16_t# cmd_bitscxx . . $ BrotliOnePassArena#cmd_bits.[128]; |
| 37 | uint32_tcxx . . $ uint32_t# cmd_histocxx . . $ BrotliOnePassArena#cmd_histo.[128]; |
| 38 | |
| 39 | /* The compressed form of the command and distance prefix codes for the next |
| 40 | block. */ |
| 41 | uint8_tcxx . . $ uint8_t# cmd_codecxx . . $ BrotliOnePassArena#cmd_code.[512]; |
| 42 | size_t cmd_code_numbitscxx . . $ BrotliOnePassArena#cmd_code_numbits.; |
| 43 | |
| 44 | HuffmanTreecxx . . $ HuffmanTree# treecxx . . $ BrotliOnePassArena#tree.[2 * BROTLI_NUM_LITERAL_SYMBOLScxx . . $ `c/common/constants.h:24:9`! + 1]; |
| 45 | uint32_tcxx . . $ uint32_t# histogramcxx . . $ BrotliOnePassArena#histogram.[256]; |
| 46 | uint8_tcxx . . $ uint8_t# tmp_depthcxx . . $ BrotliOnePassArena#tmp_depth.[BROTLI_NUM_COMMAND_SYMBOLScxx . . $ `c/common/constants.h:25:9`!]; |
| 47 | uint16_tcxx . . $ uint16_t# tmp_bitscxx . . $ BrotliOnePassArena#tmp_bits.[64]; |
| 48 | } BrotliOnePassArenacxx . . $ BrotliOnePassArena#; |
| 49 | |
| 50 | /* Compresses "input" string to the "*storage" buffer as one or more complete |
| 51 | meta-blocks, and updates the "*storage_ix" bit position. |
| 52 | |
| 53 | If "is_last" is 1, emits an additional empty last meta-block. |
| 54 | |
| 55 | "cmd_depth" and "cmd_bits" contain the command and distance prefix codes |
| 56 | (see comment in encode.h) used for the encoding of this input fragment. |
| 57 | If "is_last" is 0, they are updated to reflect the statistics |
| 58 | of this input fragment, to be used for the encoding of the next fragment. |
| 59 | |
| 60 | "*cmd_code_numbits" is the number of bits of the compressed representation |
| 61 | of the command and distance prefix codes, and "cmd_code" is an array of |
| 62 | at least "(*cmd_code_numbits + 7) >> 3" size that contains the compressed |
| 63 | command and distance prefix codes. If "is_last" is 0, these are also |
| 64 | updated to represent the updated "cmd_depth" and "cmd_bits". |
| 65 | |
| 66 | REQUIRES: "input_size" is greater than zero, or "is_last" is 1. |
| 67 | REQUIRES: "input_size" is less or equal to maximal metablock size (1 << 24). |
| 68 | REQUIRES: All elements in "table[0..table_size-1]" are initialized to zero. |
| 69 | REQUIRES: "table_size" is an odd (9, 11, 13, 15) power of two |
| 70 | OUTPUT: maximal copy distance <= |input_size| |
| 71 | OUTPUT: maximal copy distance <= BROTLI_MAX_BACKWARD_LIMIT(18) */ |
| 72 | BROTLI_INTERNALcxx . . $ `c/include/brotli/port.h:252:9`! void BrotliCompressFragmentFastcxx . . $ BrotliCompressFragmentFast(ca8d077902d3a13f).(BrotliOnePassArenacxx . . $ BrotliOnePassArena#* s, |
| 73 | const uint8_tcxx . . $ uint8_t#* input, |
| 74 | size_t input_size, |
| 75 | BROTLI_BOOLcxx . . $ `c/include/brotli/types.h:49:9`! is_last, |
| 76 | int* table, size_t table_size, |
| 77 | size_t* storage_ix, |
| 78 | uint8_tcxx . . $ uint8_t#* storage); |
| 79 | |
| 80 | #if defined(__cplusplus) || defined(c_plusplus) |
| 81 | } /* extern "C" */ |
| 82 | #endif |
| 83 | |
| 84 | #endif /* BROTLI_ENC_COMPRESS_FRAGMENT_H_ */ |