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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1 -0
- data/README.md +23 -4
- data/ext/image_pack/extconf.rb +35 -124
- data/ext/image_pack/image_pack.c +638 -595
- data/ext/image_pack/mozjpeg_sources.rb +178 -0
- data/ext/image_pack/vendor/mozjpeg/BUILDING.md +744 -0
- data/ext/image_pack/vendor/mozjpeg/CODE_OF_CONDUCT.md +15 -0
- data/ext/image_pack/vendor/mozjpeg/ChangeLog.md +1996 -0
- data/lib/image_pack/configuration.rb +54 -8
- data/lib/image_pack/version.rb +1 -1
- data/lib/image_pack.rb +65 -18
- metadata +13 -78
- data/ext/image_pack/vendor/mozjpeg/README.ijg +0 -258
- data/ext/image_pack/vendor/mozjpeg/cdjpeg.c +0 -156
- data/ext/image_pack/vendor/mozjpeg/cjpeg.c +0 -961
- data/ext/image_pack/vendor/mozjpeg/djpeg.c +0 -855
- data/ext/image_pack/vendor/mozjpeg/jaricom.c +0 -157
- data/ext/image_pack/vendor/mozjpeg/jcarith.c +0 -972
- data/ext/image_pack/vendor/mozjpeg/jcstest.c +0 -126
- data/ext/image_pack/vendor/mozjpeg/jdarith.c +0 -782
- data/ext/image_pack/vendor/mozjpeg/jdatadst-tj.c +0 -198
- data/ext/image_pack/vendor/mozjpeg/jdatasrc-tj.c +0 -194
- data/ext/image_pack/vendor/mozjpeg/jpegtran.c +0 -827
- data/ext/image_pack/vendor/mozjpeg/jpegyuv.c +0 -172
- data/ext/image_pack/vendor/mozjpeg/rdbmp.c +0 -690
- data/ext/image_pack/vendor/mozjpeg/rdcolmap.c +0 -253
- data/ext/image_pack/vendor/mozjpeg/rdgif.c +0 -720
- data/ext/image_pack/vendor/mozjpeg/rdjpeg.c +0 -160
- data/ext/image_pack/vendor/mozjpeg/rdjpgcom.c +0 -494
- data/ext/image_pack/vendor/mozjpeg/rdpng.c +0 -194
- data/ext/image_pack/vendor/mozjpeg/rdppm.c +0 -781
- data/ext/image_pack/vendor/mozjpeg/rdswitch.c +0 -642
- data/ext/image_pack/vendor/mozjpeg/rdtarga.c +0 -508
- data/ext/image_pack/vendor/mozjpeg/simd/arm/aarch32/jccolext-neon.c +0 -148
- data/ext/image_pack/vendor/mozjpeg/simd/arm/aarch32/jchuff-neon.c +0 -334
- data/ext/image_pack/vendor/mozjpeg/simd/arm/aarch32/jsimd.c +0 -976
- data/ext/image_pack/vendor/mozjpeg/simd/i386/jsimd.c +0 -1312
- data/ext/image_pack/vendor/mozjpeg/simd/mips/jsimd.c +0 -1143
- data/ext/image_pack/vendor/mozjpeg/simd/mips64/jccolext-mmi.c +0 -455
- data/ext/image_pack/vendor/mozjpeg/simd/mips64/jccolor-mmi.c +0 -148
- data/ext/image_pack/vendor/mozjpeg/simd/mips64/jcgray-mmi.c +0 -132
- data/ext/image_pack/vendor/mozjpeg/simd/mips64/jcgryext-mmi.c +0 -374
- data/ext/image_pack/vendor/mozjpeg/simd/mips64/jcsample-mmi.c +0 -98
- data/ext/image_pack/vendor/mozjpeg/simd/mips64/jdcolext-mmi.c +0 -415
- data/ext/image_pack/vendor/mozjpeg/simd/mips64/jdcolor-mmi.c +0 -139
- data/ext/image_pack/vendor/mozjpeg/simd/mips64/jdmerge-mmi.c +0 -149
- data/ext/image_pack/vendor/mozjpeg/simd/mips64/jdmrgext-mmi.c +0 -615
- data/ext/image_pack/vendor/mozjpeg/simd/mips64/jdsample-mmi.c +0 -304
- data/ext/image_pack/vendor/mozjpeg/simd/mips64/jfdctfst-mmi.c +0 -255
- data/ext/image_pack/vendor/mozjpeg/simd/mips64/jfdctint-mmi.c +0 -398
- data/ext/image_pack/vendor/mozjpeg/simd/mips64/jidctfst-mmi.c +0 -395
- data/ext/image_pack/vendor/mozjpeg/simd/mips64/jidctint-mmi.c +0 -571
- data/ext/image_pack/vendor/mozjpeg/simd/mips64/jquanti-mmi.c +0 -124
- data/ext/image_pack/vendor/mozjpeg/simd/mips64/jsimd.c +0 -866
- data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jccolext-altivec.c +0 -269
- data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jccolor-altivec.c +0 -116
- data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jcgray-altivec.c +0 -111
- data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jcgryext-altivec.c +0 -228
- data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jcsample-altivec.c +0 -159
- data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jdcolext-altivec.c +0 -276
- data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jdcolor-altivec.c +0 -106
- data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jdmerge-altivec.c +0 -130
- data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jdmrgext-altivec.c +0 -329
- data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jdsample-altivec.c +0 -400
- data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jfdctfst-altivec.c +0 -154
- data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jfdctint-altivec.c +0 -258
- data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jidctfst-altivec.c +0 -255
- data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jidctint-altivec.c +0 -357
- data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jquanti-altivec.c +0 -250
- data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jsimd.c +0 -884
- data/ext/image_pack/vendor/mozjpeg/strtest.c +0 -170
- data/ext/image_pack/vendor/mozjpeg/tjbench.c +0 -1044
- data/ext/image_pack/vendor/mozjpeg/tjexample.c +0 -406
- data/ext/image_pack/vendor/mozjpeg/tjunittest.c +0 -961
- data/ext/image_pack/vendor/mozjpeg/tjutil.c +0 -70
- data/ext/image_pack/vendor/mozjpeg/transupp.c +0 -2373
- data/ext/image_pack/vendor/mozjpeg/turbojpeg-jni.c +0 -1259
- data/ext/image_pack/vendor/mozjpeg/turbojpeg.c +0 -2320
- data/ext/image_pack/vendor/mozjpeg/wrbmp.c +0 -552
- data/ext/image_pack/vendor/mozjpeg/wrgif.c +0 -580
- data/ext/image_pack/vendor/mozjpeg/wrjpgcom.c +0 -577
- data/ext/image_pack/vendor/mozjpeg/wrppm.c +0 -366
- data/ext/image_pack/vendor/mozjpeg/wrtarga.c +0 -258
- data/ext/image_pack/vendor/mozjpeg/yuvjpeg.c +0 -268
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Written by Josh Aas and Tim Terriberry
|
|
3
|
-
* Copyright (c) 2013, Mozilla Corporation
|
|
4
|
-
* All rights reserved.
|
|
5
|
-
*
|
|
6
|
-
* Redistribution and use in source and binary forms, with or without
|
|
7
|
-
* modification, are permitted provided that the following conditions are met:
|
|
8
|
-
*
|
|
9
|
-
* 1. Redistributions of source code must retain the above copyright notice,
|
|
10
|
-
* this list of conditions and the following disclaimer.
|
|
11
|
-
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
-
* this list of conditions and the following disclaimer in the documentation
|
|
13
|
-
* and/or other materials provided with the distribution.
|
|
14
|
-
* 3. Neither the name of the Mozilla Corporation nor the names of its
|
|
15
|
-
* contributors may be used to endorse or promote products derived from this
|
|
16
|
-
* software without specific prior written permission.
|
|
17
|
-
*
|
|
18
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
19
|
-
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
20
|
-
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
21
|
-
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
22
|
-
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
23
|
-
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
24
|
-
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
25
|
-
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
26
|
-
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
27
|
-
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
28
|
-
* POSSIBILITY OF SUCH DAMAGE.
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
/* Input: JPEG YUV 4:2:0 */
|
|
32
|
-
/* Output: YUV 4:2:0 */
|
|
33
|
-
|
|
34
|
-
/* gcc -std=c99 jpegyuv.c -I/opt/local/include/ -L/opt/local/lib/ -ljpeg -o jpegyuv */
|
|
35
|
-
|
|
36
|
-
#include <stdio.h>
|
|
37
|
-
#include <stdlib.h>
|
|
38
|
-
|
|
39
|
-
#include "jpeglib.h"
|
|
40
|
-
|
|
41
|
-
int main(int argc, char *argv[]) {
|
|
42
|
-
const char *jpg_path;
|
|
43
|
-
const char *yuv_path;
|
|
44
|
-
struct jpeg_decompress_struct cinfo;
|
|
45
|
-
struct jpeg_error_mgr jerr;
|
|
46
|
-
FILE *jpg_fd;
|
|
47
|
-
int luma_width;
|
|
48
|
-
int luma_height;
|
|
49
|
-
int chroma_width;
|
|
50
|
-
int chroma_height;
|
|
51
|
-
int frame_width;
|
|
52
|
-
int yuv_size;
|
|
53
|
-
JSAMPLE *jpg_buffer;
|
|
54
|
-
JSAMPROW yrow_pointer[16];
|
|
55
|
-
JSAMPROW cbrow_pointer[8];
|
|
56
|
-
JSAMPROW crrow_pointer[8];
|
|
57
|
-
JSAMPROW *plane_pointer[3];
|
|
58
|
-
unsigned char *yuv_buffer;
|
|
59
|
-
int x;
|
|
60
|
-
int y;
|
|
61
|
-
FILE *yuv_fd;
|
|
62
|
-
|
|
63
|
-
if (argc != 3) {
|
|
64
|
-
fprintf(stderr, "Required arguments:\n");
|
|
65
|
-
fprintf(stderr, "1. Path to JPG input file\n");
|
|
66
|
-
fprintf(stderr, "2. Path to YUV output file\n");
|
|
67
|
-
return 1;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/* Will check these for validity when opening via 'fopen'. */
|
|
71
|
-
jpg_path = argv[1];
|
|
72
|
-
yuv_path = argv[2];
|
|
73
|
-
|
|
74
|
-
cinfo.err = jpeg_std_error(&jerr);
|
|
75
|
-
jpeg_create_decompress(&cinfo);
|
|
76
|
-
|
|
77
|
-
jpg_fd = fopen(jpg_path, "rb");
|
|
78
|
-
if (!jpg_fd) {
|
|
79
|
-
fprintf(stderr, "Invalid path to JPEG file!\n");
|
|
80
|
-
return 1;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
jpeg_stdio_src(&cinfo, jpg_fd);
|
|
84
|
-
|
|
85
|
-
jpeg_read_header(&cinfo, TRUE);
|
|
86
|
-
|
|
87
|
-
cinfo.raw_data_out = TRUE;
|
|
88
|
-
cinfo.do_fancy_upsampling = FALSE;
|
|
89
|
-
|
|
90
|
-
jpeg_start_decompress(&cinfo);
|
|
91
|
-
|
|
92
|
-
luma_width = cinfo.output_width;
|
|
93
|
-
luma_height = cinfo.output_height;
|
|
94
|
-
|
|
95
|
-
chroma_width = (luma_width + 1) >> 1;
|
|
96
|
-
chroma_height = (luma_height + 1) >> 1;
|
|
97
|
-
|
|
98
|
-
yuv_size = luma_width*luma_height + 2*chroma_width*chroma_height;
|
|
99
|
-
yuv_buffer = malloc(yuv_size);
|
|
100
|
-
if (!yuv_buffer) {
|
|
101
|
-
fclose(jpg_fd);
|
|
102
|
-
fprintf(stderr, "Memory allocation failure!\n");
|
|
103
|
-
return 1;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
frame_width = (cinfo.output_width + (16 - 1)) & ~(16 - 1);
|
|
107
|
-
|
|
108
|
-
jpg_buffer = malloc(frame_width*16 + 2*(frame_width/2)*8);
|
|
109
|
-
if (!jpg_buffer) {
|
|
110
|
-
fclose(jpg_fd);
|
|
111
|
-
free(yuv_buffer);
|
|
112
|
-
fprintf(stderr, "Memory allocation failure!\n");
|
|
113
|
-
return 1;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
plane_pointer[0] = yrow_pointer;
|
|
117
|
-
plane_pointer[1] = cbrow_pointer;
|
|
118
|
-
plane_pointer[2] = crrow_pointer;
|
|
119
|
-
|
|
120
|
-
for (y = 0; y < 16; y++) {
|
|
121
|
-
yrow_pointer[y] = &jpg_buffer[frame_width*y];
|
|
122
|
-
}
|
|
123
|
-
for (y = 0; y < 8; y++) {
|
|
124
|
-
cbrow_pointer[y] = &jpg_buffer[frame_width*16 + (frame_width/2)*y];
|
|
125
|
-
crrow_pointer[y] = &jpg_buffer[frame_width*16 + (frame_width/2)*(8 + y)];
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
while (cinfo.output_scanline < cinfo.output_height) {
|
|
129
|
-
int luma_scanline;
|
|
130
|
-
int chroma_scanline;
|
|
131
|
-
|
|
132
|
-
luma_scanline = cinfo.output_scanline;
|
|
133
|
-
chroma_scanline = (luma_scanline + 1) >> 1;
|
|
134
|
-
|
|
135
|
-
jpeg_read_raw_data(&cinfo, plane_pointer, 16);
|
|
136
|
-
|
|
137
|
-
for (y = 0; y < 16 && luma_scanline + y < luma_height; y++) {
|
|
138
|
-
for (x = 0; x < luma_width; x++) {
|
|
139
|
-
yuv_buffer[luma_width*(luma_scanline + y) + x] = yrow_pointer[y][x];
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
for (y = 0; y < 8 && chroma_scanline + y < chroma_height; y++) {
|
|
143
|
-
for (x = 0; x < chroma_width; x++) {
|
|
144
|
-
yuv_buffer[luma_width*luma_height +
|
|
145
|
-
chroma_width*(chroma_scanline + y) + x] = cbrow_pointer[y][x];
|
|
146
|
-
yuv_buffer[luma_width*luma_height + chroma_width*chroma_height +
|
|
147
|
-
chroma_width*(chroma_scanline + y) + x] = crrow_pointer[y][x];
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
jpeg_finish_decompress(&cinfo);
|
|
153
|
-
jpeg_destroy_decompress(&cinfo);
|
|
154
|
-
|
|
155
|
-
fclose(jpg_fd);
|
|
156
|
-
free(jpg_buffer);
|
|
157
|
-
|
|
158
|
-
yuv_fd = fopen(yuv_path, "wb");
|
|
159
|
-
if (!yuv_fd) {
|
|
160
|
-
fprintf(stderr, "Invalid path to YUV file!");
|
|
161
|
-
free(yuv_buffer);
|
|
162
|
-
return 1;
|
|
163
|
-
}
|
|
164
|
-
if (fwrite(yuv_buffer, yuv_size, 1, yuv_fd) != 1) {
|
|
165
|
-
fprintf(stderr, "Error writing yuv file\n");
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
fclose(yuv_fd);
|
|
169
|
-
free(yuv_buffer);
|
|
170
|
-
|
|
171
|
-
return 0;
|
|
172
|
-
}
|