image_pack 0.2.2 → 0.2.3

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 (85) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +1 -0
  3. data/README.md +23 -4
  4. data/ext/image_pack/extconf.rb +35 -124
  5. data/ext/image_pack/image_pack.c +638 -595
  6. data/ext/image_pack/mozjpeg_sources.rb +178 -0
  7. data/ext/image_pack/vendor/mozjpeg/BUILDING.md +744 -0
  8. data/ext/image_pack/vendor/mozjpeg/CODE_OF_CONDUCT.md +15 -0
  9. data/ext/image_pack/vendor/mozjpeg/ChangeLog.md +1996 -0
  10. data/lib/image_pack/configuration.rb +54 -8
  11. data/lib/image_pack/version.rb +1 -1
  12. data/lib/image_pack.rb +65 -18
  13. metadata +13 -78
  14. data/ext/image_pack/vendor/mozjpeg/README.ijg +0 -258
  15. data/ext/image_pack/vendor/mozjpeg/cdjpeg.c +0 -156
  16. data/ext/image_pack/vendor/mozjpeg/cjpeg.c +0 -961
  17. data/ext/image_pack/vendor/mozjpeg/djpeg.c +0 -855
  18. data/ext/image_pack/vendor/mozjpeg/jaricom.c +0 -157
  19. data/ext/image_pack/vendor/mozjpeg/jcarith.c +0 -972
  20. data/ext/image_pack/vendor/mozjpeg/jcstest.c +0 -126
  21. data/ext/image_pack/vendor/mozjpeg/jdarith.c +0 -782
  22. data/ext/image_pack/vendor/mozjpeg/jdatadst-tj.c +0 -198
  23. data/ext/image_pack/vendor/mozjpeg/jdatasrc-tj.c +0 -194
  24. data/ext/image_pack/vendor/mozjpeg/jpegtran.c +0 -827
  25. data/ext/image_pack/vendor/mozjpeg/jpegyuv.c +0 -172
  26. data/ext/image_pack/vendor/mozjpeg/rdbmp.c +0 -690
  27. data/ext/image_pack/vendor/mozjpeg/rdcolmap.c +0 -253
  28. data/ext/image_pack/vendor/mozjpeg/rdgif.c +0 -720
  29. data/ext/image_pack/vendor/mozjpeg/rdjpeg.c +0 -160
  30. data/ext/image_pack/vendor/mozjpeg/rdjpgcom.c +0 -494
  31. data/ext/image_pack/vendor/mozjpeg/rdpng.c +0 -194
  32. data/ext/image_pack/vendor/mozjpeg/rdppm.c +0 -781
  33. data/ext/image_pack/vendor/mozjpeg/rdswitch.c +0 -642
  34. data/ext/image_pack/vendor/mozjpeg/rdtarga.c +0 -508
  35. data/ext/image_pack/vendor/mozjpeg/simd/arm/aarch32/jccolext-neon.c +0 -148
  36. data/ext/image_pack/vendor/mozjpeg/simd/arm/aarch32/jchuff-neon.c +0 -334
  37. data/ext/image_pack/vendor/mozjpeg/simd/arm/aarch32/jsimd.c +0 -976
  38. data/ext/image_pack/vendor/mozjpeg/simd/i386/jsimd.c +0 -1312
  39. data/ext/image_pack/vendor/mozjpeg/simd/mips/jsimd.c +0 -1143
  40. data/ext/image_pack/vendor/mozjpeg/simd/mips64/jccolext-mmi.c +0 -455
  41. data/ext/image_pack/vendor/mozjpeg/simd/mips64/jccolor-mmi.c +0 -148
  42. data/ext/image_pack/vendor/mozjpeg/simd/mips64/jcgray-mmi.c +0 -132
  43. data/ext/image_pack/vendor/mozjpeg/simd/mips64/jcgryext-mmi.c +0 -374
  44. data/ext/image_pack/vendor/mozjpeg/simd/mips64/jcsample-mmi.c +0 -98
  45. data/ext/image_pack/vendor/mozjpeg/simd/mips64/jdcolext-mmi.c +0 -415
  46. data/ext/image_pack/vendor/mozjpeg/simd/mips64/jdcolor-mmi.c +0 -139
  47. data/ext/image_pack/vendor/mozjpeg/simd/mips64/jdmerge-mmi.c +0 -149
  48. data/ext/image_pack/vendor/mozjpeg/simd/mips64/jdmrgext-mmi.c +0 -615
  49. data/ext/image_pack/vendor/mozjpeg/simd/mips64/jdsample-mmi.c +0 -304
  50. data/ext/image_pack/vendor/mozjpeg/simd/mips64/jfdctfst-mmi.c +0 -255
  51. data/ext/image_pack/vendor/mozjpeg/simd/mips64/jfdctint-mmi.c +0 -398
  52. data/ext/image_pack/vendor/mozjpeg/simd/mips64/jidctfst-mmi.c +0 -395
  53. data/ext/image_pack/vendor/mozjpeg/simd/mips64/jidctint-mmi.c +0 -571
  54. data/ext/image_pack/vendor/mozjpeg/simd/mips64/jquanti-mmi.c +0 -124
  55. data/ext/image_pack/vendor/mozjpeg/simd/mips64/jsimd.c +0 -866
  56. data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jccolext-altivec.c +0 -269
  57. data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jccolor-altivec.c +0 -116
  58. data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jcgray-altivec.c +0 -111
  59. data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jcgryext-altivec.c +0 -228
  60. data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jcsample-altivec.c +0 -159
  61. data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jdcolext-altivec.c +0 -276
  62. data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jdcolor-altivec.c +0 -106
  63. data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jdmerge-altivec.c +0 -130
  64. data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jdmrgext-altivec.c +0 -329
  65. data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jdsample-altivec.c +0 -400
  66. data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jfdctfst-altivec.c +0 -154
  67. data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jfdctint-altivec.c +0 -258
  68. data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jidctfst-altivec.c +0 -255
  69. data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jidctint-altivec.c +0 -357
  70. data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jquanti-altivec.c +0 -250
  71. data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jsimd.c +0 -884
  72. data/ext/image_pack/vendor/mozjpeg/strtest.c +0 -170
  73. data/ext/image_pack/vendor/mozjpeg/tjbench.c +0 -1044
  74. data/ext/image_pack/vendor/mozjpeg/tjexample.c +0 -406
  75. data/ext/image_pack/vendor/mozjpeg/tjunittest.c +0 -961
  76. data/ext/image_pack/vendor/mozjpeg/tjutil.c +0 -70
  77. data/ext/image_pack/vendor/mozjpeg/transupp.c +0 -2373
  78. data/ext/image_pack/vendor/mozjpeg/turbojpeg-jni.c +0 -1259
  79. data/ext/image_pack/vendor/mozjpeg/turbojpeg.c +0 -2320
  80. data/ext/image_pack/vendor/mozjpeg/wrbmp.c +0 -552
  81. data/ext/image_pack/vendor/mozjpeg/wrgif.c +0 -580
  82. data/ext/image_pack/vendor/mozjpeg/wrjpgcom.c +0 -577
  83. data/ext/image_pack/vendor/mozjpeg/wrppm.c +0 -366
  84. data/ext/image_pack/vendor/mozjpeg/wrtarga.c +0 -258
  85. data/ext/image_pack/vendor/mozjpeg/yuvjpeg.c +0 -268
@@ -1,194 +0,0 @@
1
-
2
- #include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
3
-
4
- #ifdef PNG_SUPPORTED
5
-
6
- #include <png.h> /* if this fails, you need to install libpng-devel */
7
-
8
-
9
- typedef struct png_source_struct {
10
- struct cjpeg_source_struct pub;
11
- png_structp png_ptr;
12
- png_infop info_ptr;
13
- JDIMENSION current_row;
14
- } png_source_struct;
15
-
16
-
17
- METHODDEF(void)
18
- finish_input_png (j_compress_ptr cinfo, cjpeg_source_ptr sinfo);
19
-
20
- METHODDEF(JDIMENSION)
21
- get_pixel_rows_png (j_compress_ptr cinfo, cjpeg_source_ptr sinfo);
22
-
23
- METHODDEF(void)
24
- start_input_png (j_compress_ptr cinfo, cjpeg_source_ptr sinfo);
25
-
26
-
27
- GLOBAL(cjpeg_source_ptr)
28
- jinit_read_png(j_compress_ptr cinfo)
29
- {
30
- png_source_struct *source = (*cinfo->mem->alloc_small)((j_common_ptr) cinfo, JPOOL_IMAGE, sizeof(png_source_struct));
31
-
32
- memset(source, 0, sizeof(*source));
33
-
34
- /* Fill in method ptrs, except get_pixel_rows which start_input sets */
35
- source->pub.start_input = start_input_png;
36
- source->pub.finish_input = finish_input_png;
37
-
38
- return &source->pub;
39
- }
40
-
41
- METHODDEF(void) error_input_png(png_structp png_ptr, png_const_charp msg) {
42
- j_compress_ptr cinfo = png_get_error_ptr(png_ptr);
43
- ERREXITS(cinfo, JERR_PNG_ERROR, msg);
44
- }
45
-
46
- /* This is a small ICC profile for sRGB */
47
- static unsigned char tiny_srgb[] = {0,0,2,24,108,99,109,115,2,16,0,0,109,110,
48
- 116,114,82,71,66,32,88,89,90,32,7,220,0,1,0,25,0,3,0,41,0,57,97,99,115,112,65,
49
- 80,80,76,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,246,214,0,1,0,0,0,
50
- 0,211,45,108,99,109,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
51
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,100,101,115,99,0,0,0,252,0,0,0,106,
52
- 99,112,114,116,0,0,1,104,0,0,0,11,119,116,112,116,0,0,1,116,0,0,0,20,98,107,
53
- 112,116,0,0,1,136,0,0,0,20,114,88,89,90,0,0,1,156,0,0,0,20,103,88,89,90,0,0,1,
54
- 176,0,0,0,20,98,88,89,90,0,0,1,196,0,0,0,20,114,84,82,67,0,0,1,216,0,0,0,64,98,
55
- 84,82,67,0,0,1,216,0,0,0,64,103,84,82,67,0,0,1,216,0,0,0,64,100,101,115,99,0,0,
56
- 0,0,0,0,0,13,115,82,71,66,32,77,111,122,74,80,69,71,0,0,0,0,0,0,0,0,1,0,0,0,0,
57
- 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
58
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,116,101,120,
59
- 116,0,0,0,0,80,68,0,0,88,89,90,32,0,0,0,0,0,0,246,214,0,1,0,0,0,0,211,45,88,89,
60
- 90,32,0,0,0,0,0,0,3,22,0,0,3,51,0,0,2,164,88,89,90,32,0,0,0,0,0,0,111,162,0,0,
61
- 56,245,0,0,3,144,88,89,90,32,0,0,0,0,0,0,98,153,0,0,183,133,0,0,24,218,88,89,
62
- 90,32,0,0,0,0,0,0,36,160,0,0,15,132,0,0,182,207,99,117,114,118,0,0,0,0,0,0,0,
63
- 26,0,0,0,203,1,201,3,99,5,146,8,107,11,246,16,63,21,81,27,52,33,241,41,144,50,
64
- 24,59,146,70,5,81,119,93,237,107,112,122,5,137,177,154,124,172,105,191,125,211,
65
- 195,233,48,255,255,};
66
-
67
- METHODDEF(void)
68
- start_input_png (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
69
- {
70
- png_source_struct *source = (png_source_struct *)sinfo;
71
- png_uint_32 width, height;
72
- int bit_depth, color_type;
73
- int has_srgb_chunk;
74
- double gamma;
75
- png_bytep profile;
76
- png_charp unused1;
77
- int unused2;
78
- png_uint_32 proflen;
79
- int has_profile;
80
- size_t datalen;
81
- JOCTET *dataptr;
82
- struct jpeg_marker_struct *marker;
83
- png_size_t rowbytes;
84
-
85
- source->png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, cinfo, error_input_png, NULL);
86
- source->info_ptr = png_create_info_struct(source->png_ptr);
87
-
88
- if (!source->png_ptr || !source->info_ptr) {
89
- ERREXITS(cinfo, JERR_PNG_ERROR, "Can't create read/info_struct");
90
- return;
91
- }
92
-
93
- png_set_palette_to_rgb(source->png_ptr);
94
- png_set_expand_gray_1_2_4_to_8(source->png_ptr);
95
- png_set_strip_alpha(source->png_ptr);
96
- png_set_interlace_handling(source->png_ptr);
97
-
98
- png_init_io(source->png_ptr, source->pub.input_file);
99
- png_read_info(source->png_ptr, source->info_ptr);
100
-
101
- png_get_IHDR(source->png_ptr, source->info_ptr, &width, &height,
102
- &bit_depth, &color_type, NULL, NULL, NULL);
103
-
104
- if (width > 65535 || height > 65535) {
105
- ERREXITS(cinfo, JERR_PNG_ERROR, "Image too large");
106
- return;
107
- }
108
-
109
- if (color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_GRAY_ALPHA) {
110
- cinfo->in_color_space = JCS_GRAYSCALE;
111
- cinfo->input_components = 1;
112
- } else {
113
- cinfo->in_color_space = JCS_RGB;
114
- cinfo->input_components = 3;
115
- }
116
-
117
- if (bit_depth == 16) {
118
- png_set_strip_16(source->png_ptr);
119
- }
120
-
121
- cinfo->data_precision = 8;
122
- cinfo->image_width = width;
123
- cinfo->image_height = height;
124
-
125
- has_srgb_chunk = png_get_valid(source->png_ptr, source->info_ptr, PNG_INFO_sRGB);
126
-
127
- gamma = 0.45455;
128
- if (!has_srgb_chunk) {
129
- png_get_gAMA(source->png_ptr, source->info_ptr, &gamma);
130
- }
131
- cinfo->input_gamma = gamma;
132
- sinfo->get_pixel_rows = get_pixel_rows_png;
133
-
134
- source->pub.marker_list = NULL;
135
- profile = NULL;
136
- unused1 = NULL;
137
- unused2 = 0;
138
- proflen = 0;
139
- has_profile = 0;
140
-
141
- if (has_srgb_chunk) {
142
- /* PNG can declare use of an sRGB profile without embedding an ICC file, but JPEG doesn't have such feature */
143
- has_profile = 1;
144
- profile = tiny_srgb;
145
- proflen = sizeof(tiny_srgb);
146
- } else {
147
- has_profile = png_get_iCCP(source->png_ptr, source->info_ptr, &unused1, &unused2, &profile, &proflen); /* your libpng is out of date if you get a warning here */
148
- }
149
-
150
- if (has_profile && profile && proflen) {
151
- if (proflen < 65535-14) {
152
- datalen = proflen + 14;
153
- dataptr = (*cinfo->mem->alloc_small)((j_common_ptr)cinfo, JPOOL_IMAGE, datalen);
154
- memcpy(dataptr, "ICC_PROFILE\0\x01\x01", 14);
155
- memcpy(dataptr + 14, profile, proflen);
156
- marker = (*cinfo->mem->alloc_small)((j_common_ptr)cinfo, JPOOL_IMAGE, sizeof(struct jpeg_marker_struct));
157
- marker->next = NULL;
158
- marker->marker = JPEG_APP0+2;
159
- marker->original_length = 0;
160
- marker->data_length = datalen;
161
- marker->data = dataptr;
162
- source->pub.marker_list = marker;
163
- } else {
164
- WARNMS(cinfo, JERR_PNG_PROFILETOOLARGE);
165
- }
166
- }
167
-
168
- png_read_update_info(source->png_ptr, source->info_ptr);
169
-
170
- rowbytes = png_get_rowbytes(source->png_ptr, source->info_ptr);
171
-
172
- source->pub.buffer = (*cinfo->mem->alloc_sarray)((j_common_ptr)cinfo, JPOOL_IMAGE, (JDIMENSION)rowbytes, 1);
173
- source->pub.buffer_height = 1;
174
- }
175
-
176
- METHODDEF(JDIMENSION)
177
- get_pixel_rows_png (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
178
- {
179
- png_source_struct *source = (png_source_struct *)sinfo;
180
-
181
- png_read_row(source->png_ptr, source->pub.buffer[0], NULL);
182
- return 1;
183
- }
184
-
185
- METHODDEF(void)
186
- finish_input_png (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
187
- {
188
- png_source_struct *source = (png_source_struct *)sinfo;
189
-
190
- png_read_end(source->png_ptr, source->info_ptr);
191
- png_destroy_read_struct(&source->png_ptr, &source->info_ptr, NULL);
192
- }
193
-
194
- #endif