wxMaxima
Loading...
Searching...
No Matches
decode.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_DEC_DECODE_H_
13#define BROTLI_DEC_DECODE_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
30
35typedef enum {
45
64#define BROTLI_DECODER_ERROR_CODES_LIST(BROTLI_ERROR_CODE, SEPARATOR) \
65 BROTLI_ERROR_CODE(_, NO_ERROR, 0) SEPARATOR \
66 /* Same as BrotliDecoderResult values */ \
67 BROTLI_ERROR_CODE(_, SUCCESS, 1) SEPARATOR \
68 BROTLI_ERROR_CODE(_, NEEDS_MORE_INPUT, 2) SEPARATOR \
69 BROTLI_ERROR_CODE(_, NEEDS_MORE_OUTPUT, 3) SEPARATOR \
70 \
71 /* Errors caused by invalid input */ \
72 BROTLI_ERROR_CODE(_ERROR_FORMAT_, EXUBERANT_NIBBLE, -1) SEPARATOR \
73 BROTLI_ERROR_CODE(_ERROR_FORMAT_, RESERVED, -2) SEPARATOR \
74 BROTLI_ERROR_CODE(_ERROR_FORMAT_, EXUBERANT_META_NIBBLE, -3) SEPARATOR \
75 BROTLI_ERROR_CODE(_ERROR_FORMAT_, SIMPLE_HUFFMAN_ALPHABET, -4) SEPARATOR \
76 BROTLI_ERROR_CODE(_ERROR_FORMAT_, SIMPLE_HUFFMAN_SAME, -5) SEPARATOR \
77 BROTLI_ERROR_CODE(_ERROR_FORMAT_, CL_SPACE, -6) SEPARATOR \
78 BROTLI_ERROR_CODE(_ERROR_FORMAT_, HUFFMAN_SPACE, -7) SEPARATOR \
79 BROTLI_ERROR_CODE(_ERROR_FORMAT_, CONTEXT_MAP_REPEAT, -8) SEPARATOR \
80 BROTLI_ERROR_CODE(_ERROR_FORMAT_, BLOCK_LENGTH_1, -9) SEPARATOR \
81 BROTLI_ERROR_CODE(_ERROR_FORMAT_, BLOCK_LENGTH_2, -10) SEPARATOR \
82 BROTLI_ERROR_CODE(_ERROR_FORMAT_, TRANSFORM, -11) SEPARATOR \
83 BROTLI_ERROR_CODE(_ERROR_FORMAT_, DICTIONARY, -12) SEPARATOR \
84 BROTLI_ERROR_CODE(_ERROR_FORMAT_, WINDOW_BITS, -13) SEPARATOR \
85 BROTLI_ERROR_CODE(_ERROR_FORMAT_, PADDING_1, -14) SEPARATOR \
86 BROTLI_ERROR_CODE(_ERROR_FORMAT_, PADDING_2, -15) SEPARATOR \
87 BROTLI_ERROR_CODE(_ERROR_FORMAT_, DISTANCE, -16) SEPARATOR \
88 \
89 /* -17 code is reserved */ \
90 \
91 BROTLI_ERROR_CODE(_ERROR_, COMPOUND_DICTIONARY, -18) SEPARATOR \
92 BROTLI_ERROR_CODE(_ERROR_, DICTIONARY_NOT_SET, -19) SEPARATOR \
93 BROTLI_ERROR_CODE(_ERROR_, INVALID_ARGUMENTS, -20) SEPARATOR \
94 \
95 /* Memory allocation problems */ \
96 BROTLI_ERROR_CODE(_ERROR_ALLOC_, CONTEXT_MODES, -21) SEPARATOR \
97 /* Literal, insert and distance trees together */ \
98 BROTLI_ERROR_CODE(_ERROR_ALLOC_, TREE_GROUPS, -22) SEPARATOR \
99 /* -23..-24 codes are reserved for distinct tree groups */ \
100 BROTLI_ERROR_CODE(_ERROR_ALLOC_, CONTEXT_MAP, -25) SEPARATOR \
101 BROTLI_ERROR_CODE(_ERROR_ALLOC_, RING_BUFFER_1, -26) SEPARATOR \
102 BROTLI_ERROR_CODE(_ERROR_ALLOC_, RING_BUFFER_2, -27) SEPARATOR \
103 /* -28..-29 codes are reserved for dynamic ring-buffer allocation */ \
104 BROTLI_ERROR_CODE(_ERROR_ALLOC_, BLOCK_TYPE_TREES, -30) SEPARATOR \
105 \
106 /* "Impossible" states */ \
107 BROTLI_ERROR_CODE(_ERROR_, UNREACHABLE, -31)
108
114typedef enum {
115#define BROTLI_COMMA_ ,
116#define BROTLI_ERROR_CODE_ENUM_ITEM_(PREFIX, NAME, CODE) \
117 BROTLI_DECODER ## PREFIX ## NAME = CODE
118 BROTLI_DECODER_ERROR_CODES_LIST(BROTLI_ERROR_CODE_ENUM_ITEM_, BROTLI_COMMA_)
120#undef BROTLI_ERROR_CODE_ENUM_ITEM_
121#undef BROTLI_COMMA_
122
130#define BROTLI_LAST_ERROR_CODE BROTLI_DECODER_ERROR_UNREACHABLE
131
146
157 BrotliDecoderState* state, BrotliDecoderParameter param, uint32_t value);
158
178 BrotliDecoderState* state, BrotliSharedDictionaryType type,
179 size_t data_size, const uint8_t data[BROTLI_ARRAY_PARAM(data_size)]);
180
200 brotli_alloc_func alloc_func, brotli_free_func free_func, void* opaque);
201
207BROTLI_DEC_API void BrotliDecoderDestroyInstance(BrotliDecoderState* state);
208
227 size_t encoded_size,
228 const uint8_t encoded_buffer[BROTLI_ARRAY_PARAM(encoded_size)],
229 size_t* decoded_size,
230 uint8_t decoded_buffer[BROTLI_ARRAY_PARAM(*decoded_size)]);
231
271 BrotliDecoderState* state, size_t* available_in, const uint8_t** next_in,
272 size_t* available_out, uint8_t** next_out, size_t* total_out);
273
282 const BrotliDecoderState* state);
283
312BROTLI_DEC_API const uint8_t* BrotliDecoderTakeOutput(
313 BrotliDecoderState* state, size_t* size);
314
325BROTLI_DEC_API BROTLI_BOOL BrotliDecoderIsUsed(const BrotliDecoderState* state);
326
336 const BrotliDecoderState* state);
337
350 const BrotliDecoderState* state);
351
355BROTLI_DEC_API const char* BrotliDecoderErrorString(BrotliDecoderErrorCode c);
356
362BROTLI_DEC_API uint32_t BrotliDecoderVersion(void);
363
374typedef void (*brotli_decoder_metadata_start_func)(void* opaque, size_t size);
375
388typedef void (*brotli_decoder_metadata_chunk_func)(void* opaque,
389 const uint8_t* data,
390 size_t size);
391
400BROTLI_DEC_API void BrotliDecoderSetMetadataCallbacks(
401 BrotliDecoderState* state,
403 brotli_decoder_metadata_chunk_func chunk_func, void* opaque);
404
405#if defined(__cplusplus) || defined(c_plusplus)
406} /* extern "C" */
407#endif
408
409#endif /* BROTLI_DEC_DECODE_H_ */
BROTLI_DEC_API uint32_t BrotliDecoderVersion(void)
Gets a decoder library version.
Definition: decode.c:2927
BROTLI_DEC_API BROTLI_BOOL BrotliDecoderAttachDictionary(BrotliDecoderState *state, BrotliSharedDictionaryType type, size_t data_size, const uint8_t data[BROTLI_ARRAY_PARAM(data_size)])
Adds LZ77 prefix dictionary, adds or replaces built-in static dictionary and transforms.
Definition: decode.c:1602
BROTLI_DEC_API const uint8_t * BrotliDecoderTakeOutput(BrotliDecoderState *state, size_t *size)
Acquires pointer to internal output buffer.
Definition: decode.c:2876
BROTLI_DEC_API BrotliDecoderState * BrotliDecoderCreateInstance(brotli_alloc_func alloc_func, brotli_free_func free_func, void *opaque)
Creates an instance of BrotliDecoderState and initializes it.
Definition: decode.c:78
BROTLI_DEC_API const char * BrotliDecoderErrorString(BrotliDecoderErrorCode c)
Converts error code to a c-string.
Definition: decode.c:2915
void(* brotli_decoder_metadata_chunk_func)(void *opaque, const uint8_t *data, size_t size)
Callback to fire on metadata block chunk becomes available.
Definition: decode.h:388
void(* brotli_decoder_metadata_start_func)(void *opaque, size_t size)
Callback to fire on metadata block start.
Definition: decode.h:374
#define BROTLI_DECODER_ERROR_CODES_LIST(BROTLI_ERROR_CODE, SEPARATOR)
Template that evaluates items of BrotliDecoderErrorCode.
Definition: decode.h:64
BROTLI_DEC_API BROTLI_BOOL BrotliDecoderHasMoreOutput(const BrotliDecoderState *state)
Checks if decoder has more output.
Definition: decode.c:2867
BrotliDecoderParameter
Options to be used with BrotliDecoderSetParameter.
Definition: decode.h:133
@ BROTLI_DECODER_PARAM_LARGE_WINDOW
Flag that determines if "Large Window Brotli" is used.
Definition: decode.h:144
@ BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION
Disable "canny" ring buffer allocation strategy.
Definition: decode.h:140
BrotliDecoderResult
Result type for BrotliDecoderDecompress and BrotliDecoderDecompressStream functions.
Definition: decode.h:35
@ BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT
Partially done; should be called again with more input.
Definition: decode.h:41
@ BROTLI_DECODER_RESULT_SUCCESS
Decoding successfully completed.
Definition: decode.h:39
@ BROTLI_DECODER_RESULT_ERROR
Decoding error, e.g.
Definition: decode.h:37
@ BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT
Partially done; should be called again with more output.
Definition: decode.h:43
BROTLI_DEC_API BrotliDecoderResult BrotliDecoderDecompress(size_t encoded_size, const uint8_t encoded_buffer[BROTLI_ARRAY_PARAM(encoded_size)], size_t *decoded_size, uint8_t decoded_buffer[BROTLI_ARRAY_PARAM(*decoded_size)])
Performs one-shot memory-to-memory decompression.
Definition: decode.c:2348
BROTLI_DEC_API BrotliDecoderResult BrotliDecoderDecompressStream(BrotliDecoderState *state, size_t *available_in, const uint8_t **next_in, size_t *available_out, uint8_t **next_out, size_t *total_out)
Decompresses the input stream to the output stream.
Definition: decode.c:2384
BROTLI_DEC_API void BrotliDecoderDestroyInstance(BrotliDecoderState *state)
Deinitializes and frees BrotliDecoderState instance.
Definition: decode.c:103
BROTLI_DEC_API BROTLI_BOOL BrotliDecoderIsFinished(const BrotliDecoderState *state)
Checks if decoder instance reached the final state.
Definition: decode.c:2906
BROTLI_DEC_API void BrotliDecoderSetMetadataCallbacks(BrotliDecoderState *state, brotli_decoder_metadata_start_func start_func, brotli_decoder_metadata_chunk_func chunk_func, void *opaque)
Sets callback for receiving metadata blocks.
Definition: decode.c:2931
BROTLI_DEC_API BROTLI_BOOL BrotliDecoderSetParameter(BrotliDecoderState *state, BrotliDecoderParameter param, uint32_t value)
Sets the specified parameter to the given decoder instance.
Definition: decode.c:62
BrotliDecoderErrorCode
Error code for detailed logging / production debugging.
Definition: decode.h:114
BROTLI_DEC_API BROTLI_BOOL BrotliDecoderIsUsed(const BrotliDecoderState *state)
Checks if instance has already consumed input.
Definition: decode.c:2901
BROTLI_DEC_API BrotliDecoderErrorCode BrotliDecoderGetErrorCode(const BrotliDecoderState *state)
Acquires a detailed error code.
Definition: decode.c:2911
Definition: state.h:254
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