1 /* Copyright 2015 Google Inc. All Rights Reserved.
3 Distributed under MIT license.
4 See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
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. */
13 #ifndef BROTLI_ENC_COMPRESS_FRAGMENT_TWO_PASS_H_
14 #define BROTLI_ENC_COMPRESS_FRAGMENT_TWO_PASS_H_
16 #include "../common/platform.h"
17 #include <brotli/types.h>
20 #if defined(__cplusplus) || defined(c_plusplus)
24 static const size_t kCompressFragmentTwoPassBlockSize
= 1 << 17;
26 /* Compresses "input" string to the "*storage" buffer as one or more complete
27 meta-blocks, and updates the "*storage_ix" bit position.
29 If "is_last" is 1, emits an additional empty last meta-block.
31 REQUIRES: "input_size" is greater than zero, or "is_last" is 1.
32 REQUIRES: "input_size" is less or equal to maximal metablock size (1 << 24).
33 REQUIRES: "command_buf" and "literal_buf" point to at least
34 kCompressFragmentTwoPassBlockSize long arrays.
35 REQUIRES: All elements in "table[0..table_size-1]" are initialized to zero.
36 REQUIRES: "table_size" is a power of two
37 OUTPUT: maximal copy distance <= |input_size|
38 OUTPUT: maximal copy distance <= BROTLI_MAX_BACKWARD_LIMIT(18) */
39 BROTLI_INTERNAL
void BrotliCompressFragmentTwoPass(MemoryManager
* m
,
43 uint32_t* command_buf
,
50 #if defined(__cplusplus) || defined(c_plusplus)
54 #endif /* BROTLI_ENC_COMPRESS_FRAGMENT_TWO_PASS_H_ */