zopfli 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +6 -1
- data/lib/zopfli/version.rb +1 -1
- data/test/test_zopfli_deflate.rb +5 -7
- data/vendor/zopfli/CONTRIBUTING.md +24 -0
- data/vendor/zopfli/CONTRIBUTORS +1 -0
- data/vendor/zopfli/Makefile +5 -0
- data/vendor/zopfli/src/zopfli/cache.c +4 -0
- data/vendor/zopfli/src/zopfli/deflate.c +4 -3
- data/vendor/zopfli/src/zopfli/hash.h +4 -4
- data/vendor/zopfli/src/zopfli/katajainen.h +1 -1
- data/vendor/zopfli/src/zopfli/zopfli_bin.c +19 -3
- data/vendor/zopfli/src/zopflipng/lodepng/lodepng.cpp +2 -10
- data/vendor/zopfli/src/zopflipng/zopflipng_bin.cc +3 -2
- data/vendor/zopfli/src/zopflipng/zopflipng_lib.cc +69 -2
- data/vendor/zopfli/src/zopflipng/zopflipng_lib.h +55 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ed0d8eec767ad3ac6d89fef3b9acb09e2cc1091
|
4
|
+
data.tar.gz: 9c9c5a832bcebf030c9e7950cf4c1165dd74f7e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7f5decb3aec6b12d4a868071fc92cc4156d80253eaed923296b7d14aa302398cccbc155c27b94c76f2af394d2c5949cedca2f856a99d1fb6c06e58db4567022
|
7
|
+
data.tar.gz: 980e462293ea31247405e54a9614d9948570bfb4936bd2179160b19d2b156879cc0a2dba5153c0b3151afbc12e949a375e558b8efe0e38a4a5484fe166d6b4d6
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Zopfli
|
2
2
|
|
3
|
-
see https://
|
3
|
+
see https://github.com/google/zopfli
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -30,6 +30,11 @@ compressed_data = Zopfli.deflate string
|
|
30
30
|
uncompressed_data = Zlib::Inflate.inflate compressed_data
|
31
31
|
uncompressed_data == string
|
32
32
|
# => true
|
33
|
+
|
34
|
+
Zlib.deflate(File.read('LICENSE.txt'), Zlib::BEST_COMPRESSION).bytesize
|
35
|
+
# => 628
|
36
|
+
Zopfli.deflate(File.read('LICENSE.txt')).bytesize
|
37
|
+
# => 601
|
33
38
|
```
|
34
39
|
|
35
40
|
## Contributing
|
data/lib/zopfli/version.rb
CHANGED
data/test/test_zopfli_deflate.rb
CHANGED
@@ -24,12 +24,9 @@ describe Zopfli do
|
|
24
24
|
it "gzip format works" do
|
25
25
|
fixture = fixtures("alice29.txt").read
|
26
26
|
|
27
|
-
|
27
|
+
deflated = Zopfli.deflate fixture, format: :gzip
|
28
28
|
|
29
|
-
uncompressed =
|
30
|
-
Zlib::GzipReader.wrap(StringIO.new gzipped) { |gz|
|
31
|
-
uncompressed = gz.read
|
32
|
-
}
|
29
|
+
uncompressed = Zlib::GzipReader.wrap(StringIO.new(deflated), &:read)
|
33
30
|
|
34
31
|
uncompressed.must_equal fixture
|
35
32
|
end
|
@@ -37,11 +34,12 @@ describe Zopfli do
|
|
37
34
|
it "deflate format works" do
|
38
35
|
fixture = fixtures("alice29.txt").read
|
39
36
|
|
40
|
-
|
37
|
+
Zopfli.deflate fixture, format: :deflate
|
38
|
+
|
41
39
|
skip "How to test"
|
42
40
|
end
|
43
41
|
|
44
42
|
def fixtures(name)
|
45
|
-
File.open(File.join
|
43
|
+
File.open(File.join(File.dirname(__FILE__), "fixtures", name))
|
46
44
|
end
|
47
45
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
Want to contribute? Great! First, read this page (including the small print at the end).
|
2
|
+
|
3
|
+
### Before you contribute
|
4
|
+
Before we can use your code, you must sign the
|
5
|
+
[Google Individual Contributor License Agreement](https://developers.google.com/open-source/cla/individual?csw=1)
|
6
|
+
(CLA), which you can do online. The CLA is necessary mainly because you own the
|
7
|
+
copyright to your changes, even after your contribution becomes part of our
|
8
|
+
codebase, so we need your permission to use and distribute your code. We also
|
9
|
+
need to be sure of various other things—for instance that you'll tell us if you
|
10
|
+
know that your code infringes on other people's patents. You don't have to sign
|
11
|
+
the CLA until after you've submitted your code for review and a member has
|
12
|
+
approved it, but you must do it before we can put your code into our codebase.
|
13
|
+
Before you start working on a larger contribution, you should get in touch with
|
14
|
+
us first through the issue tracker with your idea so that we can help out and
|
15
|
+
possibly guide you. Coordinating up front makes it much easier to avoid
|
16
|
+
frustration later on.
|
17
|
+
|
18
|
+
### Code reviews
|
19
|
+
All submissions, including submissions by project members, require review. We
|
20
|
+
use Github pull requests for this purpose.
|
21
|
+
|
22
|
+
### The small print
|
23
|
+
Contributions made by corporations are covered by a different agreement than
|
24
|
+
the one above, the Software Grant and Corporate Contributor License Agreement.
|
data/vendor/zopfli/CONTRIBUTORS
CHANGED
data/vendor/zopfli/Makefile
CHANGED
@@ -32,6 +32,11 @@ zopflipng:
|
|
32
32
|
$(CC) $(ZOPFLILIB_SRC) $(CFLAGS) -c
|
33
33
|
$(CXX) $(ZOPFLILIB_OBJ) $(LODEPNG_SRC) $(ZOPFLIPNGLIB_SRC) $(ZOPFLIPNGBIN_SRC) $(CFLAGS) -o zopflipng
|
34
34
|
|
35
|
+
# ZopfliPNG shared library
|
36
|
+
libzopflipng:
|
37
|
+
$(CC) $(ZOPFLILIB_SRC) $(CFLAGS) -fPIC -c
|
38
|
+
$(CXX) $(ZOPFLILIB_OBJ) $(LODEPNG_SRC) $(ZOPFLIPNGLIB_SRC) $(CFLAGS) -fPIC --shared -Wl,-soname,libzopflipng.so.1 -o libzopflipng.so.1.0.0
|
39
|
+
|
35
40
|
# Remove all libraries and binaries
|
36
41
|
clean:
|
37
42
|
rm -f zopflipng zopfli $(ZOPFLILIB_OBJ) libzopfli*
|
@@ -31,6 +31,10 @@ void ZopfliInitCache(size_t blocksize, ZopfliLongestMatchCache* lmc) {
|
|
31
31
|
lmc->dist = (unsigned short*)malloc(sizeof(unsigned short) * blocksize);
|
32
32
|
/* Rather large amount of memory. */
|
33
33
|
lmc->sublen = (unsigned char*)malloc(ZOPFLI_CACHE_LENGTH * 3 * blocksize);
|
34
|
+
if(lmc->sublen == NULL) {
|
35
|
+
fprintf(stderr,"Error: Out of memory. Tried allocating %lu bytes of memory.\n",(unsigned long)(ZOPFLI_CACHE_LENGTH * 3 * blocksize));
|
36
|
+
exit (EXIT_FAILURE);
|
37
|
+
}
|
34
38
|
|
35
39
|
/* length > 0 and dist 0 is invalid combination, which indicates on purpose
|
36
40
|
that this cache value is not filled in yet. */
|
@@ -536,7 +536,7 @@ static void AddLZ77Block(const ZopfliOptions* options, int btype, int final,
|
|
536
536
|
unsigned d_lengths[32];
|
537
537
|
unsigned ll_symbols[288];
|
538
538
|
unsigned d_symbols[32];
|
539
|
-
size_t detect_block_size
|
539
|
+
size_t detect_block_size;
|
540
540
|
size_t compressed_size;
|
541
541
|
size_t uncompressed_size = 0;
|
542
542
|
size_t i;
|
@@ -844,6 +844,7 @@ void ZopfliDeflatePart(const ZopfliOptions* options, int btype, int final,
|
|
844
844
|
void ZopfliDeflate(const ZopfliOptions* options, int btype, int final,
|
845
845
|
const unsigned char* in, size_t insize,
|
846
846
|
unsigned char* bp, unsigned char** out, size_t* outsize) {
|
847
|
+
size_t offset = *outsize;
|
847
848
|
#if ZOPFLI_MASTER_BLOCK_SIZE == 0
|
848
849
|
ZopfliDeflatePart(options, btype, final, in, 0, insize, bp, out, outsize);
|
849
850
|
#else
|
@@ -860,7 +861,7 @@ void ZopfliDeflate(const ZopfliOptions* options, int btype, int final,
|
|
860
861
|
if (options->verbose) {
|
861
862
|
fprintf(stderr,
|
862
863
|
"Original Size: %d, Deflate: %d, Compression: %f%% Removed\n",
|
863
|
-
(int)insize, (int)*outsize,
|
864
|
-
100.0 * (double)(insize - *outsize) / (double)insize);
|
864
|
+
(int)insize, (int)(*outsize - offset),
|
865
|
+
100.0 * (double)(insize - (*outsize - offset)) / (double)insize);
|
865
866
|
}
|
866
867
|
}
|
@@ -27,16 +27,16 @@ The hash for ZopfliFindLongestMatch of lz77.c.
|
|
27
27
|
#include "util.h"
|
28
28
|
|
29
29
|
typedef struct ZopfliHash {
|
30
|
-
int* head; /* Hash value to index of its most recent
|
31
|
-
unsigned short* prev; /* Index to index of prev.
|
30
|
+
int* head; /* Hash value to index of its most recent occurrence. */
|
31
|
+
unsigned short* prev; /* Index to index of prev. occurrence of same hash. */
|
32
32
|
int* hashval; /* Index to hash value at this index. */
|
33
33
|
int val; /* Current hash value. */
|
34
34
|
|
35
35
|
#ifdef ZOPFLI_HASH_SAME_HASH
|
36
36
|
/* Fields with similar purpose as the above hash, but for the second hash with
|
37
37
|
a value that is calculated differently. */
|
38
|
-
int* head2; /* Hash value to index of its most recent
|
39
|
-
unsigned short* prev2; /* Index to index of prev.
|
38
|
+
int* head2; /* Hash value to index of its most recent occurrence. */
|
39
|
+
unsigned short* prev2; /* Index to index of prev. occurrence of same hash. */
|
40
40
|
int* hashval2; /* Index to hash value at this index. */
|
41
41
|
int val2; /* Current hash value. */
|
42
42
|
#endif
|
@@ -30,7 +30,7 @@ The output is tailored for DEFLATE: symbols that never occur, get a bit length
|
|
30
30
|
of 0, and if only a single symbol occurs at least once, its bitlength will be 1,
|
31
31
|
and not 0 as would theoretically be needed for a single symbol.
|
32
32
|
|
33
|
-
frequencies: The amount of
|
33
|
+
frequencies: The amount of occurrences of each symbol.
|
34
34
|
n: The amount of symbols.
|
35
35
|
maxbits: Maximum bit length, inclusive.
|
36
36
|
bitlengths: Output, the bitlengths for the symbol prefix codes.
|
@@ -33,6 +33,11 @@ decompressor.
|
|
33
33
|
#include "gzip_container.h"
|
34
34
|
#include "zlib_container.h"
|
35
35
|
|
36
|
+
/* Windows workaround for stdout output. */
|
37
|
+
#if _WIN32
|
38
|
+
#include <fcntl.h>
|
39
|
+
#endif
|
40
|
+
|
36
41
|
/*
|
37
42
|
Loads a file into a memory array.
|
38
43
|
*/
|
@@ -47,6 +52,10 @@ static void LoadFile(const char* filename,
|
|
47
52
|
|
48
53
|
fseek(file , 0 , SEEK_END);
|
49
54
|
*outsize = ftell(file);
|
55
|
+
if(*outsize > 2147483647) {
|
56
|
+
fprintf(stderr,"Files larger than 2GB are not supported.\n");
|
57
|
+
exit(EXIT_FAILURE);
|
58
|
+
}
|
50
59
|
rewind(file);
|
51
60
|
|
52
61
|
*out = (unsigned char*)malloc(*outsize);
|
@@ -71,6 +80,10 @@ Saves a file from a memory array, overwriting the file if it existed.
|
|
71
80
|
static void SaveFile(const char* filename,
|
72
81
|
const unsigned char* in, size_t insize) {
|
73
82
|
FILE* file = fopen(filename, "wb" );
|
83
|
+
if (file == NULL) {
|
84
|
+
fprintf(stderr,"Error: Cannot write to output file, terminating.\n");
|
85
|
+
exit (EXIT_FAILURE);
|
86
|
+
}
|
74
87
|
assert(file);
|
75
88
|
fwrite((char*)in, 1, insize, file);
|
76
89
|
fclose(file);
|
@@ -99,8 +112,11 @@ static void CompressFile(const ZopfliOptions* options,
|
|
99
112
|
SaveFile(outfilename, out, outsize);
|
100
113
|
} else {
|
101
114
|
size_t i;
|
115
|
+
#if _WIN32
|
116
|
+
/* Windows workaround for stdout output. */
|
117
|
+
_setmode(_fileno(stdout), _O_BINARY);
|
118
|
+
#endif
|
102
119
|
for (i = 0; i < outsize; i++) {
|
103
|
-
/* Works only if terminal does not convert newlines. */
|
104
120
|
printf("%c", out[i]);
|
105
121
|
}
|
106
122
|
}
|
@@ -150,7 +166,7 @@ int main(int argc, char* argv[]) {
|
|
150
166
|
}
|
151
167
|
else if (StringsEqual(arg, "-h")) {
|
152
168
|
fprintf(stderr,
|
153
|
-
"Usage: zopfli [OPTION]... FILE
|
169
|
+
"Usage: zopfli [OPTION]... FILE...\n"
|
154
170
|
" -h gives this help\n"
|
155
171
|
" -c write the result on standard output, instead of disk"
|
156
172
|
" filename + '.gz'\n"
|
@@ -168,7 +184,7 @@ int main(int argc, char* argv[]) {
|
|
168
184
|
}
|
169
185
|
|
170
186
|
if (options.numiterations < 1) {
|
171
|
-
fprintf(stderr, "Error: must have 1 or more iterations");
|
187
|
+
fprintf(stderr, "Error: must have 1 or more iterations\n");
|
172
188
|
return 0;
|
173
189
|
}
|
174
190
|
|
@@ -5165,16 +5165,8 @@ static void filterScanline(unsigned char* out, const unsigned char* scanline, co
|
|
5165
5165
|
for(i = 0; i < length; i++) out[i] = scanline[i];
|
5166
5166
|
break;
|
5167
5167
|
case 1: /*Sub*/
|
5168
|
-
|
5169
|
-
|
5170
|
-
for(i = 0; i < bytewidth; i++) out[i] = scanline[i];
|
5171
|
-
for(i = bytewidth; i < length; i++) out[i] = scanline[i] - scanline[i - bytewidth];
|
5172
|
-
}
|
5173
|
-
else
|
5174
|
-
{
|
5175
|
-
for(i = 0; i < bytewidth; i++) out[i] = scanline[i];
|
5176
|
-
for(i = bytewidth; i < length; i++) out[i] = scanline[i] - scanline[i - bytewidth];
|
5177
|
-
}
|
5168
|
+
for(i = 0; i < bytewidth; i++) out[i] = scanline[i];
|
5169
|
+
for(i = bytewidth; i < length; i++) out[i] = scanline[i] - scanline[i - bytewidth];
|
5178
5170
|
break;
|
5179
5171
|
case 2: /*Up*/
|
5180
5172
|
if(prevline)
|
@@ -151,7 +151,6 @@ int main(int argc, char *argv[]) {
|
|
151
151
|
std::string prefix = "zopfli_"; // prefix for output filenames
|
152
152
|
|
153
153
|
std::vector<std::string> files;
|
154
|
-
std::vector<char> options;
|
155
154
|
for (int i = 1; i < argc; i++) {
|
156
155
|
std::string arg = argv[i];
|
157
156
|
if (arg[0] == '-' && arg.size() > 1 && arg[1] != '-') {
|
@@ -182,6 +181,8 @@ int main(int argc, char *argv[]) {
|
|
182
181
|
int num = atoi(value.c_str());
|
183
182
|
if (name == "--always_zopflify") {
|
184
183
|
always_zopflify = true;
|
184
|
+
} else if (name == "--verbose") {
|
185
|
+
png_options.verbose = true;
|
185
186
|
} else if (name == "--lossy_transparent") {
|
186
187
|
png_options.lossy_transparent = true;
|
187
188
|
} else if (name == "--lossy_8bit") {
|
@@ -291,7 +292,7 @@ int main(int argc, char *argv[]) {
|
|
291
292
|
error = ZopfliPNGOptimize(origpng, png_options, true, &resultpng);
|
292
293
|
|
293
294
|
if (error) {
|
294
|
-
printf("Decoding error %
|
295
|
+
printf("Decoding error %u: %s\n", error, lodepng_error_text(error));
|
295
296
|
}
|
296
297
|
|
297
298
|
// Verify result, check that the result causes no decoding errors
|
@@ -19,7 +19,10 @@
|
|
19
19
|
|
20
20
|
#include "zopflipng_lib.h"
|
21
21
|
|
22
|
+
#include <errno.h>
|
22
23
|
#include <stdio.h>
|
24
|
+
#include <stdlib.h>
|
25
|
+
#include <string.h>
|
23
26
|
#include <set>
|
24
27
|
#include <vector>
|
25
28
|
|
@@ -29,6 +32,7 @@
|
|
29
32
|
|
30
33
|
ZopfliPNGOptions::ZopfliPNGOptions()
|
31
34
|
: lossy_transparent(false)
|
35
|
+
, verbose(false)
|
32
36
|
, lossy_8bit(false)
|
33
37
|
, auto_filter_strategy(true)
|
34
38
|
, use_zopfli(true)
|
@@ -48,6 +52,7 @@ unsigned CustomPNGDeflate(unsigned char** out, size_t* outsize,
|
|
48
52
|
ZopfliOptions options;
|
49
53
|
ZopfliInitOptions(&options);
|
50
54
|
|
55
|
+
options.verbose = png_options->verbose;
|
51
56
|
options.numiterations = insize < 200000
|
52
57
|
? png_options->num_iterations : png_options->num_iterations_large;
|
53
58
|
|
@@ -81,7 +86,7 @@ unsigned CustomPNGDeflate(unsigned char** out, size_t* outsize,
|
|
81
86
|
|
82
87
|
// Returns 32-bit integer value for RGBA color.
|
83
88
|
static unsigned ColorIndex(const unsigned char* color) {
|
84
|
-
return color[0] + 256u * color[1] + 65536u * color[
|
89
|
+
return color[0] + 256u * color[1] + 65536u * color[2] + 16777216u * color[3];
|
85
90
|
}
|
86
91
|
|
87
92
|
// Counts amount of colors in the image, up to 257. If transparent_counts_as_one
|
@@ -128,6 +133,7 @@ void LossyOptimizeTransparent(lodepng::State* inputstate, unsigned char* image,
|
|
128
133
|
r = image[i * 4 + 0];
|
129
134
|
g = image[i * 4 + 1];
|
130
135
|
b = image[i * 4 + 2];
|
136
|
+
break;
|
131
137
|
}
|
132
138
|
}
|
133
139
|
}
|
@@ -366,7 +372,7 @@ int ZopfliPNGOptimize(const std::vector<unsigned char>& origpng,
|
|
366
372
|
|
367
373
|
if (error) {
|
368
374
|
if (verbose) {
|
369
|
-
printf("Decoding error %
|
375
|
+
printf("Decoding error %u: %s\n", error, lodepng_error_text(error));
|
370
376
|
}
|
371
377
|
return error;
|
372
378
|
}
|
@@ -423,3 +429,64 @@ int ZopfliPNGOptimize(const std::vector<unsigned char>& origpng,
|
|
423
429
|
|
424
430
|
return error;
|
425
431
|
}
|
432
|
+
|
433
|
+
extern "C" void CZopfliPNGSetDefaults(CZopfliPNGOptions* png_options) {
|
434
|
+
|
435
|
+
memset(png_options, 0, sizeof(*png_options));
|
436
|
+
// Constructor sets the defaults
|
437
|
+
ZopfliPNGOptions opts;
|
438
|
+
|
439
|
+
png_options->lossy_transparent = opts.lossy_transparent;
|
440
|
+
png_options->lossy_8bit = opts.lossy_8bit;
|
441
|
+
png_options->auto_filter_strategy = opts.auto_filter_strategy;
|
442
|
+
png_options->use_zopfli = opts.use_zopfli;
|
443
|
+
png_options->num_iterations = opts.num_iterations;
|
444
|
+
png_options->num_iterations_large = opts.num_iterations_large;
|
445
|
+
png_options->block_split_strategy = opts.block_split_strategy;
|
446
|
+
}
|
447
|
+
|
448
|
+
extern "C" int CZopfliPNGOptimize(const unsigned char* origpng,
|
449
|
+
const size_t origpng_size,
|
450
|
+
const CZopfliPNGOptions* png_options,
|
451
|
+
int verbose,
|
452
|
+
unsigned char** resultpng,
|
453
|
+
size_t* resultpng_size) {
|
454
|
+
ZopfliPNGOptions opts;
|
455
|
+
|
456
|
+
// Copy over to the C++-style struct
|
457
|
+
opts.lossy_transparent = !!png_options->lossy_transparent;
|
458
|
+
opts.lossy_8bit = !!png_options->lossy_8bit;
|
459
|
+
opts.auto_filter_strategy = !!png_options->auto_filter_strategy;
|
460
|
+
opts.use_zopfli = !!png_options->use_zopfli;
|
461
|
+
opts.num_iterations = png_options->num_iterations;
|
462
|
+
opts.num_iterations_large = png_options->num_iterations_large;
|
463
|
+
opts.block_split_strategy = png_options->block_split_strategy;
|
464
|
+
|
465
|
+
for (int i = 0; i < png_options->num_filter_strategies; i++) {
|
466
|
+
opts.filter_strategies.push_back(png_options->filter_strategies[i]);
|
467
|
+
}
|
468
|
+
|
469
|
+
for (int i = 0; i < png_options->num_keepchunks; i++) {
|
470
|
+
opts.keepchunks.push_back(png_options->keepchunks[i]);
|
471
|
+
}
|
472
|
+
|
473
|
+
const std::vector<unsigned char> origpng_cc(origpng, origpng + origpng_size);
|
474
|
+
std::vector<unsigned char> resultpng_cc;
|
475
|
+
|
476
|
+
int ret = ZopfliPNGOptimize(origpng_cc, opts, !!verbose, &resultpng_cc);
|
477
|
+
if (ret) {
|
478
|
+
return ret;
|
479
|
+
}
|
480
|
+
|
481
|
+
*resultpng_size = resultpng_cc.size();
|
482
|
+
*resultpng = (unsigned char*) malloc(resultpng_cc.size());
|
483
|
+
if (!(*resultpng)) {
|
484
|
+
return ENOMEM;
|
485
|
+
}
|
486
|
+
|
487
|
+
memcpy(*resultpng,
|
488
|
+
reinterpret_cast<unsigned char*>(&resultpng_cc[0]),
|
489
|
+
resultpng_cc.size());
|
490
|
+
|
491
|
+
return 0;
|
492
|
+
}
|
@@ -22,9 +22,17 @@
|
|
22
22
|
#ifndef ZOPFLIPNG_LIB_H_
|
23
23
|
#define ZOPFLIPNG_LIB_H_
|
24
24
|
|
25
|
+
#ifdef __cplusplus
|
26
|
+
|
25
27
|
#include <string>
|
26
28
|
#include <vector>
|
27
29
|
|
30
|
+
extern "C" {
|
31
|
+
|
32
|
+
#endif
|
33
|
+
|
34
|
+
#include <stdlib.h>
|
35
|
+
|
28
36
|
enum ZopfliPNGFilterStrategy {
|
29
37
|
kStrategyZero = 0,
|
30
38
|
kStrategyOne = 1,
|
@@ -38,9 +46,54 @@ enum ZopfliPNGFilterStrategy {
|
|
38
46
|
kNumFilterStrategies /* Not a strategy but used for the size of this enum */
|
39
47
|
};
|
40
48
|
|
49
|
+
typedef struct CZopfliPNGOptions {
|
50
|
+
int lossy_transparent;
|
51
|
+
int lossy_8bit;
|
52
|
+
|
53
|
+
enum ZopfliPNGFilterStrategy* filter_strategies;
|
54
|
+
// How many strategies to try.
|
55
|
+
int num_filter_strategies;
|
56
|
+
|
57
|
+
int auto_filter_strategy;
|
58
|
+
|
59
|
+
char** keepchunks;
|
60
|
+
// How many entries in keepchunks.
|
61
|
+
int num_keepchunks;
|
62
|
+
|
63
|
+
int use_zopfli;
|
64
|
+
|
65
|
+
int num_iterations;
|
66
|
+
|
67
|
+
int num_iterations_large;
|
68
|
+
|
69
|
+
int block_split_strategy;
|
70
|
+
} CZopfliPNGOptions;
|
71
|
+
|
72
|
+
// Sets the default options
|
73
|
+
// Does not allocate or set keepchunks or filter_strategies
|
74
|
+
void CZopfliPNGSetDefaults(CZopfliPNGOptions *png_options);
|
75
|
+
|
76
|
+
// Returns 0 on success, error code otherwise
|
77
|
+
// The caller must free resultpng after use
|
78
|
+
int CZopfliPNGOptimize(const unsigned char* origpng,
|
79
|
+
const size_t origpng_size,
|
80
|
+
const CZopfliPNGOptions* png_options,
|
81
|
+
int verbose,
|
82
|
+
unsigned char** resultpng,
|
83
|
+
size_t* resultpng_size);
|
84
|
+
|
85
|
+
#ifdef __cplusplus
|
86
|
+
} // extern "C"
|
87
|
+
#endif
|
88
|
+
|
89
|
+
// C++ API
|
90
|
+
#ifdef __cplusplus
|
91
|
+
|
41
92
|
struct ZopfliPNGOptions {
|
42
93
|
ZopfliPNGOptions();
|
43
94
|
|
95
|
+
bool verbose;
|
96
|
+
|
44
97
|
// Allow altering hidden colors of fully transparent pixels
|
45
98
|
bool lossy_transparent;
|
46
99
|
// Convert 16-bit per channel images to 8-bit per channel
|
@@ -76,4 +129,6 @@ int ZopfliPNGOptimize(const std::vector<unsigned char>& origpng,
|
|
76
129
|
bool verbose,
|
77
130
|
std::vector<unsigned char>* resultpng);
|
78
131
|
|
132
|
+
#endif // __cplusplus
|
133
|
+
|
79
134
|
#endif // ZOPFLIPNG_LIB_H_
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zopfli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- miyucy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -71,6 +71,7 @@ files:
|
|
71
71
|
- lib/zopfli/version.rb
|
72
72
|
- test/fixtures/alice29.txt
|
73
73
|
- test/test_zopfli_deflate.rb
|
74
|
+
- vendor/zopfli/CONTRIBUTING.md
|
74
75
|
- vendor/zopfli/CONTRIBUTORS
|
75
76
|
- vendor/zopfli/COPYING
|
76
77
|
- vendor/zopfli/Makefile
|
@@ -129,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
129
130
|
version: '0'
|
130
131
|
requirements: []
|
131
132
|
rubyforge_project:
|
132
|
-
rubygems_version: 2.
|
133
|
+
rubygems_version: 2.6.4
|
133
134
|
signing_key:
|
134
135
|
specification_version: 4
|
135
136
|
summary: zopfli
|