zopfli 0.0.1 → 0.0.2
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 +8 -8
- data/README.md +9 -2
- data/ext/zopfli.c +59 -5
- data/lib/zopfli/version.rb +1 -1
- data/test/test_zopfli_deflate.rb +28 -5
- data/vendor/zopfli/README +4 -3
- data/vendor/zopfli/deflate.c +6 -5
- data/vendor/zopfli/gzip_container.c +2 -2
- data/vendor/zopfli/lz77.c +31 -17
- data/vendor/zopfli/squeeze.c +3 -0
- data/vendor/zopfli/util.c +11 -0
- data/vendor/zopfli/zlib_container.c +2 -2
- data/vendor/zopfli/zopfli.h +22 -5
- data/vendor/zopfli/zopfli_bin.c +27 -28
- data/vendor/zopfli/zopfli_lib.c +16 -10
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MWNkODM0N2JmMDRjNGNiNmIyYzliYWVjYWRiOWJjZTdjM2FhMTczZg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OWQ4YjNmMzBhNjc1NjRkOTUyYzk2Y2VkOTdmZmM3ODRmZTRjZjA4Nw==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OTQxNThkMzU3OWRkMmE0YzU5MzE0YTFlNjBiZjJjMzg4NGVjYTAyMjNjZTY4
|
10
|
+
OTk1OGUyYTRjMzM1ODE5YjAxMjEyZTg1ZTY0MzhjYWRhYmVjNGVmNTgyZjhi
|
11
|
+
YzA2MWFiOGQyNjZmMmFiMWI4OGFiMjI5YmUxZDhiYmExYmVkNDM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZjM1N2E1MjA5NDViMmZkYmFhZWVjZWQzODE2ZDAxMmZkNDUyNWMzMGZlMTBl
|
14
|
+
MWM0OTA3OGIzOGViOGE0YTAyZGVjNTliZmVlMjJlMjBmZDhiODdiZjE1OWM3
|
15
|
+
M2VmODAzMWUyNDQ4YzJiMjcwNDk3Mzg2YjUxMzA0MTY0NzQzMWU=
|
data/README.md
CHANGED
@@ -21,8 +21,15 @@ Or install it yourself as:
|
|
21
21
|
```ruby
|
22
22
|
require 'zopfli'
|
23
23
|
|
24
|
-
Zopfli.deflate
|
25
|
-
# =>
|
24
|
+
Zopfli.deflate string
|
25
|
+
# => compressed data
|
26
|
+
|
27
|
+
require 'zlib'
|
28
|
+
|
29
|
+
compressed_data = Zopfli.deflate string
|
30
|
+
uncompressed_data = Zlib::Inflate.inflate compressed_data
|
31
|
+
uncompressed_data == string
|
32
|
+
# => true
|
26
33
|
```
|
27
34
|
|
28
35
|
## Contributing
|
data/ext/zopfli.c
CHANGED
@@ -1,24 +1,78 @@
|
|
1
1
|
#include "ruby.h"
|
2
2
|
#include "zopfli.h"
|
3
3
|
|
4
|
+
#define CSTR2SYM(x) ID2SYM(rb_intern(x))
|
5
|
+
#define DEFAULT_FORMAT ZOPFLI_FORMAT_ZLIB
|
6
|
+
|
4
7
|
static VALUE rb_mZopfli;
|
5
8
|
|
9
|
+
ZopfliFormat
|
10
|
+
zopfli_deflate_parse_options(ZopfliOptions *options, VALUE opts)
|
11
|
+
{
|
12
|
+
ZopfliFormat format;
|
13
|
+
VALUE tmp;
|
14
|
+
|
15
|
+
tmp = rb_hash_aref(opts, CSTR2SYM("format"));
|
16
|
+
if (!NIL_P(tmp)) {
|
17
|
+
if (tmp == CSTR2SYM("deflate")) {
|
18
|
+
format = ZOPFLI_FORMAT_DEFLATE;
|
19
|
+
} else if (tmp == CSTR2SYM("gzip")) {
|
20
|
+
format = ZOPFLI_FORMAT_GZIP;
|
21
|
+
} else if (tmp == CSTR2SYM("zlib")) {
|
22
|
+
format = ZOPFLI_FORMAT_ZLIB;
|
23
|
+
} else {
|
24
|
+
rb_raise(rb_eArgError, "invalid format");
|
25
|
+
}
|
26
|
+
} else {
|
27
|
+
format = DEFAULT_FORMAT;
|
28
|
+
}
|
29
|
+
|
30
|
+
tmp = rb_hash_aref(opts, CSTR2SYM("num_iterations"));
|
31
|
+
if (!NIL_P(tmp)) {
|
32
|
+
options->numiterations = NUM2INT(tmp);
|
33
|
+
}
|
34
|
+
|
35
|
+
tmp = rb_hash_aref(opts, CSTR2SYM("block_splitting"));
|
36
|
+
if (!NIL_P(tmp)) {
|
37
|
+
options->blocksplitting = tmp == Qtrue;
|
38
|
+
}
|
39
|
+
|
40
|
+
tmp = rb_hash_aref(opts, CSTR2SYM("block_splitting_last"));
|
41
|
+
if (!NIL_P(tmp)) {
|
42
|
+
options->blocksplittinglast = tmp == Qtrue;
|
43
|
+
}
|
44
|
+
|
45
|
+
tmp = rb_hash_aref(opts, CSTR2SYM("block_splitting_max"));
|
46
|
+
if (!NIL_P(tmp)) {
|
47
|
+
options->blocksplittingmax = NUM2INT(tmp);
|
48
|
+
}
|
49
|
+
|
50
|
+
return format;
|
51
|
+
}
|
52
|
+
|
6
53
|
VALUE
|
7
54
|
zopfli_deflate(int argc, VALUE *argv, VALUE self)
|
8
55
|
{
|
9
|
-
VALUE
|
56
|
+
VALUE in, out, opts;
|
10
57
|
ZopfliOptions options;
|
58
|
+
ZopfliFormat format;
|
11
59
|
unsigned char *tmp = NULL;
|
12
60
|
size_t tmpsize = 0;
|
13
61
|
|
14
|
-
|
62
|
+
ZopfliInitOptions(&options);
|
15
63
|
|
16
|
-
|
64
|
+
rb_scan_args(argc, argv, "11", &in, &opts);
|
17
65
|
|
18
|
-
|
66
|
+
if (!NIL_P(opts)) {
|
67
|
+
format = zopfli_deflate_parse_options(&options, opts);
|
68
|
+
} else {
|
69
|
+
format = DEFAULT_FORMAT;
|
70
|
+
}
|
71
|
+
|
72
|
+
StringValue(in);
|
19
73
|
|
20
74
|
ZopfliCompress(&options,
|
21
|
-
|
75
|
+
format,
|
22
76
|
RSTRING_PTR(in), RSTRING_LEN(in),
|
23
77
|
&tmp, &tmpsize);
|
24
78
|
|
data/lib/zopfli/version.rb
CHANGED
data/test/test_zopfli_deflate.rb
CHANGED
@@ -5,17 +5,40 @@ require "stringio"
|
|
5
5
|
require "zlib"
|
6
6
|
|
7
7
|
describe Zopfli do
|
8
|
-
it "
|
8
|
+
it "works fine" do
|
9
9
|
fixture = fixtures("alice29.txt").read
|
10
10
|
|
11
|
-
|
11
|
+
Zopfli.deflate(fixture).must_equal(Zopfli.deflate(fixture, format: :zlib))
|
12
|
+
end
|
13
|
+
|
14
|
+
it "zlib format works" do
|
15
|
+
fixture = fixtures("alice29.txt").read
|
16
|
+
|
17
|
+
deflated = Zopfli.deflate fixture, format: :zlib
|
18
|
+
|
19
|
+
uncompressed = Zlib::Inflate.inflate deflated
|
20
|
+
|
21
|
+
uncompressed.must_equal fixture
|
22
|
+
end
|
23
|
+
|
24
|
+
it "gzip format works" do
|
25
|
+
fixture = fixtures("alice29.txt").read
|
26
|
+
|
27
|
+
gzipped = Zopfli.deflate fixture, format: :gzip
|
12
28
|
|
13
29
|
uncompressed = nil
|
14
|
-
Zlib::GzipReader.wrap(
|
30
|
+
Zlib::GzipReader.wrap(StringIO.new gzipped) { |gz|
|
15
31
|
uncompressed = gz.read
|
16
|
-
|
32
|
+
}
|
33
|
+
|
34
|
+
uncompressed.must_equal fixture
|
35
|
+
end
|
36
|
+
|
37
|
+
it "deflate format works" do
|
38
|
+
fixture = fixtures("alice29.txt").read
|
17
39
|
|
18
|
-
|
40
|
+
deflate = Zopfli.deflate fixture, format: :deflate
|
41
|
+
skip "How to test"
|
19
42
|
end
|
20
43
|
|
21
44
|
def fixtures(name)
|
data/vendor/zopfli/README
CHANGED
@@ -6,9 +6,10 @@ very well compressed gzip files.
|
|
6
6
|
|
7
7
|
The basic functions to compress data are ZopfliDeflate in deflate.h,
|
8
8
|
ZopfliZlibCompress in zlib_container.h and ZopfliGzipCompress in
|
9
|
-
gzip_container.h
|
10
|
-
|
11
|
-
|
9
|
+
gzip_container.h, or ZopfliCompress in zopfli.h.
|
10
|
+
Use the ZopfliOptions object to set parameters that affect the speed and
|
11
|
+
compression. Use the ZopfliInitOptions function to place the default values in
|
12
|
+
the ZopfliOptions first.
|
12
13
|
|
13
14
|
Deflate creates a valid deflate stream in memory, see:
|
14
15
|
http://www.ietf.org/rfc/rfc1951.txt
|
data/vendor/zopfli/deflate.c
CHANGED
@@ -17,11 +17,6 @@ Author: lode.vandevenne@gmail.com (Lode Vandevenne)
|
|
17
17
|
Author: jyrki.alakuijala@gmail.com (Jyrki Alakuijala)
|
18
18
|
*/
|
19
19
|
|
20
|
-
/*
|
21
|
-
Modified by madler@alumni.caltech.edu (Mark Adler)
|
22
|
-
Exposed DeflatePart() as an external function.
|
23
|
-
*/
|
24
|
-
|
25
20
|
#include "deflate.h"
|
26
21
|
|
27
22
|
#include <assert.h>
|
@@ -694,4 +689,10 @@ void ZopfliDeflate(const ZopfliOptions* options, int btype, int final,
|
|
694
689
|
i += size;
|
695
690
|
}
|
696
691
|
#endif
|
692
|
+
if (options->verbose) {
|
693
|
+
fprintf(stderr,
|
694
|
+
"Original Size: %d, Deflate: %d, Compression: %f%% Removed\n",
|
695
|
+
(int)insize, (int)*outsize,
|
696
|
+
100.0 * (double)(insize - *outsize) / (double)insize);
|
697
|
+
}
|
697
698
|
}
|
@@ -110,8 +110,8 @@ void ZopfliGzipCompress(const ZopfliOptions* options,
|
|
110
110
|
|
111
111
|
if (options->verbose) {
|
112
112
|
fprintf(stderr,
|
113
|
-
"Original Size: %d,
|
113
|
+
"Original Size: %d, Gzip: %d, Compression: %f%% Removed\n",
|
114
114
|
(int)insize, (int)*outsize,
|
115
|
-
100.
|
115
|
+
100.0 * (double)(insize - *outsize) / (double)insize);
|
116
116
|
}
|
117
117
|
}
|
data/vendor/zopfli/lz77.c
CHANGED
@@ -64,16 +64,30 @@ void ZopfliStoreLitLenDist(unsigned short length, unsigned short dist,
|
|
64
64
|
}
|
65
65
|
|
66
66
|
/*
|
67
|
-
Gets
|
68
|
-
length is the length, but if the distance is very long, decrease the
|
69
|
-
the length a bit to make up for the fact that long distances use large
|
70
|
-
of extra bits.
|
67
|
+
Gets a score of the length given the distance. Typically, the score of the
|
68
|
+
length is the length itself, but if the distance is very long, decrease the
|
69
|
+
score of the length a bit to make up for the fact that long distances use large
|
70
|
+
amounts of extra bits.
|
71
|
+
|
72
|
+
This is not an accurate score, it is a heuristic only for the greedy LZ77
|
73
|
+
implementation. More accurate cost models are employed later. Making this
|
74
|
+
heuristic more accurate may hurt rather than improve compression.
|
75
|
+
|
76
|
+
The two direct uses of this heuristic are:
|
77
|
+
-avoid using a length of 3 in combination with a long distance. This only has
|
78
|
+
an effect if length == 3.
|
79
|
+
-make a slightly better choice between the two options of the lazy matching.
|
80
|
+
|
81
|
+
Indirectly, this affects:
|
82
|
+
-the block split points if the default of block splitting first is used, in a
|
83
|
+
rather unpredictable way
|
84
|
+
-the first zopfli run, so it affects the chance of the first run being closer
|
85
|
+
to the optimal output
|
71
86
|
*/
|
72
|
-
static int
|
87
|
+
static int GetLengthScore(int length, int distance) {
|
73
88
|
/*
|
74
|
-
At
|
75
|
-
|
76
|
-
this seems to be the sweet spot.
|
89
|
+
At 1024, the distance uses 9+ extra bits and this seems to be the sweet spot
|
90
|
+
on tested files.
|
77
91
|
*/
|
78
92
|
return distance > 1024 ? length - 1 : length;
|
79
93
|
}
|
@@ -355,7 +369,7 @@ void ZopfliLZ77Greedy(ZopfliBlockState* s, const unsigned char* in,
|
|
355
369
|
size_t i = 0, j;
|
356
370
|
unsigned short leng;
|
357
371
|
unsigned short dist;
|
358
|
-
int
|
372
|
+
int lengthscore;
|
359
373
|
size_t windowstart = instart > ZOPFLI_WINDOW_SIZE
|
360
374
|
? instart - ZOPFLI_WINDOW_SIZE : 0;
|
361
375
|
unsigned short dummysublen[259];
|
@@ -367,7 +381,7 @@ void ZopfliLZ77Greedy(ZopfliBlockState* s, const unsigned char* in,
|
|
367
381
|
/* Lazy matching. */
|
368
382
|
unsigned prev_length = 0;
|
369
383
|
unsigned prev_match = 0;
|
370
|
-
int
|
384
|
+
int prevlengthscore;
|
371
385
|
int match_available = 0;
|
372
386
|
#endif
|
373
387
|
|
@@ -384,16 +398,16 @@ void ZopfliLZ77Greedy(ZopfliBlockState* s, const unsigned char* in,
|
|
384
398
|
|
385
399
|
ZopfliFindLongestMatch(s, h, in, i, inend, ZOPFLI_MAX_MATCH, dummysublen,
|
386
400
|
&dist, &leng);
|
387
|
-
|
401
|
+
lengthscore = GetLengthScore(leng, dist);
|
388
402
|
|
389
403
|
#ifdef ZOPFLI_LAZY_MATCHING
|
390
404
|
/* Lazy matching. */
|
391
|
-
|
405
|
+
prevlengthscore = GetLengthScore(prev_length, prev_match);
|
392
406
|
if (match_available) {
|
393
407
|
match_available = 0;
|
394
|
-
if (
|
408
|
+
if (lengthscore > prevlengthscore + 1) {
|
395
409
|
ZopfliStoreLitLenDist(in[i - 1], 0, store);
|
396
|
-
if (
|
410
|
+
if (lengthscore >= ZOPFLI_MIN_MATCH && leng < ZOPFLI_MAX_MATCH) {
|
397
411
|
match_available = 1;
|
398
412
|
prev_length = leng;
|
399
413
|
prev_match = dist;
|
@@ -403,7 +417,7 @@ void ZopfliLZ77Greedy(ZopfliBlockState* s, const unsigned char* in,
|
|
403
417
|
/* Add previous to output. */
|
404
418
|
leng = prev_length;
|
405
419
|
dist = prev_match;
|
406
|
-
|
420
|
+
lengthscore = prevlengthscore;
|
407
421
|
/* Add to output. */
|
408
422
|
ZopfliVerifyLenDist(in, inend, i - 1, dist, leng);
|
409
423
|
ZopfliStoreLitLenDist(leng, dist, store);
|
@@ -415,7 +429,7 @@ void ZopfliLZ77Greedy(ZopfliBlockState* s, const unsigned char* in,
|
|
415
429
|
continue;
|
416
430
|
}
|
417
431
|
}
|
418
|
-
else if (
|
432
|
+
else if (lengthscore >= ZOPFLI_MIN_MATCH && leng < ZOPFLI_MAX_MATCH) {
|
419
433
|
match_available = 1;
|
420
434
|
prev_length = leng;
|
421
435
|
prev_match = dist;
|
@@ -425,7 +439,7 @@ void ZopfliLZ77Greedy(ZopfliBlockState* s, const unsigned char* in,
|
|
425
439
|
#endif
|
426
440
|
|
427
441
|
/* Add to output. */
|
428
|
-
if (
|
442
|
+
if (lengthscore >= ZOPFLI_MIN_MATCH) {
|
429
443
|
ZopfliVerifyLenDist(in, inend, i, dist, leng);
|
430
444
|
ZopfliStoreLitLenDist(leng, dist, store);
|
431
445
|
} else {
|
data/vendor/zopfli/squeeze.c
CHANGED
@@ -486,6 +486,9 @@ void ZopfliLZ77Optimal(ZopfliBlockState *s,
|
|
486
486
|
¤tstore);
|
487
487
|
cost = ZopfliCalculateBlockSize(currentstore.litlens, currentstore.dists,
|
488
488
|
0, currentstore.size, 2);
|
489
|
+
if (s->options->verbose_more || (s->options->verbose && cost < bestcost)) {
|
490
|
+
fprintf(stderr, "Iteration %d: %d bit\n", i, (int) cost);
|
491
|
+
}
|
489
492
|
if (cost < bestcost) {
|
490
493
|
/* Copy to the output store. */
|
491
494
|
ZopfliCopyLZ77Store(¤tstore, store);
|
data/vendor/zopfli/util.c
CHANGED
@@ -19,6 +19,8 @@ Author: jyrki.alakuijala@gmail.com (Jyrki Alakuijala)
|
|
19
19
|
|
20
20
|
#include "util.h"
|
21
21
|
|
22
|
+
#include "zopfli.h"
|
23
|
+
|
22
24
|
#include <assert.h>
|
23
25
|
#include <stdio.h>
|
24
26
|
#include <stdlib.h>
|
@@ -200,3 +202,12 @@ int ZopfliGetLengthSymbol(int l) {
|
|
200
202
|
};
|
201
203
|
return table[l];
|
202
204
|
}
|
205
|
+
|
206
|
+
void ZopfliInitOptions(ZopfliOptions* options) {
|
207
|
+
options->verbose = 0;
|
208
|
+
options->verbose_more = 0;
|
209
|
+
options->numiterations = 15;
|
210
|
+
options->blocksplitting = 1;
|
211
|
+
options->blocksplittinglast = 0;
|
212
|
+
options->blocksplittingmax = 15;
|
213
|
+
}
|
@@ -72,8 +72,8 @@ void ZopfliZlibCompress(const ZopfliOptions* options,
|
|
72
72
|
|
73
73
|
if (options->verbose) {
|
74
74
|
fprintf(stderr,
|
75
|
-
"Original Size: %d,
|
75
|
+
"Original Size: %d, Zlib: %d, Compression: %f%% Removed\n",
|
76
76
|
(int)insize, (int)*outsize,
|
77
|
-
100.
|
77
|
+
100.0 * (double)(insize - *outsize) / (double)insize);
|
78
78
|
}
|
79
79
|
}
|
data/vendor/zopfli/zopfli.h
CHANGED
@@ -1,10 +1,24 @@
|
|
1
1
|
/*
|
2
|
-
Copyright
|
3
|
-
|
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)
|
4
18
|
*/
|
5
19
|
|
6
|
-
#ifndef
|
7
|
-
#define
|
20
|
+
#ifndef ZOPFLI_ZOPFLI_H_
|
21
|
+
#define ZOPFLI_ZOPFLI_H_
|
8
22
|
|
9
23
|
#include <stdlib.h> /* for size_t */
|
10
24
|
|
@@ -15,6 +29,9 @@ typedef struct ZopfliOptions {
|
|
15
29
|
/* Whether to print output */
|
16
30
|
int verbose;
|
17
31
|
|
32
|
+
/* Whether to print more detailed output */
|
33
|
+
int verbose_more;
|
34
|
+
|
18
35
|
/*
|
19
36
|
Maximum amount of times to rerun forward and backward pass to optimize LZ77
|
20
37
|
compression cost. Good values: 10, 15 for small files, 5 for files over
|
@@ -68,4 +85,4 @@ void ZopfliCompress(const ZopfliOptions* options, ZopfliFormat output_type,
|
|
68
85
|
const unsigned char* in, size_t insize,
|
69
86
|
unsigned char** out, size_t* outsize);
|
70
87
|
|
71
|
-
#endif /*
|
88
|
+
#endif /* ZOPFLI_ZOPFLI_H_ */
|
data/vendor/zopfli/zopfli_bin.c
CHANGED
@@ -135,44 +135,43 @@ int main(int argc, char* argv[]) {
|
|
135
135
|
ZopfliInitOptions(&options);
|
136
136
|
|
137
137
|
for (i = 1; i < argc; i++) {
|
138
|
-
|
139
|
-
|
140
|
-
else if (StringsEqual(
|
138
|
+
const char* arg = argv[i];
|
139
|
+
if (StringsEqual(arg, "-v")) options.verbose = 1;
|
140
|
+
else if (StringsEqual(arg, "-c")) output_to_stdout = 1;
|
141
|
+
else if (StringsEqual(arg, "--deflate")) {
|
141
142
|
output_type = ZOPFLI_FORMAT_DEFLATE;
|
142
143
|
}
|
143
|
-
else if (StringsEqual(
|
144
|
-
else if (StringsEqual(
|
145
|
-
else if (StringsEqual(
|
146
|
-
else if (
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
else if (StringsEqual(
|
151
|
-
|
152
|
-
|
153
|
-
else if (StringsEqual(argv[i], "--i1000")) options.numiterations = 1000;
|
154
|
-
else if (StringsEqual(argv[i], "-h")) {
|
155
|
-
fprintf(stderr, "Usage: zopfli [OPTION]... FILE\n"
|
144
|
+
else if (StringsEqual(arg, "--zlib")) output_type = ZOPFLI_FORMAT_ZLIB;
|
145
|
+
else if (StringsEqual(arg, "--gzip")) output_type = ZOPFLI_FORMAT_GZIP;
|
146
|
+
else if (StringsEqual(arg, "--splitlast")) options.blocksplittinglast = 1;
|
147
|
+
else if (arg[0] == '-' && arg[1] == '-' && arg[2] == 'i'
|
148
|
+
&& arg[3] >= '0' && arg[3] <= '9') {
|
149
|
+
options.numiterations = atoi(arg + 3);
|
150
|
+
}
|
151
|
+
else if (StringsEqual(arg, "-h")) {
|
152
|
+
fprintf(stderr,
|
153
|
+
"Usage: zopfli [OPTION]... FILE\n"
|
156
154
|
" -h gives this help\n"
|
157
155
|
" -c write the result on standard output, instead of disk"
|
158
156
|
" filename + '.gz'\n"
|
159
157
|
" -v verbose mode\n"
|
160
|
-
" --
|
161
|
-
"
|
162
|
-
"
|
163
|
-
fprintf(stderr,
|
164
|
-
" --
|
165
|
-
" --
|
166
|
-
" --
|
167
|
-
" --
|
168
|
-
" --i100 more compression, but slower\n"
|
169
|
-
" --i250 more compression, but slower\n"
|
170
|
-
" --i500 more compression, but slower\n"
|
171
|
-
" --i1000 more compression, but slower\n");
|
158
|
+
" --i# perform # iterations (default 15). More gives"
|
159
|
+
" more compression but is slower."
|
160
|
+
" Examples: --i10, --i50, --i1000\n");
|
161
|
+
fprintf(stderr,
|
162
|
+
" --gzip output to gzip format (default)\n"
|
163
|
+
" --zlib output to zlib format instead of gzip\n"
|
164
|
+
" --deflate output to deflate format instead of gzip\n"
|
165
|
+
" --splitlast do block splitting last instead of first\n");
|
172
166
|
return 0;
|
173
167
|
}
|
174
168
|
}
|
175
169
|
|
170
|
+
if (options.numiterations < 1) {
|
171
|
+
fprintf(stderr, "Error: must have 1 or more iterations");
|
172
|
+
return 0;
|
173
|
+
}
|
174
|
+
|
176
175
|
for (i = 1; i < argc; i++) {
|
177
176
|
if (argv[i][0] != '-') {
|
178
177
|
char* outfilename;
|
data/vendor/zopfli/zopfli_lib.c
CHANGED
@@ -1,6 +1,20 @@
|
|
1
1
|
/*
|
2
|
-
Copyright
|
3
|
-
|
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)
|
4
18
|
*/
|
5
19
|
|
6
20
|
#include "zopfli.h"
|
@@ -11,14 +25,6 @@ Author: lode@google.com (Lode Vandevenne)
|
|
11
25
|
|
12
26
|
#include <assert.h>
|
13
27
|
|
14
|
-
void ZopfliInitOptions(ZopfliOptions* options) {
|
15
|
-
options->verbose = 0;
|
16
|
-
options->numiterations = 15;
|
17
|
-
options->blocksplitting = 1;
|
18
|
-
options->blocksplittinglast = 0;
|
19
|
-
options->blocksplittingmax = 15;
|
20
|
-
}
|
21
|
-
|
22
28
|
void ZopfliCompress(const ZopfliOptions* options, ZopfliFormat output_type,
|
23
29
|
const unsigned char* in, size_t insize,
|
24
30
|
unsigned char** out, size_t* outsize)
|
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- miyucy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -121,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
121
|
version: '0'
|
122
122
|
requirements: []
|
123
123
|
rubyforge_project:
|
124
|
-
rubygems_version: 2.0.
|
124
|
+
rubygems_version: 2.0.3
|
125
125
|
signing_key:
|
126
126
|
specification_version: 4
|
127
127
|
summary: zopfli
|