OLD | NEW |
1 /* Copyright 2015 Google Inc. All Rights Reserved. | 1 /* Copyright 2015 Google Inc. All Rights Reserved. |
2 | 2 |
3 Distributed under MIT license. | 3 Distributed under MIT license. |
4 See file LICENSE for detail or copy at https://opensource.org/licenses/MIT | 4 See file LICENSE for detail or copy at https://opensource.org/licenses/MIT |
5 */ | 5 */ |
6 | 6 |
7 // Function for fast encoding of an input fragment, independently from the input | 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 | 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 | 9 match, we immediately emit the corresponding command and literal codes to |
10 // the bit stream. | 10 the bit stream. */ |
11 | 11 |
12 #ifndef BROTLI_ENC_COMPRESS_FRAGMENT_H_ | 12 #ifndef BROTLI_ENC_COMPRESS_FRAGMENT_H_ |
13 #define BROTLI_ENC_COMPRESS_FRAGMENT_H_ | 13 #define BROTLI_ENC_COMPRESS_FRAGMENT_H_ |
14 | 14 |
15 #include "./types.h" | 15 #include <brotli/types.h> |
| 16 #include "./memory.h" |
| 17 #include "./port.h" |
16 | 18 |
17 namespace brotli { | 19 #if defined(__cplusplus) || defined(c_plusplus) |
| 20 extern "C" { |
| 21 #endif |
18 | 22 |
19 // Compresses "input" string to the "*storage" buffer as one or more complete | 23 /* Compresses "input" string to the "*storage" buffer as one or more complete |
20 // meta-blocks, and updates the "*storage_ix" bit position. | 24 meta-blocks, and updates the "*storage_ix" bit position. |
21 // | |
22 // If "is_last" is true, emits an additional empty last meta-block. | |
23 // | |
24 // "cmd_depth" and "cmd_bits" contain the command and distance prefix codes | |
25 // (see comment in encode.h) used for the encoding of this input fragment. | |
26 // If "is_last" is false, they are updated to reflect the statistics | |
27 // of this input fragment, to be used for the encoding of the next fragment. | |
28 // | |
29 // "*cmd_code_numbits" is the number of bits of the compressed representation | |
30 // of the command and distance prefix codes, and "cmd_code" is an array of | |
31 // at least "(*cmd_code_numbits + 7) >> 3" size that contains the compressed | |
32 // command and distance prefix codes. If "is_last" is false, these are also | |
33 // updated to represent the updated "cmd_depth" and "cmd_bits". | |
34 // | |
35 // REQUIRES: "input_size" is greater than zero, or "is_last" is true. | |
36 // REQUIRES: All elements in "table[0..table_size-1]" are initialized to zero. | |
37 // REQUIRES: "table_size" is a power of two | |
38 void BrotliCompressFragmentFast(const uint8_t* input, size_t input_size, | |
39 bool is_last, | |
40 int* table, size_t table_size, | |
41 uint8_t cmd_depth[128], uint16_t cmd_bits[128], | |
42 size_t* cmd_code_numbits, uint8_t* cmd_code, | |
43 size_t* storage_ix, uint8_t* storage); | |
44 | 25 |
45 } // namespace brotli | 26 If "is_last" is 1, emits an additional empty last meta-block. |
46 | 27 |
47 #endif // BROTLI_ENC_COMPRESS_FRAGMENT_H_ | 28 "cmd_depth" and "cmd_bits" contain the command and distance prefix codes |
| 29 (see comment in encode.h) used for the encoding of this input fragment. |
| 30 If "is_last" is 0, they are updated to reflect the statistics |
| 31 of this input fragment, to be used for the encoding of the next fragment. |
| 32 |
| 33 "*cmd_code_numbits" is the number of bits of the compressed representation |
| 34 of the command and distance prefix codes, and "cmd_code" is an array of |
| 35 at least "(*cmd_code_numbits + 7) >> 3" size that contains the compressed |
| 36 command and distance prefix codes. If "is_last" is 0, these are also |
| 37 updated to represent the updated "cmd_depth" and "cmd_bits". |
| 38 |
| 39 REQUIRES: "input_size" is greater than zero, or "is_last" is 1. |
| 40 REQUIRES: All elements in "table[0..table_size-1]" are initialized to zero. |
| 41 REQUIRES: "table_size" is an odd (9, 11, 13, 15) power of two |
| 42 OUTPUT: maximal copy distance <= |input_size| |
| 43 OUTPUT: maximal copy distance <= MaxBackwardLimit(18) */ |
| 44 BROTLI_INTERNAL void BrotliCompressFragmentFast(MemoryManager* m, |
| 45 const uint8_t* input, |
| 46 size_t input_size, |
| 47 BROTLI_BOOL is_last, |
| 48 int* table, size_t table_size, |
| 49 uint8_t cmd_depth[128], |
| 50 uint16_t cmd_bits[128], |
| 51 size_t* cmd_code_numbits, |
| 52 uint8_t* cmd_code, |
| 53 size_t* storage_ix, |
| 54 uint8_t* storage); |
| 55 |
| 56 #if defined(__cplusplus) || defined(c_plusplus) |
| 57 } /* extern "C" */ |
| 58 #endif |
| 59 |
| 60 #endif /* BROTLI_ENC_COMPRESS_FRAGMENT_H_ */ |
OLD | NEW |