forked from mirror/brotli
78 lines
2.2 KiB
Go
78 lines
2.2 KiB
Go
|
package brotli
|
||
|
|
||
|
/* Copyright 2016 Google Inc. All Rights Reserved.
|
||
|
|
||
|
Distributed under MIT license.
|
||
|
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
|
||
|
*/
|
||
|
|
||
|
/* Specification: 7.3. Encoding of the context map */
|
||
|
const BROTLI_CONTEXT_MAP_MAX_RLE = 16
|
||
|
|
||
|
/* Specification: 2. Compressed representation overview */
|
||
|
const BROTLI_MAX_NUMBER_OF_BLOCK_TYPES = 256
|
||
|
|
||
|
/* Specification: 3.3. Alphabet sizes: insert-and-copy length */
|
||
|
const BROTLI_NUM_LITERAL_SYMBOLS = 256
|
||
|
|
||
|
const BROTLI_NUM_COMMAND_SYMBOLS = 704
|
||
|
|
||
|
const BROTLI_NUM_BLOCK_LEN_SYMBOLS = 26
|
||
|
|
||
|
const BROTLI_MAX_CONTEXT_MAP_SYMBOLS = (BROTLI_MAX_NUMBER_OF_BLOCK_TYPES + BROTLI_CONTEXT_MAP_MAX_RLE)
|
||
|
|
||
|
const BROTLI_MAX_BLOCK_TYPE_SYMBOLS = (BROTLI_MAX_NUMBER_OF_BLOCK_TYPES + 2)
|
||
|
|
||
|
/* Specification: 3.5. Complex prefix codes */
|
||
|
const BROTLI_REPEAT_PREVIOUS_CODE_LENGTH = 16
|
||
|
|
||
|
const BROTLI_REPEAT_ZERO_CODE_LENGTH = 17
|
||
|
|
||
|
const BROTLI_CODE_LENGTH_CODES = (BROTLI_REPEAT_ZERO_CODE_LENGTH + 1)
|
||
|
|
||
|
/* "code length of 8 is repeated" */
|
||
|
const BROTLI_INITIAL_REPEATED_CODE_LENGTH = 8
|
||
|
|
||
|
/* "Large Window Brotli" */
|
||
|
const BROTLI_LARGE_MAX_DISTANCE_BITS = 62
|
||
|
|
||
|
const BROTLI_LARGE_MIN_WBITS = 10
|
||
|
|
||
|
const BROTLI_LARGE_MAX_WBITS = 30
|
||
|
|
||
|
/* Specification: 4. Encoding of distances */
|
||
|
const BROTLI_NUM_DISTANCE_SHORT_CODES = 16
|
||
|
|
||
|
const BROTLI_MAX_NPOSTFIX = 3
|
||
|
|
||
|
const BROTLI_MAX_NDIRECT = 120
|
||
|
|
||
|
const BROTLI_MAX_DISTANCE_BITS = 24
|
||
|
|
||
|
func BROTLI_DISTANCE_ALPHABET_SIZE(NPOSTFIX uint, NDIRECT uint, MAXNBITS uint) uint {
|
||
|
return BROTLI_NUM_DISTANCE_SHORT_CODES + NDIRECT + uint(MAXNBITS<<(NPOSTFIX+1))
|
||
|
}
|
||
|
|
||
|
/* BROTLI_NUM_DISTANCE_SYMBOLS == 1128 */
|
||
|
const BROTLI_NUM_DISTANCE_SYMBOLS = 1128
|
||
|
|
||
|
const BROTLI_MAX_DISTANCE = 0x3FFFFFC
|
||
|
|
||
|
const BROTLI_MAX_ALLOWED_DISTANCE = 0x7FFFFFFC
|
||
|
|
||
|
/* 7.1. Context modes and context ID lookup for literals */
|
||
|
/* "context IDs for literals are in the range of 0..63" */
|
||
|
const BROTLI_LITERAL_CONTEXT_BITS = 6
|
||
|
|
||
|
/* 7.2. Context ID for distances */
|
||
|
const BROTLI_DISTANCE_CONTEXT_BITS = 2
|
||
|
|
||
|
/* 9.1. Format of the Stream Header */
|
||
|
/* Number of slack bytes for window size. Don't confuse
|
||
|
with BROTLI_NUM_DISTANCE_SHORT_CODES. */
|
||
|
const BROTLI_WINDOW_GAP = 16
|
||
|
|
||
|
func BROTLI_MAX_BACKWARD_LIMIT(W uint) uint {
|
||
|
return (uint(1) << W) - BROTLI_WINDOW_GAP
|
||
|
}
|