1 // Copyright 2021 The ChromiumOS Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef SRC_INCLUDE_PUFFIN_BROTLI_UTIL_H_ 6 #define SRC_INCLUDE_PUFFIN_BROTLI_UTIL_H_ 7 8 #include <stdint.h> 9 10 #include <vector> 11 12 #include "puffin/stream.h" 13 14 namespace puffin { 15 16 // Use brotli to compress |input_size| bytes of data, and write the result to 17 // |output_stream|. 18 bool BrotliEncode(const uint8_t* input, 19 size_t input_size, 20 UniqueStreamPtr output_stream); 21 // Similar to above function, and writes to a output buffer. 22 bool BrotliEncode(const uint8_t* input, 23 size_t input_size, 24 std::vector<uint8_t>* output); 25 26 // Similar to the above, but quality controls how well the compression is 27 // |quality| should be between 0 and 11 28 bool BrotliEncode(const uint8_t* input, 29 size_t input_size, 30 UniqueStreamPtr output_stream, 31 int quality); 32 33 // Decompress |input_size| bytes of data with brotli, and write the result to 34 // |output_stream|. 35 bool BrotliDecode(const uint8_t* input, 36 size_t input_size, 37 UniqueStreamPtr output_stream); 38 // Similar to above function, and writes to a output buffer. 39 bool BrotliDecode(const uint8_t* input, 40 size_t input_size, 41 std::vector<uint8_t>* output); 42 } // namespace puffin 43 44 #endif // SRC_INCLUDE_PUFFIN_BROTLI_UTIL_H_ 45