1 /* Copyright 2013 Google Inc. All Rights Reserved.
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
7 http://www.apache.org/licenses/LICENSE-2.0
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
15 API for Brotli decompression
18 #ifndef BROTLI_DEC_DECODE_H_
19 #define BROTLI_DEC_DECODE_H_
21 #include "./streams.h"
24 #if defined(__cplusplus) || defined(c_plusplus)
28 /* Sets *decoded_size to the decompressed size of the given encoded stream. */
29 /* This function only works if the encoded buffer has a single meta block, */
30 /* or if it has two meta-blocks, where the first is uncompressed and the */
31 /* second is empty. */
32 /* Returns 1 on success, 0 on failure. */
33 int BrotliDecompressedSize(size_t encoded_size
,
34 const uint8_t* encoded_buffer
,
35 size_t* decoded_size
);
37 /* Decompresses the data in encoded_buffer into decoded_buffer, and sets */
38 /* *decoded_size to the decompressed length. */
39 /* Returns 0 if there was either a bit stream error or memory allocation */
40 /* error, and 1 otherwise. */
41 /* If decoded size is zero, returns 1 and keeps decoded_buffer unchanged. */
42 int BrotliDecompressBuffer(size_t encoded_size
,
43 const uint8_t* encoded_buffer
,
45 uint8_t* decoded_buffer
);
47 /* Same as above, but uses the specified input and output callbacks instead */
48 /* of reading from and writing to pre-allocated memory buffers. */
49 int BrotliDecompress(BrotliInput input
, BrotliOutput output
);
51 #if defined(__cplusplus) || defined(c_plusplus)
55 #endif /* BROTLI_DEC_DECODE_H_ */