]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/C/BrotliCompress/enc/compress_fragment_two_pass.h
BaseTools: Copy Brotli algorithm 3rd party source code for tool
[mirror_edk2.git] / BaseTools / Source / C / BrotliCompress / enc / compress_fragment_two_pass.h
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_
15
16 #include "../common/types.h"
17 #include "./memory.h"
18 #include "./port.h"
19
20 #if defined(__cplusplus) || defined(c_plusplus)
21 extern "C" {
22 #endif
23
24 static const size_t kCompressFragmentTwoPassBlockSize = 1 << 17;
25
26 /* Compresses "input" string to the "*storage" buffer as one or more complete
27 meta-blocks, and updates the "*storage_ix" bit position.
28
29 If "is_last" is 1, emits an additional empty last meta-block.
30
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 BROTLI_INTERNAL void BrotliCompressFragmentTwoPass(MemoryManager* m,
37 const uint8_t* input,
38 size_t input_size,
39 BROTLI_BOOL is_last,
40 uint32_t* command_buf,
41 uint8_t* literal_buf,
42 int* table,
43 size_t table_size,
44 size_t* storage_ix,
45 uint8_t* storage);
46
47 #if defined(__cplusplus) || defined(c_plusplus)
48 } /* extern "C" */
49 #endif
50
51 #endif /* BROTLI_ENC_COMPRESS_FRAGMENT_TWO_PASS_H_ */