]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/C/BrotliCompress/enc/compress_fragment.h
BaseTools: Copy Brotli algorithm 3rd party source code for tool
[mirror_edk2.git] / BaseTools / Source / C / BrotliCompress / enc / compress_fragment.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 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_
14
15 #include "../common/types.h"
16 #include "./memory.h"
17 #include "./port.h"
18
19 #if defined(__cplusplus) || defined(c_plusplus)
20 extern "C" {
21 #endif
22
23 /* Compresses "input" string to the "*storage" buffer as one or more complete
24 meta-blocks, and updates the "*storage_ix" bit position.
25
26 If "is_last" is 1, emits an additional empty last meta-block.
27
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 a power of two */
42 BROTLI_INTERNAL void BrotliCompressFragmentFast(MemoryManager* m,
43 const uint8_t* input,
44 size_t input_size,
45 BROTLI_BOOL is_last,
46 int* table, size_t table_size,
47 uint8_t cmd_depth[128],
48 uint16_t cmd_bits[128],
49 size_t* cmd_code_numbits,
50 uint8_t* cmd_code,
51 size_t* storage_ix,
52 uint8_t* storage);
53
54 #if defined(__cplusplus) || defined(c_plusplus)
55 } /* extern "C" */
56 #endif
57
58 #endif /* BROTLI_ENC_COMPRESS_FRAGMENT_H_ */