1// Copyright 2013 Google Inc. All Rights Reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// Functions for encoding of integers into prefix codes the amount of extra
16// bits, and the actual values of the extra bits.
17
18#ifndef BROTLI_ENC_PREFIX_H_
19#define BROTLI_ENC_PREFIX_H_
20
21#include <stdint.h>
22
23namespace brotli {
24
25static const int kNumInsertLenPrefixes = 24;
26static const int kNumCopyLenPrefixes = 24;
27static const int kNumCommandPrefixes = 704;
28static const int kNumBlockLenPrefixes = 26;
29static const int kNumDistanceShortCodes = 16;
30static const int kNumDistancePrefixes = 520;
31
32int CommandPrefix(int insert_length, int copy_length);
33int InsertLengthExtraBits(int prefix);
34int InsertLengthOffset(int prefix);
35int CopyLengthExtraBits(int prefix);
36int CopyLengthOffset(int prefix);
37
38void PrefixEncodeCopyDistance(int distance_code,
39                              int num_direct_codes,
40                              int shift_bits,
41                              uint16_t* prefix,
42                              int* nbits,
43                              uint32_t* extra_bits);
44
45int BlockLengthPrefix(int length);
46int BlockLengthExtraBits(int prefix);
47int BlockLengthOffset(int prefix);
48
49}  // namespace brotli
50
51#endif  // BROTLI_ENC_PREFIX_H_
52