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/* 31Compresses according to the deflate specification and append the compressed 32result to the output. 33This function will usually output multiple deflate blocks. If final is 1, then 34the final bit will be set on the last block. 35 36options: global program options 37btype: the deflate block type. Use 2 for best compression. 38 -0: non compressed blocks (00) 39 -1: blocks with fixed tree (01) 40 -2: blocks with dynamic tree (10) 41final: whether this is the last section of the input, sets the final bit to the 42 last deflate block. 43in: the input bytes 44insize: number of input bytes 45bp: bit pointer for the output array. This must initially be 0, and for 46 consecutive calls must be reused (it can have values from 0-7). This is 47 because deflate appends blocks as bit-based data, rather than on byte 48 boundaries. 49out: pointer to the dynamic output array to which the result is appended. Must 50 be freed after use. 51outsize: pointer to the dynamic output array size. 52*/ 53void ZopfliDeflate(const ZopfliOptions* options, int btype, int final, 54 const unsigned char* in, size_t insize, 55 unsigned char* bp, unsigned char** out, size_t* outsize); 56 57/* 58Like ZopfliDeflate, but allows to specify start and end byte with instart and 59inend. Only that part is compressed, but earlier bytes are still used for the 60back window. 61*/ 62void ZopfliDeflatePart(const ZopfliOptions* options, int btype, int final, 63 const unsigned char* in, size_t instart, size_t inend, 64 unsigned char* bp, unsigned char** out, 65 size_t* outsize); 66 67/* 68Calculates block size in bits. 69litlens: lz77 lit/lengths 70dists: ll77 distances 71lstart: start of block 72lend: end of block (not inclusive) 73*/ 74double ZopfliCalculateBlockSize(const unsigned short* litlens, 75 const unsigned short* dists, 76 size_t lstart, size_t lend, int btype); 77#endif /* ZOPFLI_DEFLATE_H_ */ 78