zopfli 0.0.5 → 0.0.7

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.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.gitmodules +1 -1
  3. data/.travis.yml +24 -0
  4. data/Gemfile +2 -0
  5. data/Rakefile +8 -10
  6. data/ext/extconf.rb +1 -0
  7. data/ext/zopfli.c +37 -17
  8. data/lib/zopfli/version.rb +1 -1
  9. data/smoke.sh +9 -0
  10. data/{test → spec}/fixtures/alice29.txt +0 -0
  11. data/spec/spec_helper.rb +2 -0
  12. data/spec/zopfli_spec.rb +68 -0
  13. data/vendor/zopfli/src/zopfli/blocksplitter.c +34 -44
  14. data/vendor/zopfli/src/zopfli/blocksplitter.h +2 -6
  15. data/vendor/zopfli/src/zopfli/cache.c +3 -1
  16. data/vendor/zopfli/src/zopfli/deflate.c +351 -287
  17. data/vendor/zopfli/src/zopfli/deflate.h +8 -2
  18. data/vendor/zopfli/src/zopfli/gzip_container.c +54 -47
  19. data/vendor/zopfli/src/zopfli/hash.c +18 -10
  20. data/vendor/zopfli/src/zopfli/hash.h +6 -3
  21. data/vendor/zopfli/src/zopfli/katajainen.c +73 -62
  22. data/vendor/zopfli/src/zopfli/lz77.c +190 -42
  23. data/vendor/zopfli/src/zopfli/lz77.h +32 -19
  24. data/vendor/zopfli/src/zopfli/squeeze.c +75 -61
  25. data/vendor/zopfli/src/zopfli/squeeze.h +1 -0
  26. data/vendor/zopfli/src/zopfli/symbols.h +239 -0
  27. data/vendor/zopfli/src/zopfli/util.c +0 -178
  28. data/vendor/zopfli/src/zopfli/util.h +6 -23
  29. data/vendor/zopfli/src/zopfli/zlib_container.c +1 -1
  30. data/vendor/zopfli/src/zopfli/zopfli.h +1 -4
  31. data/vendor/zopfli/src/zopfli/zopfli_bin.c +11 -8
  32. data/zopfli.gemspec +8 -27
  33. metadata +13 -20
  34. data/test/test_zopfli_deflate.rb +0 -45
  35. data/vendor/zopfli/CONTRIBUTING.md +0 -24
  36. data/vendor/zopfli/CONTRIBUTORS +0 -8
  37. data/vendor/zopfli/Makefile +0 -42
  38. data/vendor/zopfli/README +0 -32
  39. data/vendor/zopfli/README.zopflipng +0 -35
  40. data/vendor/zopfli/src/zopflipng/lodepng/lodepng.cpp +0 -6252
  41. data/vendor/zopfli/src/zopflipng/lodepng/lodepng.h +0 -1716
  42. data/vendor/zopfli/src/zopflipng/lodepng/lodepng_util.cpp +0 -656
  43. data/vendor/zopfli/src/zopflipng/lodepng/lodepng_util.h +0 -151
  44. data/vendor/zopfli/src/zopflipng/zopflipng_bin.cc +0 -408
  45. data/vendor/zopfli/src/zopflipng/zopflipng_lib.cc +0 -492
  46. data/vendor/zopfli/src/zopflipng/zopflipng_lib.h +0 -134
@@ -1,134 +0,0 @@
1
- // Copyright 2013 Google Inc. All Rights Reserved.
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
- //
15
- // Author: lode.vandevenne@gmail.com (Lode Vandevenne)
16
- // Author: jyrki.alakuijala@gmail.com (Jyrki Alakuijala)
17
-
18
- // Library to recompress and optimize PNG images. Uses Zopfli as the compression
19
- // backend, chooses optimal PNG color model, and tries out several PNG filter
20
- // strategies.
21
-
22
- #ifndef ZOPFLIPNG_LIB_H_
23
- #define ZOPFLIPNG_LIB_H_
24
-
25
- #ifdef __cplusplus
26
-
27
- #include <string>
28
- #include <vector>
29
-
30
- extern "C" {
31
-
32
- #endif
33
-
34
- #include <stdlib.h>
35
-
36
- enum ZopfliPNGFilterStrategy {
37
- kStrategyZero = 0,
38
- kStrategyOne = 1,
39
- kStrategyTwo = 2,
40
- kStrategyThree = 3,
41
- kStrategyFour = 4,
42
- kStrategyMinSum,
43
- kStrategyEntropy,
44
- kStrategyPredefined,
45
- kStrategyBruteForce,
46
- kNumFilterStrategies /* Not a strategy but used for the size of this enum */
47
- };
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
-
92
- struct ZopfliPNGOptions {
93
- ZopfliPNGOptions();
94
-
95
- bool verbose;
96
-
97
- // Allow altering hidden colors of fully transparent pixels
98
- bool lossy_transparent;
99
- // Convert 16-bit per channel images to 8-bit per channel
100
- bool lossy_8bit;
101
-
102
- // Filter strategies to try
103
- std::vector<ZopfliPNGFilterStrategy> filter_strategies;
104
-
105
- // Automatically choose filter strategy using less good compression
106
- bool auto_filter_strategy;
107
-
108
- // PNG chunks to keep
109
- // chunks to literally copy over from the original PNG to the resulting one
110
- std::vector<std::string> keepchunks;
111
-
112
- // Use Zopfli deflate compression
113
- bool use_zopfli;
114
-
115
- // Zopfli number of iterations
116
- int num_iterations;
117
-
118
- // Zopfli number of iterations on large images
119
- int num_iterations_large;
120
-
121
- // 0=none, 1=first, 2=last, 3=both
122
- int block_split_strategy;
123
- };
124
-
125
- // Returns 0 on success, error code otherwise.
126
- // If verbose is true, it will print some info while working.
127
- int ZopfliPNGOptimize(const std::vector<unsigned char>& origpng,
128
- const ZopfliPNGOptions& png_options,
129
- bool verbose,
130
- std::vector<unsigned char>* resultpng);
131
-
132
- #endif // __cplusplus
133
-
134
- #endif // ZOPFLIPNG_LIB_H_