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 /*
      7 Modified by madler (at) alumni.caltech.edu (Mark Adler)
      8 Moved ZopfliInitOptions() to deflate.c.
      9 */
     10 
     11 #include "zopfli.h"
     12 
     13 #include "deflate.h"
     14 #include "gzip_container.h"
     15 #include "zlib_container.h"
     16 
     17 #include <assert.h>
     18 
     19 void ZopfliCompress(const ZopfliOptions* options, ZopfliFormat output_type,
     20                     const unsigned char* in, size_t insize,
     21                     unsigned char** out, size_t* outsize)
     22 {
     23   if (output_type == ZOPFLI_FORMAT_GZIP) {
     24     ZopfliGzipCompress(options, in, insize, out, outsize);
     25   } else if (output_type == ZOPFLI_FORMAT_ZLIB) {
     26     ZopfliZlibCompress(options, in, insize, out, outsize);
     27   } else if (output_type == ZOPFLI_FORMAT_DEFLATE) {
     28     unsigned char bp = 0;
     29     ZopfliDeflate(options, 2 /* Dynamic block */, 1,
     30                   in, insize, &bp, out, outsize);
     31   } else {
     32     assert(0);
     33   }
     34 }
     35