zopfli 0.0.2 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +6 -14
  2. data/.gitmodules +1 -1
  3. data/.travis.yml +23 -0
  4. data/Gemfile +2 -0
  5. data/README.md +6 -1
  6. data/Rakefile +8 -10
  7. data/ext/extconf.rb +2 -1
  8. data/ext/zopfli.c +39 -20
  9. data/lib/zopfli/version.rb +1 -1
  10. data/smoke.sh +9 -0
  11. data/{test → spec}/fixtures/alice29.txt +0 -0
  12. data/spec/spec_helper.rb +2 -0
  13. data/spec/zopfli_spec.rb +68 -0
  14. data/vendor/zopfli/{blocksplitter.c → src/zopfli/blocksplitter.c} +41 -53
  15. data/vendor/zopfli/{blocksplitter.h → src/zopfli/blocksplitter.h} +2 -6
  16. data/vendor/zopfli/{cache.c → src/zopfli/cache.c} +6 -0
  17. data/vendor/zopfli/{cache.h → src/zopfli/cache.h} +0 -0
  18. data/vendor/zopfli/src/zopfli/deflate.c +931 -0
  19. data/vendor/zopfli/{deflate.h → src/zopfli/deflate.h} +17 -2
  20. data/vendor/zopfli/src/zopfli/gzip_container.c +124 -0
  21. data/vendor/zopfli/{gzip_container.h → src/zopfli/gzip_container.h} +8 -0
  22. data/vendor/zopfli/{hash.c → src/zopfli/hash.c} +18 -10
  23. data/vendor/zopfli/{hash.h → src/zopfli/hash.h} +10 -7
  24. data/vendor/zopfli/{katajainen.c → src/zopfli/katajainen.c} +73 -62
  25. data/vendor/zopfli/{katajainen.h → src/zopfli/katajainen.h} +1 -1
  26. data/vendor/zopfli/{lz77.c → src/zopfli/lz77.c} +190 -42
  27. data/vendor/zopfli/{lz77.h → src/zopfli/lz77.h} +39 -23
  28. data/vendor/zopfli/{squeeze.c → src/zopfli/squeeze.c} +75 -61
  29. data/vendor/zopfli/{squeeze.h → src/zopfli/squeeze.h} +1 -0
  30. data/vendor/zopfli/{util.c → src/zopfli/symbols.h} +49 -23
  31. data/vendor/zopfli/{tree.c → src/zopfli/tree.c} +0 -0
  32. data/vendor/zopfli/{tree.h → src/zopfli/tree.h} +0 -0
  33. data/vendor/zopfli/src/zopfli/util.c +35 -0
  34. data/vendor/zopfli/{util.h → src/zopfli/util.h} +6 -23
  35. data/vendor/zopfli/{zlib_container.c → src/zopfli/zlib_container.c} +1 -1
  36. data/vendor/zopfli/{zlib_container.h → src/zopfli/zlib_container.h} +8 -0
  37. data/vendor/zopfli/{zopfli.h → src/zopfli/zopfli.h} +10 -4
  38. data/vendor/zopfli/{zopfli_bin.c → src/zopfli/zopfli_bin.c} +31 -15
  39. data/vendor/zopfli/{zopfli_lib.c → src/zopfli/zopfli_lib.c} +1 -2
  40. data/zopfli.gemspec +9 -28
  41. metadata +51 -50
  42. data/test/test_zopfli_deflate.rb +0 -47
  43. data/vendor/zopfli/CONTRIBUTORS +0 -6
  44. data/vendor/zopfli/README +0 -25
  45. data/vendor/zopfli/deflate.c +0 -698
  46. data/vendor/zopfli/gzip_container.c +0 -117
  47. data/vendor/zopfli/makefile +0 -5
@@ -1,117 +0,0 @@
1
- /*
2
- Copyright 2013 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)
18
- */
19
-
20
- #include "gzip_container.h"
21
- #include "util.h"
22
-
23
- #include <stdio.h>
24
-
25
- #include "deflate.h"
26
-
27
- /* Table of CRCs of all 8-bit messages. */
28
- static unsigned long crc_table[256];
29
-
30
- /* Flag: has the table been computed? Initially false. */
31
- static int crc_table_computed = 0;
32
-
33
- /* Makes the table for a fast CRC. */
34
- static void MakeCRCTable() {
35
- unsigned long c;
36
- int n, k;
37
- for (n = 0; n < 256; n++) {
38
- c = (unsigned long) n;
39
- for (k = 0; k < 8; k++) {
40
- if (c & 1) {
41
- c = 0xedb88320L ^ (c >> 1);
42
- } else {
43
- c = c >> 1;
44
- }
45
- }
46
- crc_table[n] = c;
47
- }
48
- crc_table_computed = 1;
49
- }
50
-
51
-
52
- /*
53
- Updates a running crc with the bytes buf[0..len-1] and returns
54
- the updated crc. The crc should be initialized to zero.
55
- */
56
- static unsigned long UpdateCRC(unsigned long crc,
57
- const unsigned char *buf, size_t len) {
58
- unsigned long c = crc ^ 0xffffffffL;
59
- unsigned n;
60
-
61
- if (!crc_table_computed)
62
- MakeCRCTable();
63
- for (n = 0; n < len; n++) {
64
- c = crc_table[(c ^ buf[n]) & 0xff] ^ (c >> 8);
65
- }
66
- return c ^ 0xffffffffL;
67
- }
68
-
69
- /* Returns the CRC of the bytes buf[0..len-1]. */
70
- static unsigned long CRC(const unsigned char* buf, int len) {
71
- return UpdateCRC(0L, buf, len);
72
- }
73
-
74
- /*
75
- Compresses the data according to the gzip specification.
76
- */
77
- void ZopfliGzipCompress(const ZopfliOptions* options,
78
- const unsigned char* in, size_t insize,
79
- unsigned char** out, size_t* outsize) {
80
- unsigned long crcvalue = CRC(in, insize);
81
- unsigned char bp = 0;
82
-
83
- ZOPFLI_APPEND_DATA(31, out, outsize); /* ID1 */
84
- ZOPFLI_APPEND_DATA(139, out, outsize); /* ID2 */
85
- ZOPFLI_APPEND_DATA(8, out, outsize); /* CM */
86
- ZOPFLI_APPEND_DATA(0, out, outsize); /* FLG */
87
- /* MTIME */
88
- ZOPFLI_APPEND_DATA(0, out, outsize);
89
- ZOPFLI_APPEND_DATA(0, out, outsize);
90
- ZOPFLI_APPEND_DATA(0, out, outsize);
91
- ZOPFLI_APPEND_DATA(0, out, outsize);
92
-
93
- ZOPFLI_APPEND_DATA(2, out, outsize); /* XFL, 2 indicates best compression. */
94
- ZOPFLI_APPEND_DATA(3, out, outsize); /* OS follows Unix conventions. */
95
-
96
- ZopfliDeflate(options, 2 /* Dynamic block */, 1,
97
- in, insize, &bp, out, outsize);
98
-
99
- /* CRC */
100
- ZOPFLI_APPEND_DATA(crcvalue % 256, out, outsize);
101
- ZOPFLI_APPEND_DATA((crcvalue >> 8) % 256, out, outsize);
102
- ZOPFLI_APPEND_DATA((crcvalue >> 16) % 256, out, outsize);
103
- ZOPFLI_APPEND_DATA((crcvalue >> 24) % 256, out, outsize);
104
-
105
- /* ISIZE */
106
- ZOPFLI_APPEND_DATA(insize % 256, out, outsize);
107
- ZOPFLI_APPEND_DATA((insize >> 8) % 256, out, outsize);
108
- ZOPFLI_APPEND_DATA((insize >> 16) % 256, out, outsize);
109
- ZOPFLI_APPEND_DATA((insize >> 24) % 256, out, outsize);
110
-
111
- if (options->verbose) {
112
- fprintf(stderr,
113
- "Original Size: %d, Gzip: %d, Compression: %f%% Removed\n",
114
- (int)insize, (int)*outsize,
115
- 100.0 * (double)(insize - *outsize) / (double)insize);
116
- }
117
- }
@@ -1,5 +0,0 @@
1
- make:
2
- gcc *.c -O2 -W -Wall -Wextra -ansi -pedantic -lm -o zopfli
3
-
4
- debug:
5
- gcc *.c -g3 -lm -o zopfli