• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 Copyright 2011 Google Inc. All Rights Reserved.
3 
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7 
8     http://www.apache.org/licenses/LICENSE-2.0
9 
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15 
16 Author: lode.vandevenne@gmail.com (Lode Vandevenne)
17 Author: jyrki.alakuijala@gmail.com (Jyrki Alakuijala)
18 */
19 
20 #include "zopfli.h"
21 
22 #include "deflate.h"
23 #include "gzip_container.h"
24 #include "zlib_container.h"
25 
26 #include <assert.h>
27 
ZopfliCompress(const ZopfliOptions * options,ZopfliFormat output_type,const unsigned char * in,size_t insize,unsigned char ** out,size_t * outsize)28 void ZopfliCompress(const ZopfliOptions* options, ZopfliFormat output_type,
29                     const unsigned char* in, size_t insize,
30                     unsigned char** out, size_t* outsize) {
31   if (output_type == ZOPFLI_FORMAT_GZIP) {
32     ZopfliGzipCompress(options, in, insize, out, outsize);
33   } else if (output_type == ZOPFLI_FORMAT_ZLIB) {
34     ZopfliZlibCompress(options, in, insize, out, outsize);
35   } else if (output_type == ZOPFLI_FORMAT_DEFLATE) {
36     unsigned char bp = 0;
37     ZopfliDeflate(options, 2 /* Dynamic block */, 1,
38                   in, insize, &bp, out, outsize);
39   } else {
40     assert(0);
41   }
42 }
43