github.com/andybalholm/brotli@v1.0.6/constants.go (about) 1 package brotli 2 3 /* Copyright 2016 Google Inc. All Rights Reserved. 4 5 Distributed under MIT license. 6 See file LICENSE for detail or copy at https://opensource.org/licenses/MIT 7 */ 8 9 /* Specification: 7.3. Encoding of the context map */ 10 const contextMapMaxRle = 16 11 12 /* Specification: 2. Compressed representation overview */ 13 const maxNumberOfBlockTypes = 256 14 15 /* Specification: 3.3. Alphabet sizes: insert-and-copy length */ 16 const numLiteralSymbols = 256 17 18 const numCommandSymbols = 704 19 20 const numBlockLenSymbols = 26 21 22 const maxContextMapSymbols = (maxNumberOfBlockTypes + contextMapMaxRle) 23 24 const maxBlockTypeSymbols = (maxNumberOfBlockTypes + 2) 25 26 /* Specification: 3.5. Complex prefix codes */ 27 const repeatPreviousCodeLength = 16 28 29 const repeatZeroCodeLength = 17 30 31 const codeLengthCodes = (repeatZeroCodeLength + 1) 32 33 /* "code length of 8 is repeated" */ 34 const initialRepeatedCodeLength = 8 35 36 /* "Large Window Brotli" */ 37 const largeMaxDistanceBits = 62 38 39 const largeMinWbits = 10 40 41 const largeMaxWbits = 30 42 43 /* Specification: 4. Encoding of distances */ 44 const numDistanceShortCodes = 16 45 46 const maxNpostfix = 3 47 48 const maxNdirect = 120 49 50 const maxDistanceBits = 24 51 52 func distanceAlphabetSize(NPOSTFIX uint, NDIRECT uint, MAXNBITS uint) uint { 53 return numDistanceShortCodes + NDIRECT + uint(MAXNBITS<<(NPOSTFIX+1)) 54 } 55 56 /* numDistanceSymbols == 1128 */ 57 const numDistanceSymbols = 1128 58 59 const maxDistance = 0x3FFFFFC 60 61 const maxAllowedDistance = 0x7FFFFFFC 62 63 /* 7.1. Context modes and context ID lookup for literals */ 64 /* "context IDs for literals are in the range of 0..63" */ 65 const literalContextBits = 6 66 67 /* 7.2. Context ID for distances */ 68 const distanceContextBits = 2 69 70 /* 9.1. Format of the Stream Header */ 71 /* Number of slack bytes for window size. Don't confuse 72 with BROTLI_NUM_DISTANCE_SHORT_CODES. */ 73 const windowGap = 16 74 75 func maxBackwardLimit(W uint) uint { 76 return (uint(1) << W) - windowGap 77 }