-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge-in SharedDictionary feature (#916)
Co-authored-by: Eugene Kliuchnikov <eustas@chromium.org>
- Loading branch information
Showing
37 changed files
with
3,066 additions
and
38 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* Copyright 2017 Google Inc. All Rights Reserved. | ||
Distributed under MIT license. | ||
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT | ||
*/ | ||
|
||
/* (Transparent) Shared Dictionary definition. */ | ||
|
||
#ifndef BROTLI_COMMON_SHARED_DICTIONARY_INTERNAL_H_ | ||
#define BROTLI_COMMON_SHARED_DICTIONARY_INTERNAL_H_ | ||
|
||
#include "./dictionary.h" | ||
#include <brotli/shared_dictionary.h> | ||
#include "./transform.h" | ||
#include <brotli/types.h> | ||
|
||
#if defined(__cplusplus) || defined(c_plusplus) | ||
extern "C" { | ||
#endif | ||
|
||
struct BrotliSharedDictionaryStruct { | ||
/* LZ77 prefixes (compound dictionary). */ | ||
uint32_t num_prefix; /* max SHARED_BROTLI_MAX_COMPOUND_DICTS */ | ||
size_t prefix_size[SHARED_BROTLI_MAX_COMPOUND_DICTS]; | ||
const uint8_t* prefix[SHARED_BROTLI_MAX_COMPOUND_DICTS]; | ||
|
||
/* If set, the context map is used to select word and transform list from 64 | ||
contexts, if not set, the context map is not used and only words[0] and | ||
transforms[0] are to be used. */ | ||
BROTLI_BOOL context_based; | ||
|
||
uint8_t context_map[SHARED_BROTLI_NUM_DICTIONARY_CONTEXTS]; | ||
|
||
/* Amount of word_list+transform_list combinations. */ | ||
uint8_t num_dictionaries; | ||
|
||
/* Must use num_dictionaries values. */ | ||
const BrotliDictionary* words[SHARED_BROTLI_NUM_DICTIONARY_CONTEXTS]; | ||
|
||
/* Must use num_dictionaries values. */ | ||
const BrotliTransforms* transforms[SHARED_BROTLI_NUM_DICTIONARY_CONTEXTS]; | ||
|
||
/* Amount of custom word lists. May be 0 if only Brotli's built-in is used */ | ||
uint8_t num_word_lists; | ||
|
||
/* Contents of the custom words lists. Must be NULL if num_word_lists is 0. */ | ||
BrotliDictionary* words_instances; | ||
|
||
/* Amount of custom transform lists. May be 0 if only Brotli's built-in is | ||
used */ | ||
uint8_t num_transform_lists; | ||
|
||
/* Contents of the custom transform lists. Must be NULL if num_transform_lists | ||
is 0. */ | ||
BrotliTransforms* transforms_instances; | ||
|
||
/* Concatenated prefix_suffix_maps of the custom transform lists. Must be NULL | ||
if num_transform_lists is 0. */ | ||
uint16_t* prefix_suffix_maps; | ||
|
||
/* Memory management */ | ||
brotli_alloc_func alloc_func; | ||
brotli_free_func free_func; | ||
void* memory_manager_opaque; | ||
}; | ||
|
||
typedef struct BrotliSharedDictionaryStruct BrotliSharedDictionaryInternal; | ||
#define BrotliSharedDictionary BrotliSharedDictionaryInternal | ||
|
||
#if defined(__cplusplus) || defined(c_plusplus) | ||
} /* extern "C" */ | ||
#endif | ||
|
||
#endif /* BROTLI_COMMON_SHARED_DICTIONARY_INTERNAL_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
19d86fb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When
BrotliDecoderAttachDictionary
andBrotliEncoderPrepareDictionary
were added in the above, a.h
vs..c
VLA vs. pointer usage mismatch was added but has not been fixed. Looks like checking for this might be a good idea if there is a reasonable way to do so. (There have been past mismatches that were later fixed.)See: #893 for an example that was applied: 0a3944c .
Looks like #929 ( 27dd726 ) is a pull request for the specifics here.