aboutsummaryrefslogtreecommitdiff
path: root/enc/compress_fragment.h
diff options
context:
space:
mode:
authorZoltan Szabadka <szabadka@google.com>2016-01-11 11:21:42 +0100
committerZoltan Szabadka <szabadka@google.com>2016-01-11 11:21:42 +0100
commit417107b3ddb04cfd4ddfa7592fed0eb886186281 (patch)
treeb74051dd367e28ec1de7a89419d6a9608567b157 /enc/compress_fragment.h
parent27688e605cef6f023c6f8ed199344f993b67254c (diff)
downloadbrotli-417107b3ddb04cfd4ddfa7592fed0eb886186281.zip
brotli-417107b3ddb04cfd4ddfa7592fed0eb886186281.tar.gz
brotli-417107b3ddb04cfd4ddfa7592fed0eb886186281.tar.bz2
Add two more fast modes to the brotli compressor.
The new modes process the input data in independent blocks, using backward references only from within an input block. The new modes can be used by specifying quality 0 or quality 1, the old quality 1 and quality 2 modes are renamed quality 2 and quality 3, respectively, and the old quality 3 mode is removed.
Diffstat (limited to 'enc/compress_fragment.h')
-rw-r--r--enc/compress_fragment.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/enc/compress_fragment.h b/enc/compress_fragment.h
new file mode 100644
index 0000000..7ce05fd
--- /dev/null
+++ b/enc/compress_fragment.h
@@ -0,0 +1,47 @@
+/* Copyright 2015 Google Inc. All Rights Reserved.
+
+ Distributed under MIT license.
+ See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
+*/
+
+// Function for fast encoding of an input fragment, independently from the input
+// history. This function uses one-pass processing: when we find a backward
+// match, we immediately emit the corresponding command and literal codes to
+// the bit stream.
+
+#ifndef BROTLI_ENC_COMPRESS_FRAGMENT_H_
+#define BROTLI_ENC_COMPRESS_FRAGMENT_H_
+
+#include "./types.h"
+
+namespace brotli {
+
+// Compresses "input" string to the "*storage" buffer as one or more complete
+// meta-blocks, and updates the "*storage_ix" bit position.
+//
+// If "is_last" is true, emits an additional empty last meta-block.
+//
+// "cmd_depth" and "cmd_bits" contain the command and distance prefix codes
+// (see comment in encode.h) used for the encoding of this input fragment.
+// If "is_last" is false, they are updated to reflect the statistics
+// of this input fragment, to be used for the encoding of the next fragment.
+//
+// "*cmd_code_numbits" is the number of bits of the compressed representation
+// of the command and distance prefix codes, and "cmd_code" is an array of
+// at least "(*cmd_code_numbits + 7) >> 3" size that contains the compressed
+// command and distance prefix codes. If "is_last" is false, these are also
+// updated to represent the updated "cmd_depth" and "cmd_bits".
+//
+// REQUIRES: "input_size" is greater than zero, or "is_last" is true.
+// REQUIRES: All elements in "table[0..table_size-1]" are initialized to zero.
+// REQUIRES: "table_size" is a power of two
+void BrotliCompressFragmentFast(const uint8_t* input, size_t input_size,
+ bool is_last,
+ int* table, size_t table_size,
+ uint8_t cmd_depth[128], uint16_t cmd_bits[128],
+ size_t* cmd_code_numbits, uint8_t* cmd_code,
+ size_t* storage_ix, uint8_t* storage);
+
+} // namespace brotli
+
+#endif // BROTLI_ENC_COMPRESS_FRAGMENT_H_