Path: blob/master/thirdparty/brotli/common/dictionary.h
21654 views
/* Copyright 2013 Google Inc. All Rights Reserved.12Distributed under MIT license.3See file LICENSE for detail or copy at https://opensource.org/licenses/MIT4*/56/* Collection of static dictionary words. */78#ifndef BROTLI_COMMON_DICTIONARY_H_9#define BROTLI_COMMON_DICTIONARY_H_1011#include "platform.h"1213#if defined(__cplusplus) || defined(c_plusplus)14extern "C" {15#endif1617typedef struct BrotliDictionary {18/**19* Number of bits to encode index of dictionary word in a bucket.20*21* Specification: Appendix A. Static Dictionary Data22*23* Words in a dictionary are bucketed by length.24* @c 0 means that there are no words of a given length.25* Dictionary consists of words with length of [4..24] bytes.26* Values at [0..3] and [25..31] indices should not be addressed.27*/28uint8_t size_bits_by_length[32];2930/* assert(offset[i + 1] == offset[i] + (bits[i] ? (i << bits[i]) : 0)) */31uint32_t offsets_by_length[32];3233/* assert(data_size == offsets_by_length[31]) */34size_t data_size;3536/* Data array is not bound, and should obey to size_bits_by_length values.37Specified size matches default (RFC 7932) dictionary. Its size is38defined by data_size */39const uint8_t* data;40} BrotliDictionary;4142BROTLI_COMMON_API const BrotliDictionary* BrotliGetDictionary(void);4344/**45* Sets dictionary data.46*47* When dictionary data is already set / present, this method is no-op.48*49* Dictionary data MUST be provided before BrotliGetDictionary is invoked.50* This method is used ONLY in multi-client environment (e.g. C + Java),51* to reduce storage by sharing single dictionary between implementations.52*/53BROTLI_COMMON_API void BrotliSetDictionaryData(const uint8_t* data);5455#define BROTLI_MIN_DICTIONARY_WORD_LENGTH 456#define BROTLI_MAX_DICTIONARY_WORD_LENGTH 245758#if defined(__cplusplus) || defined(c_plusplus)59} /* extern "C" */60#endif6162#endif /* BROTLI_COMMON_DICTIONARY_H_ */636465