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