1 1.1 tls /* 2 1.1 tls Copyright 2013 Google Inc. All Rights Reserved. 3 1.1 tls Author: lode (at) google.com (Lode Vandevenne) 4 1.1 tls */ 5 1.1 tls 6 1.1 tls #ifndef UTIL_COMPRESSION_ZOPFLI_INTERNAL_ZOPFLI_H_ 7 1.1 tls #define UTIL_COMPRESSION_ZOPFLI_INTERNAL_ZOPFLI_H_ 8 1.1 tls 9 1.1 tls #include <stdlib.h> /* for size_t */ 10 1.1 tls 11 1.1 tls /* 12 1.1 tls Options used throughout the program. 13 1.1 tls */ 14 1.1 tls typedef struct ZopfliOptions { 15 1.1 tls /* Whether to print output */ 16 1.1 tls int verbose; 17 1.1 tls 18 1.1 tls /* 19 1.1 tls Maximum amount of times to rerun forward and backward pass to optimize LZ77 20 1.1 tls compression cost. Good values: 10, 15 for small files, 5 for files over 21 1.1 tls several MB in size or it will be too slow. 22 1.1 tls */ 23 1.1 tls int numiterations; 24 1.1 tls 25 1.1 tls /* 26 1.1 tls If true, splits the data in multiple deflate blocks with optimal choice 27 1.1 tls for the block boundaries. Block splitting gives better compression. Default: 28 1.1 tls true (1). 29 1.1 tls */ 30 1.1 tls int blocksplitting; 31 1.1 tls 32 1.1 tls /* 33 1.1 tls If true, chooses the optimal block split points only after doing the iterative 34 1.1 tls LZ77 compression. If false, chooses the block split points first, then does 35 1.1 tls iterative LZ77 on each individual block. Depending on the file, either first 36 1.1 tls or last gives the best compression. Default: false (0). 37 1.1 tls */ 38 1.1 tls int blocksplittinglast; 39 1.1 tls 40 1.1 tls /* 41 1.1 tls Maximum amount of blocks to split into (0 for unlimited, but this can give 42 1.1 tls extreme results that hurt compression on some files). Default value: 15. 43 1.1 tls */ 44 1.1 tls int blocksplittingmax; 45 1.1 tls } ZopfliOptions; 46 1.1 tls 47 1.1 tls /* Initializes options with default values. */ 48 1.1 tls void ZopfliInitOptions(ZopfliOptions* options); 49 1.1 tls 50 1.1 tls /* Output format */ 51 1.1 tls typedef enum { 52 1.1 tls ZOPFLI_FORMAT_GZIP, 53 1.1 tls ZOPFLI_FORMAT_ZLIB, 54 1.1 tls ZOPFLI_FORMAT_DEFLATE 55 1.1 tls } ZopfliFormat; 56 1.1 tls 57 1.1 tls /* 58 1.1 tls Compresses according to the given output format and appends the result to the 59 1.1 tls output. 60 1.1 tls 61 1.1 tls options: global program options 62 1.1 tls output_type: the output format to use 63 1.1 tls out: pointer to the dynamic output array to which the result is appended. Must 64 1.1 tls be freed after use 65 1.1 tls outsize: pointer to the dynamic output array size 66 1.1 tls */ 67 1.1 tls void ZopfliCompress(const ZopfliOptions* options, ZopfliFormat output_type, 68 1.1 tls const unsigned char* in, size_t insize, 69 1.1 tls unsigned char** out, size_t* outsize); 70 1.1 tls 71 1.1 tls #endif /* UTIL_COMPRESSION_ZOPFLI_INTERNAL_ZOPFLI_H_ */ 72