1 /* 2 Copyright 2011 Google Inc. All Rights Reserved. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 16 Author: lode.vandevenne@gmail.com (Lode Vandevenne) 17 Author: jyrki.alakuijala@gmail.com (Jyrki Alakuijala) 18 */ 19 20 /* 21 Functions to choose good boundaries for block splitting. Deflate allows encoding 22 the data in multiple blocks, with a separate Huffman tree for each block. The 23 Huffman tree itself requires some bytes to encode, so by choosing certain 24 blocks, you can either hurt, or enhance compression. These functions choose good 25 ones that enhance it. 26 */ 27 28 #ifndef ZOPFLI_BLOCKSPLITTER_H_ 29 #define ZOPFLI_BLOCKSPLITTER_H_ 30 31 #include <stdlib.h> 32 33 #include "zopfli.h" 34 35 36 /* 37 Does blocksplitting on LZ77 data. 38 The output splitpoints are indices in the LZ77 data. 39 litlens: lz77 lit/lengths 40 dists: lz77 distances 41 llsize: size of litlens and dists 42 maxblocks: set a limit to the amount of blocks. Set to 0 to mean no limit. 43 */ 44 void ZopfliBlockSplitLZ77(const ZopfliOptions* options, 45 const unsigned short* litlens, 46 const unsigned short* dists, 47 size_t llsize, size_t maxblocks, 48 size_t** splitpoints, size_t* npoints); 49 50 /* 51 Does blocksplitting on uncompressed data. 52 The output splitpoints are indices in the uncompressed bytes. 53 54 options: general program options. 55 in: uncompressed input data 56 instart: where to start splitting 57 inend: where to end splitting (not inclusive) 58 maxblocks: maximum amount of blocks to split into, or 0 for no limit 59 splitpoints: dynamic array to put the resulting split point coordinates into. 60 The coordinates are indices in the input array. 61 npoints: pointer to amount of splitpoints, for the dynamic array. The amount of 62 blocks is the amount of splitpoitns + 1. 63 */ 64 void ZopfliBlockSplit(const ZopfliOptions* options, 65 const unsigned char* in, size_t instart, size_t inend, 66 size_t maxblocks, size_t** splitpoints, size_t* npoints); 67 68 /* 69 Divides the input into equal blocks, does not even take LZ77 lengths into 70 account. 71 */ 72 void ZopfliBlockSplitSimple(const unsigned char* in, 73 size_t instart, size_t inend, 74 size_t blocksize, 75 size_t** splitpoints, size_t* npoints); 76 77 #endif /* ZOPFLI_BLOCKSPLITTER_H_ */ 78