| 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 two-pass processing: in the first pass we save | 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 | 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 | 10 second pass we emit them into the bit stream using prefix codes built based |
| 11 // on the actual command and literal byte histograms. | 11 on the actual command and literal byte histograms. */ |
| 12 | 12 |
| 13 #ifndef BROTLI_ENC_COMPRESS_FRAGMENT_TWO_PASS_H_ | 13 #ifndef BROTLI_ENC_COMPRESS_FRAGMENT_TWO_PASS_H_ |
| 14 #define BROTLI_ENC_COMPRESS_FRAGMENT_TWO_PASS_H_ | 14 #define BROTLI_ENC_COMPRESS_FRAGMENT_TWO_PASS_H_ |
| 15 | 15 |
| 16 #include "./types.h" | 16 #include <brotli/types.h> |
| 17 #include "./memory.h" |
| 18 #include "./port.h" |
| 17 | 19 |
| 18 namespace brotli { | 20 #if defined(__cplusplus) || defined(c_plusplus) |
| 21 extern "C" { |
| 22 #endif |
| 19 | 23 |
| 20 static const size_t kCompressFragmentTwoPassBlockSize = 1 << 17; | 24 static const size_t kCompressFragmentTwoPassBlockSize = 1 << 17; |
| 21 | 25 |
| 22 // Compresses "input" string to the "*storage" buffer as one or more complete | 26 /* Compresses "input" string to the "*storage" buffer as one or more complete |
| 23 // meta-blocks, and updates the "*storage_ix" bit position. | 27 meta-blocks, and updates the "*storage_ix" bit position. |
| 24 // | |
| 25 // If "is_last" is true, emits an additional empty last meta-block. | |
| 26 // | |
| 27 // REQUIRES: "input_size" is greater than zero, or "is_last" is true. | |
| 28 // REQUIRES: "command_buf" and "literal_buf" point to at least | |
| 29 // kCompressFragmentTwoPassBlockSize long arrays. | |
| 30 // REQUIRES: All elements in "table[0..table_size-1]" are initialized to zero. | |
| 31 // REQUIRES: "table_size" is a power of two | |
| 32 void BrotliCompressFragmentTwoPass(const uint8_t* input, size_t input_size, | |
| 33 bool is_last, | |
| 34 uint32_t* command_buf, uint8_t* literal_buf, | |
| 35 int* table, size_t table_size, | |
| 36 size_t* storage_ix, uint8_t* storage); | |
| 37 | 28 |
| 38 } // namespace brotli | 29 If "is_last" is 1, emits an additional empty last meta-block. |
| 39 | 30 |
| 40 #endif // BROTLI_ENC_COMPRESS_FRAGMENT_TWO_PASS_H_ | 31 REQUIRES: "input_size" is greater than zero, or "is_last" is 1. |
| 32 REQUIRES: "command_buf" and "literal_buf" point to at least |
| 33 kCompressFragmentTwoPassBlockSize long arrays. |
| 34 REQUIRES: All elements in "table[0..table_size-1]" are initialized to zero. |
| 35 REQUIRES: "table_size" is a power of two |
| 36 OUTPUT: maximal copy distance <= |input_size| |
| 37 OUTPUT: maximal copy distance <= MaxBackwardLimit(18) */ |
| 38 BROTLI_INTERNAL void BrotliCompressFragmentTwoPass(MemoryManager* m, |
| 39 const uint8_t* input, |
| 40 size_t input_size, |
| 41 BROTLI_BOOL is_last, |
| 42 uint32_t* command_buf, |
| 43 uint8_t* literal_buf, |
| 44 int* table, |
| 45 size_t table_size, |
| 46 size_t* storage_ix, |
| 47 uint8_t* storage); |
| 48 |
| 49 #if defined(__cplusplus) || defined(c_plusplus) |
| 50 } /* extern "C" */ |
| 51 #endif |
| 52 |
| 53 #endif /* BROTLI_ENC_COMPRESS_FRAGMENT_TWO_PASS_H_ */ |
| OLD | NEW |