zopfli 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZTViMWU0NzQwNmI3OWQ5NGYyOWNmYmNmYTg0ZDI0YTUxNTdiYmRlOQ==
4
+ MWNkODM0N2JmMDRjNGNiNmIyYzliYWVjYWRiOWJjZTdjM2FhMTczZg==
5
5
  data.tar.gz: !binary |-
6
- Y2ZjNjQxYjNhMWIxOGMxNDRhY2MxMDAyMTdkY2E5OWIzMjc4NjAzYQ==
6
+ OWQ4YjNmMzBhNjc1NjRkOTUyYzk2Y2VkOTdmZmM3ODRmZTRjZjA4Nw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- M2U3YmZkODQzYmFkNGFjMzFjMDExNGIzNjZhMGIwN2I1YTc2NjBhZTAyYzA1
10
- NWYxYTM0NzBkNzA1NjFiYTgwYjY4ZDYzN2YwZmM4Njg5YTgzZTcwOTFiMDY3
11
- NWZhNjIwZTM4NWQxMWMwOGFhMjUzMTcyNDgxNjJkN2YyZTVjMWQ=
9
+ OTQxNThkMzU3OWRkMmE0YzU5MzE0YTFlNjBiZjJjMzg4NGVjYTAyMjNjZTY4
10
+ OTk1OGUyYTRjMzM1ODE5YjAxMjEyZTg1ZTY0MzhjYWRhYmVjNGVmNTgyZjhi
11
+ YzA2MWFiOGQyNjZmMmFiMWI4OGFiMjI5YmUxZDhiYmExYmVkNDM=
12
12
  data.tar.gz: !binary |-
13
- Zjg3OTc4NTcyNWVkZDI0ZWNmZGM4YzZjZmMwNzVjMzRhN2M5OTkzMjUyMzYz
14
- M2ZlOWNkM2VlNTdkODEzNzhiYzExMGIxODgxYjNiN2QwY2E3MDMyNzhmZjdl
15
- OWU0MGIyMGY1N2YyYjAwMmMwNWYzZWUxMDI2ZTc5YzQyMzI3NjQ=
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 gzipped_string
25
- # => ungzipped data
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 in, out, opt;
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
- rb_scan_args(argc, argv, "1", &in);
62
+ ZopfliInitOptions(&options);
15
63
 
16
- StringValue(in);
64
+ rb_scan_args(argc, argv, "11", &in, &opts);
17
65
 
18
- ZopfliInitOptions(&options);
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
- ZOPFLI_FORMAT_GZIP,
75
+ format,
22
76
  RSTRING_PTR(in), RSTRING_LEN(in),
23
77
  &tmp, &tmpsize);
24
78
 
@@ -1,3 +1,3 @@
1
1
  module Zopfli
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -5,17 +5,40 @@ require "stringio"
5
5
  require "zlib"
6
6
 
7
7
  describe Zopfli do
8
- it "should compatible to gzip" do
8
+ it "works fine" do
9
9
  fixture = fixtures("alice29.txt").read
10
10
 
11
- sio = StringIO.new(Zopfli.deflate fixture)
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(sio) do |gz|
30
+ Zlib::GzipReader.wrap(StringIO.new gzipped) { |gz|
15
31
  uncompressed = gz.read
16
- end
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
- fixture.must_equal uncompressed
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. Use the ZopfliOptions object to set parameters that affect the
10
- speed and compression. Use the ZopfliInitOptions function to place the default
11
- values in the ZopfliOptions first.
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
@@ -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, Compressed: %d, Compression: %f%% Removed\n",
113
+ "Original Size: %d, Gzip: %d, Compression: %f%% Removed\n",
114
114
  (int)insize, (int)*outsize,
115
- 100.0f * (float)(insize - *outsize) / (float)insize);
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 the value of the length given the distance. Typically, the value of the
68
- length is the length, but if the distance is very long, decrease the value of
69
- the length a bit to make up for the fact that long distances use large amounts
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 GetLengthValue(int length, int distance) {
87
+ static int GetLengthScore(int length, int distance) {
73
88
  /*
74
- At distance > 1024, using length 3 is no longer good, due to the large amount
75
- of extra bits for the distance code. distance > 1024 uses 9+ extra bits, and
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 lengvalue;
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 prevlengvalue;
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
- lengvalue = GetLengthValue(leng, dist);
401
+ lengthscore = GetLengthScore(leng, dist);
388
402
 
389
403
  #ifdef ZOPFLI_LAZY_MATCHING
390
404
  /* Lazy matching. */
391
- prevlengvalue = GetLengthValue(prev_length, prev_match);
405
+ prevlengthscore = GetLengthScore(prev_length, prev_match);
392
406
  if (match_available) {
393
407
  match_available = 0;
394
- if (lengvalue > prevlengvalue + 1) {
408
+ if (lengthscore > prevlengthscore + 1) {
395
409
  ZopfliStoreLitLenDist(in[i - 1], 0, store);
396
- if (lengvalue >= ZOPFLI_MIN_MATCH && lengvalue < ZOPFLI_MAX_MATCH) {
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
- lengvalue = prevlengvalue;
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 (lengvalue >= ZOPFLI_MIN_MATCH && leng < ZOPFLI_MAX_MATCH) {
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 (lengvalue >= ZOPFLI_MIN_MATCH) {
442
+ if (lengthscore >= ZOPFLI_MIN_MATCH) {
429
443
  ZopfliVerifyLenDist(in, inend, i, dist, leng);
430
444
  ZopfliStoreLitLenDist(leng, dist, store);
431
445
  } else {
@@ -486,6 +486,9 @@ void ZopfliLZ77Optimal(ZopfliBlockState *s,
486
486
  &currentstore);
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(&currentstore, 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, Compressed: %d, Compression: %f%% Removed\n",
75
+ "Original Size: %d, Zlib: %d, Compression: %f%% Removed\n",
76
76
  (int)insize, (int)*outsize,
77
- 100.0f * (float)(insize - *outsize) / (float)insize);
77
+ 100.0 * (double)(insize - *outsize) / (double)insize);
78
78
  }
79
79
  }
@@ -1,10 +1,24 @@
1
1
  /*
2
- Copyright 2013 Google Inc. All Rights Reserved.
3
- Author: lode@google.com (Lode Vandevenne)
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 UTIL_COMPRESSION_ZOPFLI_INTERNAL_ZOPFLI_H_
7
- #define UTIL_COMPRESSION_ZOPFLI_INTERNAL_ZOPFLI_H_
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 /* UTIL_COMPRESSION_ZOPFLI_INTERNAL_ZOPFLI_H_ */
88
+ #endif /* ZOPFLI_ZOPFLI_H_ */
@@ -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
- if (StringsEqual(argv[i], "-v")) options.verbose = 1;
139
- else if (StringsEqual(argv[i], "-c")) output_to_stdout = 1;
140
- else if (StringsEqual(argv[i], "--deflate")) {
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(argv[i], "--zlib")) output_type = ZOPFLI_FORMAT_ZLIB;
144
- else if (StringsEqual(argv[i], "--gzip")) output_type = ZOPFLI_FORMAT_GZIP;
145
- else if (StringsEqual(argv[i], "--i5")) options.numiterations = 5;
146
- else if (StringsEqual(argv[i], "--i10")) options.numiterations = 10;
147
- else if (StringsEqual(argv[i], "--i15")) options.numiterations = 15;
148
- else if (StringsEqual(argv[i], "--i25")) options.numiterations = 25;
149
- else if (StringsEqual(argv[i], "--i50")) options.numiterations = 50;
150
- else if (StringsEqual(argv[i], "--i100")) options.numiterations = 100;
151
- else if (StringsEqual(argv[i], "--i250")) options.numiterations = 250;
152
- else if (StringsEqual(argv[i], "--i500")) options.numiterations = 500;
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
- " --gzip output to gzip format (default)\n"
161
- " --deflate output to deflate format instead of gzip\n"
162
- " --zlib output to zlib format instead of gzip\n");
163
- fprintf(stderr, " --i5 less compression, but faster\n"
164
- " --i10 less compression, but faster\n"
165
- " --i15 default compression, 15 iterations\n"
166
- " --i25 more compression, but slower\n"
167
- " --i50 more compression, but slower\n"
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;
@@ -1,6 +1,20 @@
1
1
  /*
2
- Copyright 2013 Google Inc. All Rights Reserved.
3
- Author: lode@google.com (Lode Vandevenne)
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.1
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-03-07 00:00:00.000000000 Z
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.0
124
+ rubygems_version: 2.0.3
125
125
  signing_key:
126
126
  specification_version: 4
127
127
  summary: zopfli