179e99afe468407e9ff9f0820df7190cb069eabebZoltan Szabadka// Copyright 2013 Google Inc. All Rights Reserved.
279e99afe468407e9ff9f0820df7190cb069eabebZoltan Szabadka//
379e99afe468407e9ff9f0820df7190cb069eabebZoltan Szabadka// Licensed under the Apache License, Version 2.0 (the "License");
479e99afe468407e9ff9f0820df7190cb069eabebZoltan Szabadka// you may not use this file except in compliance with the License.
579e99afe468407e9ff9f0820df7190cb069eabebZoltan Szabadka// You may obtain a copy of the License at
679e99afe468407e9ff9f0820df7190cb069eabebZoltan Szabadka//
779e99afe468407e9ff9f0820df7190cb069eabebZoltan Szabadka// http://www.apache.org/licenses/LICENSE-2.0
879e99afe468407e9ff9f0820df7190cb069eabebZoltan Szabadka//
979e99afe468407e9ff9f0820df7190cb069eabebZoltan Szabadka// Unless required by applicable law or agreed to in writing, software
1079e99afe468407e9ff9f0820df7190cb069eabebZoltan Szabadka// distributed under the License is distributed on an "AS IS" BASIS,
1179e99afe468407e9ff9f0820df7190cb069eabebZoltan Szabadka// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1279e99afe468407e9ff9f0820df7190cb069eabebZoltan Szabadka// See the License for the specific language governing permissions and
1379e99afe468407e9ff9f0820df7190cb069eabebZoltan Szabadka// limitations under the License.
1479e99afe468407e9ff9f0820df7190cb069eabebZoltan Szabadka//
1579e99afe468407e9ff9f0820df7190cb069eabebZoltan Szabadka// Functions for encoding of integers into prefix codes the amount of extra
1679e99afe468407e9ff9f0820df7190cb069eabebZoltan Szabadka// bits, and the actual values of the extra bits.
1779e99afe468407e9ff9f0820df7190cb069eabebZoltan Szabadka
1879e99afe468407e9ff9f0820df7190cb069eabebZoltan Szabadka#ifndef BROTLI_ENC_PREFIX_H_
1979e99afe468407e9ff9f0820df7190cb069eabebZoltan Szabadka#define BROTLI_ENC_PREFIX_H_
2079e99afe468407e9ff9f0820df7190cb069eabebZoltan Szabadka
2179e99afe468407e9ff9f0820df7190cb069eabebZoltan Szabadka#include <stdint.h>
2279e99afe468407e9ff9f0820df7190cb069eabebZoltan Szabadka
2379e99afe468407e9ff9f0820df7190cb069eabebZoltan Szabadkanamespace brotli {
2479e99afe468407e9ff9f0820df7190cb069eabebZoltan Szabadka
2579e99afe468407e9ff9f0820df7190cb069eabebZoltan Szabadkastatic const int kNumInsertLenPrefixes = 24;
2679e99afe468407e9ff9f0820df7190cb069eabebZoltan Szabadkastatic const int kNumCopyLenPrefixes = 24;
2779e99afe468407e9ff9f0820df7190cb069eabebZoltan Szabadkastatic const int kNumCommandPrefixes = 704;
2879e99afe468407e9ff9f0820df7190cb069eabebZoltan Szabadkastatic const int kNumBlockLenPrefixes = 26;
2979e99afe468407e9ff9f0820df7190cb069eabebZoltan Szabadkastatic const int kNumDistanceShortCodes = 16;
3079e99afe468407e9ff9f0820df7190cb069eabebZoltan Szabadkastatic const int kNumDistancePrefixes = 520;
3179e99afe468407e9ff9f0820df7190cb069eabebZoltan Szabadka
3279e99afe468407e9ff9f0820df7190cb069eabebZoltan Szabadkaint CommandPrefix(int insert_length, int copy_length);
3379e99afe468407e9ff9f0820df7190cb069eabebZoltan Szabadkaint InsertLengthExtraBits(int prefix);
3479e99afe468407e9ff9f0820df7190cb069eabebZoltan Szabadkaint InsertLengthOffset(int prefix);
3579e99afe468407e9ff9f0820df7190cb069eabebZoltan Szabadkaint CopyLengthExtraBits(int prefix);
3679e99afe468407e9ff9f0820df7190cb069eabebZoltan Szabadkaint CopyLengthOffset(int prefix);
3779e99afe468407e9ff9f0820df7190cb069eabebZoltan Szabadka
3879e99afe468407e9ff9f0820df7190cb069eabebZoltan Szabadkavoid PrefixEncodeCopyDistance(int distance_code,
3979e99afe468407e9ff9f0820df7190cb069eabebZoltan Szabadka                              int num_direct_codes,
4079e99afe468407e9ff9f0820df7190cb069eabebZoltan Szabadka                              int shift_bits,
4179e99afe468407e9ff9f0820df7190cb069eabebZoltan Szabadka                              uint16_t* prefix,
4279e99afe468407e9ff9f0820df7190cb069eabebZoltan Szabadka                              int* nbits,
4379e99afe468407e9ff9f0820df7190cb069eabebZoltan Szabadka                              uint32_t* extra_bits);
4479e99afe468407e9ff9f0820df7190cb069eabebZoltan Szabadka
4579e99afe468407e9ff9f0820df7190cb069eabebZoltan Szabadkaint BlockLengthPrefix(int length);
4679e99afe468407e9ff9f0820df7190cb069eabebZoltan Szabadkaint BlockLengthExtraBits(int prefix);
4779e99afe468407e9ff9f0820df7190cb069eabebZoltan Szabadkaint BlockLengthOffset(int prefix);
4879e99afe468407e9ff9f0820df7190cb069eabebZoltan Szabadka
4979e99afe468407e9ff9f0820df7190cb069eabebZoltan Szabadka}  // namespace brotli
5079e99afe468407e9ff9f0820df7190cb069eabebZoltan Szabadka
5179e99afe468407e9ff9f0820df7190cb069eabebZoltan Szabadka#endif  // BROTLI_ENC_PREFIX_H_
52