Path: blob/master/thirdparty/brotli/common/dictionary.h
9906 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 <brotli/port.h>12#include <brotli/types.h>1314#if defined(__cplusplus) || defined(c_plusplus)15extern "C" {16#endif1718typedef struct BrotliDictionary {19/**20* Number of bits to encode index of dictionary word in a bucket.21*22* Specification: Appendix A. Static Dictionary Data23*24* Words in a dictionary are bucketed by length.25* @c 0 means that there are no words of a given length.26* Dictionary consists of words with length of [4..24] bytes.27* Values at [0..3] and [25..31] indices should not be addressed.28*/29uint8_t size_bits_by_length[32];3031/* assert(offset[i + 1] == offset[i] + (bits[i] ? (i << bits[i]) : 0)) */32uint32_t offsets_by_length[32];3334/* assert(data_size == offsets_by_length[31]) */35size_t data_size;3637/* Data array is not bound, and should obey to size_bits_by_length values.38Specified size matches default (RFC 7932) dictionary. Its size is39defined by data_size */40const uint8_t* data;41} BrotliDictionary;4243BROTLI_COMMON_API const BrotliDictionary* BrotliGetDictionary(void);4445/**46* Sets dictionary data.47*48* When dictionary data is already set / present, this method is no-op.49*50* Dictionary data MUST be provided before BrotliGetDictionary is invoked.51* This method is used ONLY in multi-client environment (e.g. C + Java),52* to reduce storage by sharing single dictionary between implementations.53*/54BROTLI_COMMON_API void BrotliSetDictionaryData(const uint8_t* data);5556#define BROTLI_MIN_DICTIONARY_WORD_LENGTH 457#define BROTLI_MAX_DICTIONARY_WORD_LENGTH 245859#if defined(__cplusplus) || defined(c_plusplus)60} /* extern "C" */61#endif6263#endif /* BROTLI_COMMON_DICTIONARY_H_ */646566