Home | History | Annotate | Download | only in enc
      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 
     23 namespace brotli {
     24 
     25 static const int kNumInsertLenPrefixes = 24;
     26 static const int kNumCopyLenPrefixes = 24;
     27 static const int kNumCommandPrefixes = 704;
     28 static const int kNumBlockLenPrefixes = 26;
     29 static const int kNumDistanceShortCodes = 16;
     30 static const int kNumDistancePrefixes = 520;
     31 
     32 int CommandPrefix(int insert_length, int copy_length);
     33 int InsertLengthExtraBits(int prefix);
     34 int InsertLengthOffset(int prefix);
     35 int CopyLengthExtraBits(int prefix);
     36 int CopyLengthOffset(int prefix);
     37 
     38 void 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 
     45 int BlockLengthPrefix(int length);
     46 int BlockLengthExtraBits(int prefix);
     47 int BlockLengthOffset(int prefix);
     48 
     49 }  // namespace brotli
     50 
     51 #endif  // BROTLI_ENC_PREFIX_H_
     52