wxMaxima
Loading...
Searching...
No Matches
encode.h
Go to the documentation of this file.
1/* Copyright 2013 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
12#ifndef BROTLI_ENC_ENCODE_H_
13#define BROTLI_ENC_ENCODE_H_
14
15#include <brotli/port.h>
16#include <brotli/shared_dictionary.h>
17#include <brotli/types.h>
18
19#if defined(__cplusplus) || defined(c_plusplus)
20extern "C" {
21#endif
22
24#define BROTLI_MIN_WINDOW_BITS 10
30#define BROTLI_MAX_WINDOW_BITS 24
35#define BROTLI_LARGE_MAX_WINDOW_BITS 30
37#define BROTLI_MIN_INPUT_BLOCK_BITS 16
39#define BROTLI_MAX_INPUT_BLOCK_BITS 24
41#define BROTLI_MIN_QUALITY 0
43#define BROTLI_MAX_QUALITY 11
44
46typedef enum BrotliEncoderMode {
59
61#define BROTLI_DEFAULT_QUALITY 11
63#define BROTLI_DEFAULT_WINDOW 22
65#define BROTLI_DEFAULT_MODE BROTLI_MODE_GENERIC
66
133
223
231
247 BrotliEncoderState* state, BrotliEncoderParameter param, uint32_t value);
248
264 brotli_alloc_func alloc_func, brotli_free_func free_func, void* opaque);
265
271BROTLI_ENC_API void BrotliEncoderDestroyInstance(BrotliEncoderState* state);
272
273/* Opaque type for pointer to different possible internal structures containing
274 dictionary prepared for the encoder */
275typedef struct BrotliEncoderPreparedDictionaryStruct
276 BrotliEncoderPreparedDictionary;
277
295BROTLI_ENC_API BrotliEncoderPreparedDictionary*
296BrotliEncoderPrepareDictionary(BrotliSharedDictionaryType type,
297 size_t data_size, const uint8_t data[BROTLI_ARRAY_PARAM(data_size)],
298 int quality,
299 brotli_alloc_func alloc_func, brotli_free_func free_func, void* opaque);
300
301BROTLI_ENC_API void BrotliEncoderDestroyPreparedDictionary(
302 BrotliEncoderPreparedDictionary* dictionary);
303
315 BrotliEncoderState* state,
316 const BrotliEncoderPreparedDictionary* dictionary);
317
328BROTLI_ENC_API size_t BrotliEncoderMaxCompressedSize(size_t input_size);
329
359 int quality, int lgwin, BrotliEncoderMode mode, size_t input_size,
360 const uint8_t input_buffer[BROTLI_ARRAY_PARAM(input_size)],
361 size_t* encoded_size,
362 uint8_t encoded_buffer[BROTLI_ARRAY_PARAM(*encoded_size)]);
363
427 BrotliEncoderState* state, BrotliEncoderOperation op, size_t* available_in,
428 const uint8_t** next_in, size_t* available_out, uint8_t** next_out,
429 size_t* total_out);
430
440
449 BrotliEncoderState* state);
450
479BROTLI_ENC_API const uint8_t* BrotliEncoderTakeOutput(
480 BrotliEncoderState* state, size_t* size);
481
482/* Returns the estimated peak memory usage (in bytes) of the BrotliCompress()
483 function, not counting the memory needed for the input and output. */
484BROTLI_ENC_EXTRA_API size_t BrotliEncoderEstimatePeakMemoryUsage(
485 int quality, int lgwin, size_t input_size);
486/* Returns 0 if dictionary is not valid; otherwise returns allocation size. */
487BROTLI_ENC_EXTRA_API size_t BrotliEncoderGetPreparedDictionarySize(
488 const BrotliEncoderPreparedDictionary* dictionary);
489
495BROTLI_ENC_API uint32_t BrotliEncoderVersion(void);
496
497#if defined(__cplusplus) || defined(c_plusplus)
498} /* extern "C" */
499#endif
500
501#endif /* BROTLI_ENC_ENCODE_H_ */
BROTLI_ENC_API BROTLI_BOOL BrotliEncoderSetParameter(BrotliEncoderState *state, BrotliEncoderParameter param, uint32_t value)
Sets the specified parameter to the given encoder instance.
Definition: encode.c:62
BROTLI_ENC_API BROTLI_BOOL BrotliEncoderHasMoreOutput(BrotliEncoderState *state)
Checks if encoder has more output.
Definition: encode.c:1688
BROTLI_ENC_API BROTLI_BOOL BrotliEncoderIsFinished(BrotliEncoderState *state)
Checks if encoder instance reached the final state.
Definition: encode.c:1683
BROTLI_ENC_API size_t BrotliEncoderMaxCompressedSize(size_t input_size)
Calculates the output size bound for the given input_size.
Definition: encode.c:1210
BROTLI_ENC_API BrotliEncoderState * BrotliEncoderCreateInstance(brotli_alloc_func alloc_func, brotli_free_func free_func, void *opaque)
Creates an instance of BrotliEncoderState and initializes it.
Definition: encode.c:749
BROTLI_ENC_API const uint8_t * BrotliEncoderTakeOutput(BrotliEncoderState *state, size_t *size)
Acquires pointer to internal output buffer.
Definition: encode.c:1692
BROTLI_ENC_API BROTLI_BOOL BrotliEncoderCompress(int quality, int lgwin, BrotliEncoderMode mode, size_t input_size, const uint8_t input_buffer[BROTLI_ARRAY_PARAM(input_size)], size_t *encoded_size, uint8_t encoded_buffer[BROTLI_ARRAY_PARAM(*encoded_size)])
Performs one-shot memory-to-memory compression.
Definition: encode.c:1255
BROTLI_ENC_API void BrotliEncoderDestroyInstance(BrotliEncoderState *state)
Deinitializes and frees BrotliEncoderState instance.
Definition: encode.c:786
BROTLI_ENC_API uint32_t BrotliEncoderVersion(void)
Gets an encoder library version.
Definition: encode.c:1711
BrotliEncoderParameter
Options to be used with BrotliEncoderSetParameter.
Definition: encode.h:135
@ BROTLI_PARAM_QUALITY
The main compression speed-density lever.
Definition: encode.h:148
@ BROTLI_PARAM_NDIRECT
Recommended number of direct distance codes (NDIRECT).
Definition: encode.h:205
@ BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING
Flag that affects usage of "literal context modeling" format feature.
Definition: encode.h:179
@ BROTLI_PARAM_STREAM_OFFSET
Number of bytes of input stream already processed by a different instance.
Definition: encode.h:221
@ BROTLI_PARAM_LARGE_WINDOW
Flag that determines if "Large Window Brotli" is used.
Definition: encode.h:189
@ BROTLI_PARAM_NPOSTFIX
Recommended number of postfix bits (NPOSTFIX).
Definition: encode.h:197
@ BROTLI_PARAM_LGBLOCK
Recommended input block size.
Definition: encode.h:173
@ BROTLI_PARAM_SIZE_HINT
Estimated total input size for all BrotliEncoderCompressStream calls.
Definition: encode.h:185
@ BROTLI_PARAM_LGWIN
Recommended sliding LZ77 window size.
Definition: encode.h:159
@ BROTLI_PARAM_MODE
Tune encoder for specific input.
Definition: encode.h:141
BrotliEncoderMode
Options for BROTLI_PARAM_MODE parameter.
Definition: encode.h:46
@ BROTLI_MODE_TEXT
Compression mode for UTF-8 formatted text input.
Definition: encode.h:55
@ BROTLI_MODE_GENERIC
Default compression mode.
Definition: encode.h:53
@ BROTLI_MODE_FONT
Compression mode used in WOFF 2.0.
Definition: encode.h:57
BROTLI_ENC_API BROTLI_BOOL BrotliEncoderCompressStream(BrotliEncoderState *state, BrotliEncoderOperation op, size_t *available_in, const uint8_t **next_in, size_t *available_out, uint8_t **next_out, size_t *total_out)
Compresses input stream to output stream.
Definition: encode.c:1593
BROTLI_ENC_API BROTLI_BOOL BrotliEncoderAttachPreparedDictionary(BrotliEncoderState *state, const BrotliEncoderPreparedDictionary *dictionary)
Attaches a prepared dictionary of any type to the encoder.
Definition: encode.c:1787
BROTLI_ENC_API BrotliEncoderPreparedDictionary * BrotliEncoderPrepareDictionary(BrotliSharedDictionaryType type, size_t data_size, const uint8_t data[BROTLI_ARRAY_PARAM(data_size)], int quality, brotli_alloc_func alloc_func, brotli_free_func free_func, void *opaque)
Prepares a shared dictionary from the given file format for the encoder.
BrotliEncoderOperation
Operations that can be performed by streaming encoder.
Definition: encode.h:68
@ BROTLI_OPERATION_FLUSH
Produce output for all processed input.
Definition: encode.h:91
@ BROTLI_OPERATION_EMIT_METADATA
Emit metadata block to stream.
Definition: encode.h:131
@ BROTLI_OPERATION_FINISH
Finalize the stream.
Definition: encode.h:110
@ BROTLI_OPERATION_PROCESS
Process input.
Definition: encode.h:74
Definition: state.h:44
Common types used in decoder and encoder API.
void *(* brotli_alloc_func)(void *opaque, size_t size)
Allocating function pointer type.
Definition: types.h:71
void(* brotli_free_func)(void *opaque, void *address)
Deallocating function pointer type.
Definition: types.h:81
#define BROTLI_BOOL
A portable bool replacement.
Definition: types.h:49