12#ifndef BROTLI_COMMON_CONSTANTS_H_
13#define BROTLI_COMMON_CONSTANTS_H_
16#include <brotli/port.h>
17#include <brotli/types.h>
20#define BROTLI_CONTEXT_MAP_MAX_RLE 16
23#define BROTLI_MAX_NUMBER_OF_BLOCK_TYPES 256
26#define BROTLI_NUM_LITERAL_SYMBOLS 256
27#define BROTLI_NUM_COMMAND_SYMBOLS 704
28#define BROTLI_NUM_BLOCK_LEN_SYMBOLS 26
29#define BROTLI_MAX_CONTEXT_MAP_SYMBOLS (BROTLI_MAX_NUMBER_OF_BLOCK_TYPES + \
30 BROTLI_CONTEXT_MAP_MAX_RLE)
31#define BROTLI_MAX_BLOCK_TYPE_SYMBOLS (BROTLI_MAX_NUMBER_OF_BLOCK_TYPES + 2)
34#define BROTLI_REPEAT_PREVIOUS_CODE_LENGTH 16
35#define BROTLI_REPEAT_ZERO_CODE_LENGTH 17
36#define BROTLI_CODE_LENGTH_CODES (BROTLI_REPEAT_ZERO_CODE_LENGTH + 1)
38#define BROTLI_INITIAL_REPEATED_CODE_LENGTH 8
50#define BROTLI_LARGE_MAX_DISTANCE_BITS 62U
51#define BROTLI_LARGE_MIN_WBITS 10
57#define BROTLI_LARGE_MAX_WBITS 30
60#define BROTLI_NUM_DISTANCE_SHORT_CODES 16
66#define BROTLI_MAX_NPOSTFIX 3
67#define BROTLI_MAX_NDIRECT 120
68#define BROTLI_MAX_DISTANCE_BITS 24U
69#define BROTLI_DISTANCE_ALPHABET_SIZE(NPOSTFIX, NDIRECT, MAXNBITS) ( \
70 BROTLI_NUM_DISTANCE_SHORT_CODES + (NDIRECT) + \
71 ((MAXNBITS) << ((NPOSTFIX) + 1)))
73#define BROTLI_NUM_DISTANCE_SYMBOLS \
74 BROTLI_DISTANCE_ALPHABET_SIZE( \
75 BROTLI_MAX_NDIRECT, BROTLI_MAX_NPOSTFIX, BROTLI_LARGE_MAX_DISTANCE_BITS)
80#define BROTLI_MAX_DISTANCE 0x3FFFFFC
86#define BROTLI_MAX_ALLOWED_DISTANCE 0x7FFFFFFC
90#define BROTLI_NUM_INS_COPY_CODES 24
94#define BROTLI_LITERAL_CONTEXT_BITS 6
97#define BROTLI_DISTANCE_CONTEXT_BITS 2
102#define BROTLI_WINDOW_GAP 16
103#define BROTLI_MAX_BACKWARD_LIMIT(W) (((size_t)1 << (W)) - BROTLI_WINDOW_GAP)
128 uint32_t max_distance, uint32_t npostfix, uint32_t ndirect) {
133 if (max_distance <= ndirect) {
140 uint32_t forbidden_distance = max_distance + 1;
142 uint32_t offset = forbidden_distance - ndirect - 1;
143 uint32_t ndistbits = 0;
148 uint32_t postfix = (1u << npostfix) - 1;
152 offset = (offset >> npostfix) + 4;
156 while (tmp != 0) {ndistbits++; tmp = tmp >> 1;}
160 half = (offset >> ndistbits) & 1;
162 group = ((ndistbits - 1) << 1) | half;
173 ndistbits = (group >> 1) + 1;
175 extra = (1u << ndistbits) - 1;
177 start = (1u << (ndistbits + 1)) - 4;
179 start += (group & 1) << ndistbits;
BROTLI_UNUSED_FUNCTION BrotliDistanceCodeLimit BrotliCalculateDistanceCodeLimit(uint32_t max_distance, uint32_t npostfix, uint32_t ndirect)
Definition constants.h:127
BROTLI_COMMON_API const BrotliPrefixCodeRange _kBrotliPrefixCodeRanges[BROTLI_NUM_BLOCK_LEN_SYMBOLS]
Definition constants.c:10
#define BROTLI_NUM_DISTANCE_SHORT_CODES
Definition constants.h:60
struct BrotliDistanceCodeLimit BrotliDistanceCodeLimit
#define BROTLI_NUM_BLOCK_LEN_SYMBOLS
Definition constants.h:28
#define BROTLI_COMMON_API
Definition port.h:283
Definition constants.h:105
uint32_t max_distance
Definition constants.h:107
uint32_t max_alphabet_size
Definition constants.h:106
Definition constants.h:191