12#ifndef BROTLI_COMMON_CONSTANTS_H_
13#define BROTLI_COMMON_CONSTANTS_H_
15#include <brotli/port.h>
16#include <brotli/types.h>
21#define BROTLI_CONTEXT_MAP_MAX_RLE 16
24#define BROTLI_MAX_NUMBER_OF_BLOCK_TYPES 256
27#define BROTLI_NUM_LITERAL_SYMBOLS 256
28#define BROTLI_NUM_COMMAND_SYMBOLS 704
29#define BROTLI_NUM_BLOCK_LEN_SYMBOLS 26
30#define BROTLI_MAX_CONTEXT_MAP_SYMBOLS (BROTLI_MAX_NUMBER_OF_BLOCK_TYPES + \
31 BROTLI_CONTEXT_MAP_MAX_RLE)
32#define BROTLI_MAX_BLOCK_TYPE_SYMBOLS (BROTLI_MAX_NUMBER_OF_BLOCK_TYPES + 2)
35#define BROTLI_REPEAT_PREVIOUS_CODE_LENGTH 16
36#define BROTLI_REPEAT_ZERO_CODE_LENGTH 17
37#define BROTLI_CODE_LENGTH_CODES (BROTLI_REPEAT_ZERO_CODE_LENGTH + 1)
39#define BROTLI_INITIAL_REPEATED_CODE_LENGTH 8
51#define BROTLI_LARGE_MAX_DISTANCE_BITS 62U
52#define BROTLI_LARGE_MIN_WBITS 10
58#define BROTLI_LARGE_MAX_WBITS 30
61#define BROTLI_NUM_DISTANCE_SHORT_CODES 16
67#define BROTLI_MAX_NPOSTFIX 3
68#define BROTLI_MAX_NDIRECT 120
69#define BROTLI_MAX_DISTANCE_BITS 24U
70#define BROTLI_DISTANCE_ALPHABET_SIZE(NPOSTFIX, NDIRECT, MAXNBITS) ( \
71 BROTLI_NUM_DISTANCE_SHORT_CODES + (NDIRECT) + \
72 ((MAXNBITS) << ((NPOSTFIX) + 1)))
74#define BROTLI_NUM_DISTANCE_SYMBOLS \
75 BROTLI_DISTANCE_ALPHABET_SIZE( \
76 BROTLI_MAX_NDIRECT, BROTLI_MAX_NPOSTFIX, BROTLI_LARGE_MAX_DISTANCE_BITS)
81#define BROTLI_MAX_DISTANCE 0x3FFFFFC
87#define BROTLI_MAX_ALLOWED_DISTANCE 0x7FFFFFFC
91#define BROTLI_NUM_INS_COPY_CODES 24
95#define BROTLI_LITERAL_CONTEXT_BITS 6
98#define BROTLI_DISTANCE_CONTEXT_BITS 2
103#define BROTLI_WINDOW_GAP 16
104#define BROTLI_MAX_BACKWARD_LIMIT(W) (((size_t)1 << (W)) - BROTLI_WINDOW_GAP)
129 uint32_t max_distance, uint32_t npostfix, uint32_t ndirect) {
134 if (max_distance <= ndirect) {
141 uint32_t forbidden_distance = max_distance + 1;
143 uint32_t offset = forbidden_distance - ndirect - 1;
144 uint32_t ndistbits = 0;
149 uint32_t postfix = (1u << npostfix) - 1;
153 offset = (offset >> npostfix) + 4;
157 while (tmp != 0) {ndistbits++; tmp = tmp >> 1;}
161 half = (offset >> ndistbits) & 1;
163 group = ((ndistbits - 1) << 1) | half;
174 ndistbits = (group >> 1) + 1;
176 extra = (1u << ndistbits) - 1;
178 start = (1u << (ndistbits + 1)) - 4;
180 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