]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/C/BrotliCompress/include/brotli/encode.h
BaseTools: Make brotli a submodule
[mirror_edk2.git] / BaseTools / Source / C / BrotliCompress / include / brotli / encode.h
diff --git a/BaseTools/Source/C/BrotliCompress/include/brotli/encode.h b/BaseTools/Source/C/BrotliCompress/include/brotli/encode.h
deleted file mode 100644 (file)
index b26fa42..0000000
+++ /dev/null
@@ -1,427 +0,0 @@
-/* Copyright 2013 Google Inc. All Rights Reserved.\r
-\r
-   Distributed under MIT license.\r
-   See file LICENSE for detail or copy at https://opensource.org/licenses/MIT\r
-*/\r
-\r
-/**\r
- * @file\r
- * API for Brotli compression.\r
- */\r
-\r
-#ifndef BROTLI_ENC_ENCODE_H_\r
-#define BROTLI_ENC_ENCODE_H_\r
-\r
-#include <brotli/port.h>\r
-#include <brotli/types.h>\r
-\r
-#if defined(__cplusplus) || defined(c_plusplus)\r
-extern "C" {\r
-#endif\r
-\r
-/** Minimal value for ::BROTLI_PARAM_LGWIN parameter. */\r
-#define BROTLI_MIN_WINDOW_BITS 10\r
-/**\r
- * Maximal value for ::BROTLI_PARAM_LGWIN parameter.\r
- *\r
- * @note equal to @c BROTLI_MAX_DISTANCE_BITS constant.\r
- */\r
-#define BROTLI_MAX_WINDOW_BITS 24\r
-/**\r
- * Maximal value for ::BROTLI_PARAM_LGWIN parameter\r
- * in "Large Window Brotli" (32-bit).\r
- */\r
-#define BROTLI_LARGE_MAX_WINDOW_BITS 30\r
-/** Minimal value for ::BROTLI_PARAM_LGBLOCK parameter. */\r
-#define BROTLI_MIN_INPUT_BLOCK_BITS 16\r
-/** Maximal value for ::BROTLI_PARAM_LGBLOCK parameter. */\r
-#define BROTLI_MAX_INPUT_BLOCK_BITS 24\r
-/** Minimal value for ::BROTLI_PARAM_QUALITY parameter. */\r
-#define BROTLI_MIN_QUALITY 0\r
-/** Maximal value for ::BROTLI_PARAM_QUALITY parameter. */\r
-#define BROTLI_MAX_QUALITY 11\r
-\r
-/** Options for ::BROTLI_PARAM_MODE parameter. */\r
-typedef enum BrotliEncoderMode {\r
-  /**\r
-   * Default compression mode.\r
-   *\r
-   * In this mode compressor does not know anything in advance about the\r
-   * properties of the input.\r
-   */\r
-  BROTLI_MODE_GENERIC = 0,\r
-  /** Compression mode for UTF-8 formatted text input. */\r
-  BROTLI_MODE_TEXT = 1,\r
-  /** Compression mode used in WOFF 2.0. */\r
-  BROTLI_MODE_FONT = 2\r
-} BrotliEncoderMode;\r
-\r
-/** Default value for ::BROTLI_PARAM_QUALITY parameter. */\r
-#define BROTLI_DEFAULT_QUALITY 11\r
-/** Default value for ::BROTLI_PARAM_LGWIN parameter. */\r
-#define BROTLI_DEFAULT_WINDOW 22\r
-/** Default value for ::BROTLI_PARAM_MODE parameter. */\r
-#define BROTLI_DEFAULT_MODE BROTLI_MODE_GENERIC\r
-\r
-/** Operations that can be performed by streaming encoder. */\r
-typedef enum BrotliEncoderOperation {\r
-  /**\r
-   * Process input.\r
-   *\r
-   * Encoder may postpone producing output, until it has processed enough input.\r
-   */\r
-  BROTLI_OPERATION_PROCESS = 0,\r
-  /**\r
-   * Produce output for all processed input.\r
-   *\r
-   * Actual flush is performed when input stream is depleted and there is enough\r
-   * space in output stream. This means that client should repeat\r
-   * ::BROTLI_OPERATION_FLUSH operation until @p available_in becomes @c 0, and\r
-   * ::BrotliEncoderHasMoreOutput returns ::BROTLI_FALSE. If output is acquired\r
-   * via ::BrotliEncoderTakeOutput, then operation should be repeated after\r
-   * output buffer is drained.\r
-   *\r
-   * @warning Until flush is complete, client @b SHOULD @b NOT swap,\r
-   *          reduce or extend input stream.\r
-   *\r
-   * When flush is complete, output data will be sufficient for decoder to\r
-   * reproduce all the given input.\r
-   */\r
-  BROTLI_OPERATION_FLUSH = 1,\r
-  /**\r
-   * Finalize the stream.\r
-   *\r
-   * Actual finalization is performed when input stream is depleted and there is\r
-   * enough space in output stream. This means that client should repeat\r
-   * ::BROTLI_OPERATION_FINISH operation until @p available_in becomes @c 0, and\r
-   * ::BrotliEncoderHasMoreOutput returns ::BROTLI_FALSE. If output is acquired\r
-   * via ::BrotliEncoderTakeOutput, then operation should be repeated after\r
-   * output buffer is drained.\r
-   *\r
-   * @warning Until finalization is complete, client @b SHOULD @b NOT swap,\r
-   *          reduce or extend input stream.\r
-   *\r
-   * Helper function ::BrotliEncoderIsFinished checks if stream is finalized and\r
-   * output fully dumped.\r
-   *\r
-   * Adding more input data to finalized stream is impossible.\r
-   */\r
-  BROTLI_OPERATION_FINISH = 2,\r
-  /**\r
-   * Emit metadata block to stream.\r
-   *\r
-   * Metadata is opaque to Brotli: neither encoder, nor decoder processes this\r
-   * data or relies on it. It may be used to pass some extra information from\r
-   * encoder client to decoder client without interfering with main data stream.\r
-   *\r
-   * @note Encoder may emit empty metadata blocks internally, to pad encoded\r
-   *       stream to byte boundary.\r
-   *\r
-   * @warning Until emitting metadata is complete client @b SHOULD @b NOT swap,\r
-   *          reduce or extend input stream.\r
-   *\r
-   * @warning The whole content of input buffer is considered to be the content\r
-   *          of metadata block. Do @b NOT @e append metadata to input stream,\r
-   *          before it is depleted with other operations.\r
-   *\r
-   * Stream is soft-flushed before metadata block is emitted. Metadata block\r
-   * @b MUST be no longer than than 16MiB.\r
-   */\r
-  BROTLI_OPERATION_EMIT_METADATA = 3\r
-} BrotliEncoderOperation;\r
-\r
-/** Options to be used with ::BrotliEncoderSetParameter. */\r
-typedef enum BrotliEncoderParameter {\r
-  /**\r
-   * Tune encoder for specific input.\r
-   *\r
-   * ::BrotliEncoderMode enumerates all available values.\r
-   */\r
-  BROTLI_PARAM_MODE = 0,\r
-  /**\r
-   * The main compression speed-density lever.\r
-   *\r
-   * The higher the quality, the slower the compression. Range is\r
-   * from ::BROTLI_MIN_QUALITY to ::BROTLI_MAX_QUALITY.\r
-   */\r
-  BROTLI_PARAM_QUALITY = 1,\r
-  /**\r
-   * Recommended sliding LZ77 window size.\r
-   *\r
-   * Encoder may reduce this value, e.g. if input is much smaller than\r
-   * window size.\r
-   *\r
-   * Window size is `(1 << value) - 16`.\r
-   *\r
-   * Range is from ::BROTLI_MIN_WINDOW_BITS to ::BROTLI_MAX_WINDOW_BITS.\r
-   */\r
-  BROTLI_PARAM_LGWIN = 2,\r
-  /**\r
-   * Recommended input block size.\r
-   *\r
-   * Encoder may reduce this value, e.g. if input is much smaller than input\r
-   * block size.\r
-   *\r
-   * Range is from ::BROTLI_MIN_INPUT_BLOCK_BITS to\r
-   * ::BROTLI_MAX_INPUT_BLOCK_BITS.\r
-   *\r
-   * @note Bigger input block size allows better compression, but consumes more\r
-   *       memory. \n The rough formula of memory used for temporary input\r
-   *       storage is `3 << lgBlock`.\r
-   */\r
-  BROTLI_PARAM_LGBLOCK = 3,\r
-  /**\r
-   * Flag that affects usage of "literal context modeling" format feature.\r
-   *\r
-   * This flag is a "decoding-speed vs compression ratio" trade-off.\r
-   */\r
-  BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING = 4,\r
-  /**\r
-   * Estimated total input size for all ::BrotliEncoderCompressStream calls.\r
-   *\r
-   * The default value is 0, which means that the total input size is unknown.\r
-   */\r
-  BROTLI_PARAM_SIZE_HINT = 5,\r
-  /**\r
-   * Flag that determines if "Large Window Brotli" is used.\r
-   */\r
-  BROTLI_PARAM_LARGE_WINDOW = 6,\r
-  /**\r
-   * Recommended number of postfix bits (NPOSTFIX).\r
-   *\r
-   * Encoder may change this value.\r
-   *\r
-   * Range is from 0 to ::BROTLI_MAX_NPOSTFIX.\r
-   */\r
-  BROTLI_PARAM_NPOSTFIX = 7,\r
-  /**\r
-   * Recommended number of direct distance codes (NDIRECT).\r
-   *\r
-   * Encoder may change this value.\r
-   *\r
-   * Range is from 0 to (15 << NPOSTFIX) in steps of (1 << NPOSTFIX).\r
-   */\r
-  BROTLI_PARAM_NDIRECT = 8\r
-} BrotliEncoderParameter;\r
-\r
-/**\r
- * Opaque structure that holds encoder state.\r
- *\r
- * Allocated and initialized with ::BrotliEncoderCreateInstance.\r
- * Cleaned up and deallocated with ::BrotliEncoderDestroyInstance.\r
- */\r
-typedef struct BrotliEncoderStateStruct BrotliEncoderState;\r
-\r
-/**\r
- * Sets the specified parameter to the given encoder instance.\r
- *\r
- * @param state encoder instance\r
- * @param param parameter to set\r
- * @param value new parameter value\r
- * @returns ::BROTLI_FALSE if parameter is unrecognized, or value is invalid\r
- * @returns ::BROTLI_FALSE if value of parameter can not be changed at current\r
- *          encoder state (e.g. when encoding is started, window size might be\r
- *          already encoded and therefore it is impossible to change it)\r
- * @returns ::BROTLI_TRUE if value is accepted\r
- * @warning invalid values might be accepted in case they would not break\r
- *          encoding process.\r
- */\r
-BROTLI_ENC_API BROTLI_BOOL BrotliEncoderSetParameter(\r
-    BrotliEncoderState* state, BrotliEncoderParameter param, uint32_t value);\r
-\r
-/**\r
- * Creates an instance of ::BrotliEncoderState and initializes it.\r
- *\r
- * @p alloc_func and @p free_func @b MUST be both zero or both non-zero. In the\r
- * case they are both zero, default memory allocators are used. @p opaque is\r
- * passed to @p alloc_func and @p free_func when they are called. @p free_func\r
- * has to return without doing anything when asked to free a NULL pointer.\r
- *\r
- * @param alloc_func custom memory allocation function\r
- * @param free_func custom memory free function\r
- * @param opaque custom memory manager handle\r
- * @returns @c 0 if instance can not be allocated or initialized\r
- * @returns pointer to initialized ::BrotliEncoderState otherwise\r
- */\r
-BROTLI_ENC_API BrotliEncoderState* BrotliEncoderCreateInstance(\r
-    brotli_alloc_func alloc_func, brotli_free_func free_func, void* opaque);\r
-\r
-/**\r
- * Deinitializes and frees ::BrotliEncoderState instance.\r
- *\r
- * @param state decoder instance to be cleaned up and deallocated\r
- */\r
-BROTLI_ENC_API void BrotliEncoderDestroyInstance(BrotliEncoderState* state);\r
-\r
-/**\r
- * Calculates the output size bound for the given @p input_size.\r
- *\r
- * @warning Result is only valid if quality is at least @c 2 and, in\r
- *          case ::BrotliEncoderCompressStream was used, no flushes\r
- *          (::BROTLI_OPERATION_FLUSH) were performed.\r
- *\r
- * @param input_size size of projected input\r
- * @returns @c 0 if result does not fit @c size_t\r
- */\r
-BROTLI_ENC_API size_t BrotliEncoderMaxCompressedSize(size_t input_size);\r
-\r
-/**\r
- * Performs one-shot memory-to-memory compression.\r
- *\r
- * Compresses the data in @p input_buffer into @p encoded_buffer, and sets\r
- * @p *encoded_size to the compressed length.\r
- *\r
- * @note If ::BrotliEncoderMaxCompressedSize(@p input_size) returns non-zero\r
- *       value, then output is guaranteed to be no longer than that.\r
- *\r
- * @param quality quality parameter value, e.g. ::BROTLI_DEFAULT_QUALITY\r
- * @param lgwin lgwin parameter value, e.g. ::BROTLI_DEFAULT_WINDOW\r
- * @param mode mode parameter value, e.g. ::BROTLI_DEFAULT_MODE\r
- * @param input_size size of @p input_buffer\r
- * @param input_buffer input data buffer with at least @p input_size\r
- *        addressable bytes\r
- * @param[in, out] encoded_size @b in: size of @p encoded_buffer; \n\r
- *                 @b out: length of compressed data written to\r
- *                 @p encoded_buffer, or @c 0 if compression fails\r
- * @param encoded_buffer compressed data destination buffer\r
- * @returns ::BROTLI_FALSE in case of compression error\r
- * @returns ::BROTLI_FALSE if output buffer is too small\r
- * @returns ::BROTLI_TRUE otherwise\r
- */\r
-BROTLI_ENC_API BROTLI_BOOL BrotliEncoderCompress(\r
-    int quality, int lgwin, BrotliEncoderMode mode, size_t input_size,\r
-    const uint8_t input_buffer[BROTLI_ARRAY_PARAM(input_size)],\r
-    size_t* encoded_size,\r
-    uint8_t encoded_buffer[BROTLI_ARRAY_PARAM(*encoded_size)]);\r
-\r
-/**\r
- * Compresses input stream to output stream.\r
- *\r
- * The values @p *available_in and @p *available_out must specify the number of\r
- * bytes addressable at @p *next_in and @p *next_out respectively.\r
- * When @p *available_out is @c 0, @p next_out is allowed to be @c NULL.\r
- *\r
- * After each call, @p *available_in will be decremented by the amount of input\r
- * bytes consumed, and the @p *next_in pointer will be incremented by that\r
- * amount. Similarly, @p *available_out will be decremented by the amount of\r
- * output bytes written, and the @p *next_out pointer will be incremented by\r
- * that amount.\r
- *\r
- * @p total_out, if it is not a null-pointer, will be set to the number\r
- * of bytes compressed since the last @p state initialization.\r
- *\r
- *\r
- *\r
- * Internally workflow consists of 3 tasks:\r
- *  -# (optionally) copy input data to internal buffer\r
- *  -# actually compress data and (optionally) store it to internal buffer\r
- *  -# (optionally) copy compressed bytes from internal buffer to output stream\r
- *\r
- * Whenever all 3 tasks can't move forward anymore, or error occurs, this\r
- * method returns the control flow to caller.\r
- *\r
- * @p op is used to perform flush, finish the stream, or inject metadata block.\r
- * See ::BrotliEncoderOperation for more information.\r
- *\r
- * Flushing the stream means forcing encoding of all input passed to encoder and\r
- * completing the current output block, so it could be fully decoded by stream\r
- * decoder. To perform flush set @p op to ::BROTLI_OPERATION_FLUSH.\r
- * Under some circumstances (e.g. lack of output stream capacity) this operation\r
- * would require several calls to ::BrotliEncoderCompressStream. The method must\r
- * be called again until both input stream is depleted and encoder has no more\r
- * output (see ::BrotliEncoderHasMoreOutput) after the method is called.\r
- *\r
- * Finishing the stream means encoding of all input passed to encoder and\r
- * adding specific "final" marks, so stream decoder could determine that stream\r
- * is complete. To perform finish set @p op to ::BROTLI_OPERATION_FINISH.\r
- * Under some circumstances (e.g. lack of output stream capacity) this operation\r
- * would require several calls to ::BrotliEncoderCompressStream. The method must\r
- * be called again until both input stream is depleted and encoder has no more\r
- * output (see ::BrotliEncoderHasMoreOutput) after the method is called.\r
- *\r
- * @warning When flushing and finishing, @p op should not change until operation\r
- *          is complete; input stream should not be swapped, reduced or\r
- *          extended as well.\r
- *\r
- * @param state encoder instance\r
- * @param op requested operation\r
- * @param[in, out] available_in @b in: amount of available input; \n\r
- *                 @b out: amount of unused input\r
- * @param[in, out] next_in pointer to the next input byte\r
- * @param[in, out] available_out @b in: length of output buffer; \n\r
- *                 @b out: remaining size of output buffer\r
- * @param[in, out] next_out compressed output buffer cursor;\r
- *                 can be @c NULL if @p available_out is @c 0\r
- * @param[out] total_out number of bytes produced so far; can be @c NULL\r
- * @returns ::BROTLI_FALSE if there was an error\r
- * @returns ::BROTLI_TRUE otherwise\r
- */\r
-BROTLI_ENC_API BROTLI_BOOL BrotliEncoderCompressStream(\r
-    BrotliEncoderState* state, BrotliEncoderOperation op, size_t* available_in,\r
-    const uint8_t** next_in, size_t* available_out, uint8_t** next_out,\r
-    size_t* total_out);\r
-\r
-/**\r
- * Checks if encoder instance reached the final state.\r
- *\r
- * @param state encoder instance\r
- * @returns ::BROTLI_TRUE if encoder is in a state where it reached the end of\r
- *          the input and produced all of the output\r
- * @returns ::BROTLI_FALSE otherwise\r
- */\r
-BROTLI_ENC_API BROTLI_BOOL BrotliEncoderIsFinished(BrotliEncoderState* state);\r
-\r
-/**\r
- * Checks if encoder has more output.\r
- *\r
- * @param state encoder instance\r
- * @returns ::BROTLI_TRUE, if encoder has some unconsumed output\r
- * @returns ::BROTLI_FALSE otherwise\r
- */\r
-BROTLI_ENC_API BROTLI_BOOL BrotliEncoderHasMoreOutput(\r
-    BrotliEncoderState* state);\r
-\r
-/**\r
- * Acquires pointer to internal output buffer.\r
- *\r
- * This method is used to make language bindings easier and more efficient:\r
- *  -# push data to ::BrotliEncoderCompressStream,\r
- *     until ::BrotliEncoderHasMoreOutput returns BROTL_TRUE\r
- *  -# use ::BrotliEncoderTakeOutput to peek bytes and copy to language-specific\r
- *     entity\r
- *\r
- * Also this could be useful if there is an output stream that is able to\r
- * consume all the provided data (e.g. when data is saved to file system).\r
- *\r
- * @attention After every call to ::BrotliEncoderTakeOutput @p *size bytes of\r
- *            output are considered consumed for all consecutive calls to the\r
- *            instance methods; returned pointer becomes invalidated as well.\r
- *\r
- * @note Encoder output is not guaranteed to be contiguous. This means that\r
- *       after the size-unrestricted call to ::BrotliEncoderTakeOutput,\r
- *       immediate next call to ::BrotliEncoderTakeOutput may return more data.\r
- *\r
- * @param state encoder instance\r
- * @param[in, out] size @b in: number of bytes caller is ready to take, @c 0 if\r
- *                 any amount could be handled; \n\r
- *                 @b out: amount of data pointed by returned pointer and\r
- *                 considered consumed; \n\r
- *                 out value is never greater than in value, unless it is @c 0\r
- * @returns pointer to output data\r
- */\r
-BROTLI_ENC_API const uint8_t* BrotliEncoderTakeOutput(\r
-    BrotliEncoderState* state, size_t* size);\r
-\r
-\r
-/**\r
- * Gets an encoder library version.\r
- *\r
- * Look at BROTLI_VERSION for more information.\r
- */\r
-BROTLI_ENC_API uint32_t BrotliEncoderVersion(void);\r
-\r
-#if defined(__cplusplus) || defined(c_plusplus)\r
-}  /* extern "C" */\r
-#endif\r
-\r
-#endif  /* BROTLI_ENC_ENCODE_H_ */\r