Add "use_brotli" flag

- brotli compression of metadata will be optional, so a flag is added to both encoder and decoder
- precomp will pass the flag to Brunsli[Decode/Encode]Jpeg
This commit is contained in:
Christian Schneider 2019-10-22 12:07:44 +02:00
parent a4e06aafdf
commit 006a5849b1
4 changed files with 9 additions and 2 deletions

View file

@ -1394,12 +1394,13 @@ BrunsliStatus ProcessJpeg(State* state, JPEGData* jpg) {
} // namespace internal
BrunsliStatus BrunsliDecodeJpeg(const uint8_t* data, const size_t len,
JPEGData* jpg) {
JPEGData* jpg, bool use_brotli) {
if (!data) return BRUNSLI_INVALID_PARAM;
State state;
state.data = data;
state.len = len;
state.use_brotli = use_brotli;
return internal::dec::ProcessJpeg(&state, jpg);
}

View file

@ -81,6 +81,8 @@ struct State {
bool shallow_histograms = false;
size_t num_contexts = 0;
size_t num_histograms = 0;
bool use_brotli;
};
// Use in "headerless" mode, after jpg is filled, but before decoding.

View file

@ -1371,8 +1371,10 @@ bool BrunsliSerialize(State* state, const JPEGData& jpg, uint32_t skip_sections,
*
* For "groups" workflow, few more stages are required, see comments.
*/
bool BrunsliEncodeJpeg(const JPEGData& jpg, uint8_t* data, size_t* len) {
bool BrunsliEncodeJpeg(const JPEGData& jpg, uint8_t* data, size_t* len, bool use_brotli) {
State state;
state.use_brotli = use_brotli;
std::vector<ComponentMeta>& meta = state.meta;
size_t num_components = jpg.components.size();

View file

@ -136,6 +136,8 @@ struct State {
std::vector<ComponentMeta> meta;
size_t num_contexts;
bool use_brotli;
};
// Encoder workflow: