aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLode Vandevenne <lode@google.com>2013-03-06 14:03:24 +0100
committerLode Vandevenne <lode@google.com>2013-03-06 14:03:24 +0100
commit8c218eff39749e738c92bf34155099ad280c16f7 (patch)
tree3d70cc05cfb302d7497d1ce5174a977e87205523
parent981df0fe897c94382b9b963eb72bc36cbc2e729c (diff)
downloadzopfli-8c218eff39749e738c92bf34155099ad280c16f7.tar.gz
Make a better distinction between zopfli binary and library
-rw-r--r--CONTRIBUTORS1
-rw-r--r--blocksplitter.c1
-rw-r--r--blocksplitter.h2
-rw-r--r--deflate.h2
-rw-r--r--gzip_container.c1
-rw-r--r--gzip_container.h2
-rw-r--r--lz77.c1
-rw-r--r--lz77.h2
-rw-r--r--util.c8
-rw-r--r--util.h39
-rw-r--r--zlib_container.c1
-rw-r--r--zlib_container.h2
-rw-r--r--zopfli_bin.c (renamed from zopfli.c)38
13 files changed, 23 insertions, 77 deletions
diff --git a/CONTRIBUTORS b/CONTRIBUTORS
index 7294d3f..10ce75a 100644
--- a/CONTRIBUTORS
+++ b/CONTRIBUTORS
@@ -1,5 +1,6 @@
Mark Adler
Jyrki Alakuijala
Daniel Reed
+Huzaifa Sidhpurwala
Péter Szabó
Lode Vandevenne
diff --git a/blocksplitter.c b/blocksplitter.c
index db3e24a..9c2c40e 100644
--- a/blocksplitter.c
+++ b/blocksplitter.c
@@ -27,6 +27,7 @@ Author: jyrki.alakuijala@gmail.com (Jyrki Alakuijala)
#include "lz77.h"
#include "squeeze.h"
#include "tree.h"
+#include "util.h"
/*
The "f" for the FindMinimum function below.
diff --git a/blocksplitter.h b/blocksplitter.h
index 74b8d7e..6791702 100644
--- a/blocksplitter.h
+++ b/blocksplitter.h
@@ -30,7 +30,7 @@ ones that enhance it.
#include <stdlib.h>
-#include "util.h"
+#include "zopfli.h"
/*
diff --git a/deflate.h b/deflate.h
index 5c54b6d..c53f8be 100644
--- a/deflate.h
+++ b/deflate.h
@@ -25,7 +25,7 @@ Functions to compress according to the DEFLATE specification, using the
"squeeze" LZ77 compression backend.
*/
-#include "util.h"
+#include "zopfli.h"
/*
Compresses according to the deflate specification and append the compressed
diff --git a/gzip_container.c b/gzip_container.c
index e94a3bd..b68667f 100644
--- a/gzip_container.c
+++ b/gzip_container.c
@@ -18,6 +18,7 @@ Author: jyrki.alakuijala@gmail.com (Jyrki Alakuijala)
*/
#include "gzip_container.h"
+#include "util.h"
#include <stdio.h>
diff --git a/gzip_container.h b/gzip_container.h
index 5558eb1..fdbc6b5 100644
--- a/gzip_container.h
+++ b/gzip_container.h
@@ -24,7 +24,7 @@ Author: jyrki.alakuijala@gmail.com (Jyrki Alakuijala)
Functions to compress according to the Gzip specification.
*/
-#include "util.h"
+#include "zopfli.h"
/*
Compresses according to the gzip specification and append the compressed
diff --git a/lz77.c b/lz77.c
index 5b74e1e..a9dc4d3 100644
--- a/lz77.c
+++ b/lz77.c
@@ -18,6 +18,7 @@ Author: jyrki.alakuijala@gmail.com (Jyrki Alakuijala)
*/
#include "lz77.h"
+#include "util.h"
#include <assert.h>
#include <stdio.h>
diff --git a/lz77.h b/lz77.h
index 83ef1c8..df65ace 100644
--- a/lz77.h
+++ b/lz77.h
@@ -29,7 +29,7 @@ compression.
#include "cache.h"
#include "hash.h"
-#include "util.h"
+#include "zopfli.h"
/*
Stores lit/length and dist pairs for LZ77.
diff --git a/util.c b/util.c
index 17cb111..b106885 100644
--- a/util.c
+++ b/util.c
@@ -200,11 +200,3 @@ int ZopfliGetLengthSymbol(int l) {
};
return table[l];
}
-
-void ZopfliInitOptions(ZopfliOptions* options) {
- options->verbose = 0;
- options->numiterations = 15;
- options->blocksplitting = 1;
- options->blocksplittinglast = 0;
- options->blocksplittingmax = 15;
-}
diff --git a/util.h b/util.h
index 6a7aafa..4188f51 100644
--- a/util.h
+++ b/util.h
@@ -138,45 +138,6 @@ int ZopfliGetDistExtraBits(int dist);
int ZopfliGetDistExtraBitsValue(int dist);
/*
-Options used throughout the program.
-*/
-typedef struct ZopfliOptions {
- /* Whether to print output */
- int verbose;
-
- /*
- Maximum amount of times to rerun forward and backward pass to optimize LZ77
- compression cost. Good values: 10, 15 for small files, 5 for files over
- several MB in size or it will be too slow.
- */
- int numiterations;
-
- /*
- If true, splits the data in multiple deflate blocks with optimal choice
- for the block boundaries. Block splitting gives better compression. Default:
- true (1).
- */
- int blocksplitting;
-
- /*
- If true, chooses the optimal block split points only after doing the iterative
- LZ77 compression. If false, chooses the block split points first, then does
- iterative LZ77 on each individual block. Depending on the file, either first
- or last gives the best compression. Default: false (0).
- */
- int blocksplittinglast;
-
- /*
- Maximum amount of blocks to split into (0 for unlimited, but this can give
- extreme results that hurt compression on some files). Default value: 15.
- */
- int blocksplittingmax;
-} ZopfliOptions;
-
-/* Initializes options with default values. */
-void ZopfliInitOptions(ZopfliOptions* options);
-
-/*
Appends value to dynamically allocated memory, doubling its allocation size
whenever needed.
diff --git a/zlib_container.c b/zlib_container.c
index 7d9f195..9a21231 100644
--- a/zlib_container.c
+++ b/zlib_container.c
@@ -18,6 +18,7 @@ Author: jyrki.alakuijala@gmail.com (Jyrki Alakuijala)
*/
#include "zlib_container.h"
+#include "util.h"
#include <stdio.h>
diff --git a/zlib_container.h b/zlib_container.h
index 05644a2..e83dadc 100644
--- a/zlib_container.h
+++ b/zlib_container.h
@@ -24,7 +24,7 @@ Author: jyrki.alakuijala@gmail.com (Jyrki Alakuijala)
Functions to compress according to the Zlib specification.
*/
-#include "util.h"
+#include "zopfli.h"
/*
Compresses according to the zlib specification and append the compressed
diff --git a/zopfli.c b/zopfli_bin.c
index f56d7d8..c649cf6 100644
--- a/zopfli.c
+++ b/zopfli_bin.c
@@ -76,17 +76,11 @@ static void SaveFile(const char* filename,
fclose(file);
}
-typedef enum {
- OUTPUT_GZIP,
- OUTPUT_ZLIB,
- OUTPUT_DEFLATE
-} OutputType;
-
/*
outfilename: filename to write output to, or 0 to write to stdout instead
*/
static void CompressFile(const ZopfliOptions* options,
- OutputType output_type,
+ ZopfliFormat output_type,
const char* infilename,
const char* outfilename) {
unsigned char* in;
@@ -98,17 +92,9 @@ static void CompressFile(const ZopfliOptions* options,
fprintf(stderr, "Invalid filename: %s\n", infilename);
return;
}
- if (output_type == OUTPUT_GZIP) {
- ZopfliGzipCompress(options, in, insize, &out, &outsize);
- } else if (output_type == OUTPUT_ZLIB) {
- ZopfliZlibCompress(options, in, insize, &out, &outsize);
- } else if (output_type == OUTPUT_DEFLATE) {
- unsigned char bp = 0;
- ZopfliDeflate(options, 2 /* Dynamic block */, 1,
- in, insize, &bp, &out, &outsize);
- } else {
- assert(0);
- }
+
+ ZopfliCompress(options, output_type, in, insize, &out, &outsize);
+
if (outfilename) {
SaveFile(outfilename, out, outsize);
} else {
@@ -141,19 +127,21 @@ static char StringsEqual(const char* str1, const char* str2) {
int main(int argc, char* argv[]) {
ZopfliOptions options;
+ ZopfliFormat output_type = ZOPFLI_FORMAT_GZIP;
const char* filename = 0;
int output_to_stdout = 0;
int i;
- OutputType output_type = OUTPUT_GZIP;
ZopfliInitOptions(&options);
for (i = 1; i < argc; i++) {
if (StringsEqual(argv[i], "-v")) options.verbose = 1;
else if (StringsEqual(argv[i], "-c")) output_to_stdout = 1;
- else if (StringsEqual(argv[i], "--deflate")) output_type = OUTPUT_DEFLATE;
- else if (StringsEqual(argv[i], "--zlib")) output_type = OUTPUT_ZLIB;
- else if (StringsEqual(argv[i], "--gzip")) output_type = OUTPUT_GZIP;
+ else if (StringsEqual(argv[i], "--deflate")) {
+ output_type = ZOPFLI_FORMAT_DEFLATE;
+ }
+ else if (StringsEqual(argv[i], "--zlib")) output_type = ZOPFLI_FORMAT_ZLIB;
+ else if (StringsEqual(argv[i], "--gzip")) output_type = ZOPFLI_FORMAT_GZIP;
else if (StringsEqual(argv[i], "--i5")) options.numiterations = 5;
else if (StringsEqual(argv[i], "--i10")) options.numiterations = 10;
else if (StringsEqual(argv[i], "--i15")) options.numiterations = 15;
@@ -191,12 +179,12 @@ int main(int argc, char* argv[]) {
filename = argv[i];
if (output_to_stdout) {
outfilename = 0;
- } else if (output_type == OUTPUT_GZIP) {
+ } else if (output_type == ZOPFLI_FORMAT_GZIP) {
outfilename = AddStrings(filename, ".gz");
- } else if (output_type == OUTPUT_ZLIB) {
+ } else if (output_type == ZOPFLI_FORMAT_ZLIB) {
outfilename = AddStrings(filename, ".zlib");
} else {
- assert(output_type == OUTPUT_DEFLATE);
+ assert(output_type == ZOPFLI_FORMAT_DEFLATE);
outfilename = AddStrings(filename, ".deflate");
}
if (options.verbose && outfilename) {