1/* 2Copyright 2011 Google Inc. All Rights Reserved. 3 4Licensed under the Apache License, Version 2.0 (the "License"); 5you may not use this file except in compliance with the License. 6You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10Unless required by applicable law or agreed to in writing, software 11distributed under the License is distributed on an "AS IS" BASIS, 12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13See the License for the specific language governing permissions and 14limitations under the License. 15 16Author: lode.vandevenne@gmail.com (Lode Vandevenne) 17Author: jyrki.alakuijala@gmail.com (Jyrki Alakuijala) 18*/ 19 20#ifndef ZOPFLI_DEFLATE_H_ 21#define ZOPFLI_DEFLATE_H_ 22 23/* 24Functions to compress according to the DEFLATE specification, using the 25"squeeze" LZ77 compression backend. 26*/ 27 28#include "zopfli.h" 29 30#ifdef __cplusplus 31extern "C" { 32#endif 33 34/* 35Compresses according to the deflate specification and append the compressed 36result to the output. 37This function will usually output multiple deflate blocks. If final is 1, then 38the final bit will be set on the last block. 39 40options: global program options 41btype: the deflate block type. Use 2 for best compression. 42 -0: non compressed blocks (00) 43 -1: blocks with fixed tree (01) 44 -2: blocks with dynamic tree (10) 45final: whether this is the last section of the input, sets the final bit to the 46 last deflate block. 47in: the input bytes 48insize: number of input bytes 49bp: bit pointer for the output array. This must initially be 0, and for 50 consecutive calls must be reused (it can have values from 0-7). This is 51 because deflate appends blocks as bit-based data, rather than on byte 52 boundaries. 53out: pointer to the dynamic output array to which the result is appended. Must 54 be freed after use. 55outsize: pointer to the dynamic output array size. 56*/ 57void ZopfliDeflate(const ZopfliOptions* options, int btype, int final, 58 const unsigned char* in, size_t insize, 59 unsigned char* bp, unsigned char** out, size_t* outsize); 60 61/* 62Like ZopfliDeflate, but allows to specify start and end byte with instart and 63inend. Only that part is compressed, but earlier bytes are still used for the 64back window. 65*/ 66void ZopfliDeflatePart(const ZopfliOptions* options, int btype, int final, 67 const unsigned char* in, size_t instart, size_t inend, 68 unsigned char* bp, unsigned char** out, 69 size_t* outsize); 70 71/* 72Calculates block size in bits. 73litlens: lz77 lit/lengths 74dists: ll77 distances 75lstart: start of block 76lend: end of block (not inclusive) 77*/ 78double ZopfliCalculateBlockSize(const unsigned short* litlens, 79 const unsigned short* dists, 80 size_t lstart, size_t lend, int btype); 81 82#ifdef __cplusplus 83} // extern "C" 84#endif 85 86#endif /* ZOPFLI_DEFLATE_H_ */ 87