image_intensities 1.0.3 → 1.0.4

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 (93) hide show
  1. checksums.yaml +4 -4
  2. data/ext/image_intensities/Makefile +73 -4
  3. data/ext/image_intensities/turbojpeg/cderror.h +137 -0
  4. data/ext/image_intensities/turbojpeg/cdjpeg.h +157 -0
  5. data/ext/image_intensities/turbojpeg/cmyk.h +61 -0
  6. data/ext/image_intensities/turbojpeg/jaricom.c +157 -0
  7. data/ext/image_intensities/turbojpeg/jcapimin.c +295 -0
  8. data/ext/image_intensities/turbojpeg/jcapistd.c +162 -0
  9. data/ext/image_intensities/turbojpeg/jcarith.c +932 -0
  10. data/ext/image_intensities/turbojpeg/jccoefct.c +449 -0
  11. data/ext/image_intensities/turbojpeg/jccolext.c +144 -0
  12. data/ext/image_intensities/turbojpeg/jccolor.c +710 -0
  13. data/ext/image_intensities/turbojpeg/jcdctmgr.c +721 -0
  14. data/ext/image_intensities/turbojpeg/jchuff.c +1096 -0
  15. data/ext/image_intensities/turbojpeg/jchuff.h +42 -0
  16. data/ext/image_intensities/turbojpeg/jcicc.c +105 -0
  17. data/ext/image_intensities/turbojpeg/jcinit.c +77 -0
  18. data/ext/image_intensities/turbojpeg/jcmainct.c +162 -0
  19. data/ext/image_intensities/turbojpeg/jcmarker.c +664 -0
  20. data/ext/image_intensities/turbojpeg/jcmaster.c +640 -0
  21. data/ext/image_intensities/turbojpeg/jcomapi.c +109 -0
  22. data/ext/image_intensities/turbojpeg/jconfig.h +73 -0
  23. data/ext/image_intensities/turbojpeg/jconfigint.h +31 -0
  24. data/ext/image_intensities/turbojpeg/jcparam.c +541 -0
  25. data/ext/image_intensities/turbojpeg/jcphuff.c +1105 -0
  26. data/ext/image_intensities/turbojpeg/jcprepct.c +351 -0
  27. data/ext/image_intensities/turbojpeg/jcsample.c +539 -0
  28. data/ext/image_intensities/turbojpeg/jctrans.c +400 -0
  29. data/ext/image_intensities/turbojpeg/jdapimin.c +407 -0
  30. data/ext/image_intensities/turbojpeg/jdapistd.c +639 -0
  31. data/ext/image_intensities/turbojpeg/jdarith.c +773 -0
  32. data/ext/image_intensities/turbojpeg/jdatadst-tj.c +203 -0
  33. data/ext/image_intensities/turbojpeg/jdatadst.c +293 -0
  34. data/ext/image_intensities/turbojpeg/jdatasrc-tj.c +194 -0
  35. data/ext/image_intensities/turbojpeg/jdatasrc.c +295 -0
  36. data/ext/image_intensities/turbojpeg/jdcoefct.c +692 -0
  37. data/ext/image_intensities/turbojpeg/jdcoefct.h +82 -0
  38. data/ext/image_intensities/turbojpeg/jdcol565.c +384 -0
  39. data/ext/image_intensities/turbojpeg/jdcolext.c +143 -0
  40. data/ext/image_intensities/turbojpeg/jdcolor.c +883 -0
  41. data/ext/image_intensities/turbojpeg/jdct.h +208 -0
  42. data/ext/image_intensities/turbojpeg/jddctmgr.c +352 -0
  43. data/ext/image_intensities/turbojpeg/jdhuff.c +831 -0
  44. data/ext/image_intensities/turbojpeg/jdhuff.h +238 -0
  45. data/ext/image_intensities/turbojpeg/jdicc.c +171 -0
  46. data/ext/image_intensities/turbojpeg/jdinput.c +408 -0
  47. data/ext/image_intensities/turbojpeg/jdmainct.c +460 -0
  48. data/ext/image_intensities/turbojpeg/jdmainct.h +71 -0
  49. data/ext/image_intensities/turbojpeg/jdmarker.c +1377 -0
  50. data/ext/image_intensities/turbojpeg/jdmaster.c +737 -0
  51. data/ext/image_intensities/turbojpeg/jdmaster.h +28 -0
  52. data/ext/image_intensities/turbojpeg/jdmerge.c +617 -0
  53. data/ext/image_intensities/turbojpeg/jdmrg565.c +354 -0
  54. data/ext/image_intensities/turbojpeg/jdmrgext.c +184 -0
  55. data/ext/image_intensities/turbojpeg/jdphuff.c +687 -0
  56. data/ext/image_intensities/turbojpeg/jdpostct.c +294 -0
  57. data/ext/image_intensities/turbojpeg/jdsample.c +518 -0
  58. data/ext/image_intensities/turbojpeg/jdsample.h +50 -0
  59. data/ext/image_intensities/turbojpeg/jdtrans.c +155 -0
  60. data/ext/image_intensities/turbojpeg/jerror.c +251 -0
  61. data/ext/image_intensities/turbojpeg/jfdctflt.c +169 -0
  62. data/ext/image_intensities/turbojpeg/jfdctfst.c +227 -0
  63. data/ext/image_intensities/turbojpeg/jfdctint.c +288 -0
  64. data/ext/image_intensities/turbojpeg/jidctflt.c +240 -0
  65. data/ext/image_intensities/turbojpeg/jidctfst.c +371 -0
  66. data/ext/image_intensities/turbojpeg/jidctint.c +2627 -0
  67. data/ext/image_intensities/turbojpeg/jidctred.c +409 -0
  68. data/ext/image_intensities/turbojpeg/jinclude.h +88 -0
  69. data/ext/image_intensities/turbojpeg/jmemmgr.c +1179 -0
  70. data/ext/image_intensities/turbojpeg/jmemnobs.c +115 -0
  71. data/ext/image_intensities/turbojpeg/jmemsys.h +178 -0
  72. data/ext/image_intensities/turbojpeg/jpeg_nbits_table.h +4098 -0
  73. data/ext/image_intensities/turbojpeg/jpegcomp.h +31 -0
  74. data/ext/image_intensities/turbojpeg/jquant1.c +859 -0
  75. data/ext/image_intensities/turbojpeg/jquant2.c +1285 -0
  76. data/ext/image_intensities/turbojpeg/jsimd.h +117 -0
  77. data/ext/image_intensities/turbojpeg/jsimd_none.c +418 -0
  78. data/ext/image_intensities/turbojpeg/jsimddct.h +70 -0
  79. data/ext/image_intensities/turbojpeg/jstdhuff.c +143 -0
  80. data/ext/image_intensities/turbojpeg/jutils.c +133 -0
  81. data/ext/image_intensities/turbojpeg/jversion.h +52 -0
  82. data/ext/image_intensities/turbojpeg/libturbojpeg.a +0 -0
  83. data/ext/image_intensities/turbojpeg/rdbmp.c +689 -0
  84. data/ext/image_intensities/turbojpeg/rdppm.c +766 -0
  85. data/ext/image_intensities/turbojpeg/tjutil.h +47 -0
  86. data/ext/image_intensities/turbojpeg/transupp.c +1628 -0
  87. data/ext/image_intensities/turbojpeg/transupp.h +210 -0
  88. data/ext/image_intensities/turbojpeg/turbojpeg.c +2150 -0
  89. data/ext/image_intensities/turbojpeg/wrbmp.c +558 -0
  90. data/ext/image_intensities/turbojpeg/wrppm.c +365 -0
  91. data/image_intensities.gemspec +1 -1
  92. data/lib/image_intensities/version.rb +1 -1
  93. metadata +91 -3
@@ -0,0 +1,354 @@
1
+ /*
2
+ * jdmrg565.c
3
+ *
4
+ * This file was part of the Independent JPEG Group's software:
5
+ * Copyright (C) 1994-1996, Thomas G. Lane.
6
+ * libjpeg-turbo Modifications:
7
+ * Copyright (C) 2013, Linaro Limited.
8
+ * Copyright (C) 2014-2015, 2018, D. R. Commander.
9
+ * For conditions of distribution and use, see the accompanying README.ijg
10
+ * file.
11
+ *
12
+ * This file contains code for merged upsampling/color conversion.
13
+ */
14
+
15
+
16
+ INLINE
17
+ LOCAL(void)
18
+ h2v1_merged_upsample_565_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
19
+ JDIMENSION in_row_group_ctr,
20
+ JSAMPARRAY output_buf)
21
+ {
22
+ my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
23
+ register int y, cred, cgreen, cblue;
24
+ int cb, cr;
25
+ register JSAMPROW outptr;
26
+ JSAMPROW inptr0, inptr1, inptr2;
27
+ JDIMENSION col;
28
+ /* copy these pointers into registers if possible */
29
+ register JSAMPLE *range_limit = cinfo->sample_range_limit;
30
+ int *Crrtab = upsample->Cr_r_tab;
31
+ int *Cbbtab = upsample->Cb_b_tab;
32
+ JLONG *Crgtab = upsample->Cr_g_tab;
33
+ JLONG *Cbgtab = upsample->Cb_g_tab;
34
+ unsigned int r, g, b;
35
+ JLONG rgb;
36
+ SHIFT_TEMPS
37
+
38
+ inptr0 = input_buf[0][in_row_group_ctr];
39
+ inptr1 = input_buf[1][in_row_group_ctr];
40
+ inptr2 = input_buf[2][in_row_group_ctr];
41
+ outptr = output_buf[0];
42
+
43
+ /* Loop for each pair of output pixels */
44
+ for (col = cinfo->output_width >> 1; col > 0; col--) {
45
+ /* Do the chroma part of the calculation */
46
+ cb = GETJSAMPLE(*inptr1++);
47
+ cr = GETJSAMPLE(*inptr2++);
48
+ cred = Crrtab[cr];
49
+ cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
50
+ cblue = Cbbtab[cb];
51
+
52
+ /* Fetch 2 Y values and emit 2 pixels */
53
+ y = GETJSAMPLE(*inptr0++);
54
+ r = range_limit[y + cred];
55
+ g = range_limit[y + cgreen];
56
+ b = range_limit[y + cblue];
57
+ rgb = PACK_SHORT_565(r, g, b);
58
+
59
+ y = GETJSAMPLE(*inptr0++);
60
+ r = range_limit[y + cred];
61
+ g = range_limit[y + cgreen];
62
+ b = range_limit[y + cblue];
63
+ rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(r, g, b));
64
+
65
+ WRITE_TWO_PIXELS(outptr, rgb);
66
+ outptr += 4;
67
+ }
68
+
69
+ /* If image width is odd, do the last output column separately */
70
+ if (cinfo->output_width & 1) {
71
+ cb = GETJSAMPLE(*inptr1);
72
+ cr = GETJSAMPLE(*inptr2);
73
+ cred = Crrtab[cr];
74
+ cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
75
+ cblue = Cbbtab[cb];
76
+ y = GETJSAMPLE(*inptr0);
77
+ r = range_limit[y + cred];
78
+ g = range_limit[y + cgreen];
79
+ b = range_limit[y + cblue];
80
+ rgb = PACK_SHORT_565(r, g, b);
81
+ *(INT16 *)outptr = (INT16)rgb;
82
+ }
83
+ }
84
+
85
+
86
+ INLINE
87
+ LOCAL(void)
88
+ h2v1_merged_upsample_565D_internal(j_decompress_ptr cinfo,
89
+ JSAMPIMAGE input_buf,
90
+ JDIMENSION in_row_group_ctr,
91
+ JSAMPARRAY output_buf)
92
+ {
93
+ my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
94
+ register int y, cred, cgreen, cblue;
95
+ int cb, cr;
96
+ register JSAMPROW outptr;
97
+ JSAMPROW inptr0, inptr1, inptr2;
98
+ JDIMENSION col;
99
+ /* copy these pointers into registers if possible */
100
+ register JSAMPLE *range_limit = cinfo->sample_range_limit;
101
+ int *Crrtab = upsample->Cr_r_tab;
102
+ int *Cbbtab = upsample->Cb_b_tab;
103
+ JLONG *Crgtab = upsample->Cr_g_tab;
104
+ JLONG *Cbgtab = upsample->Cb_g_tab;
105
+ JLONG d0 = dither_matrix[cinfo->output_scanline & DITHER_MASK];
106
+ unsigned int r, g, b;
107
+ JLONG rgb;
108
+ SHIFT_TEMPS
109
+
110
+ inptr0 = input_buf[0][in_row_group_ctr];
111
+ inptr1 = input_buf[1][in_row_group_ctr];
112
+ inptr2 = input_buf[2][in_row_group_ctr];
113
+ outptr = output_buf[0];
114
+
115
+ /* Loop for each pair of output pixels */
116
+ for (col = cinfo->output_width >> 1; col > 0; col--) {
117
+ /* Do the chroma part of the calculation */
118
+ cb = GETJSAMPLE(*inptr1++);
119
+ cr = GETJSAMPLE(*inptr2++);
120
+ cred = Crrtab[cr];
121
+ cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
122
+ cblue = Cbbtab[cb];
123
+
124
+ /* Fetch 2 Y values and emit 2 pixels */
125
+ y = GETJSAMPLE(*inptr0++);
126
+ r = range_limit[DITHER_565_R(y + cred, d0)];
127
+ g = range_limit[DITHER_565_G(y + cgreen, d0)];
128
+ b = range_limit[DITHER_565_B(y + cblue, d0)];
129
+ d0 = DITHER_ROTATE(d0);
130
+ rgb = PACK_SHORT_565(r, g, b);
131
+
132
+ y = GETJSAMPLE(*inptr0++);
133
+ r = range_limit[DITHER_565_R(y + cred, d0)];
134
+ g = range_limit[DITHER_565_G(y + cgreen, d0)];
135
+ b = range_limit[DITHER_565_B(y + cblue, d0)];
136
+ d0 = DITHER_ROTATE(d0);
137
+ rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(r, g, b));
138
+
139
+ WRITE_TWO_PIXELS(outptr, rgb);
140
+ outptr += 4;
141
+ }
142
+
143
+ /* If image width is odd, do the last output column separately */
144
+ if (cinfo->output_width & 1) {
145
+ cb = GETJSAMPLE(*inptr1);
146
+ cr = GETJSAMPLE(*inptr2);
147
+ cred = Crrtab[cr];
148
+ cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
149
+ cblue = Cbbtab[cb];
150
+ y = GETJSAMPLE(*inptr0);
151
+ r = range_limit[DITHER_565_R(y + cred, d0)];
152
+ g = range_limit[DITHER_565_G(y + cgreen, d0)];
153
+ b = range_limit[DITHER_565_B(y + cblue, d0)];
154
+ rgb = PACK_SHORT_565(r, g, b);
155
+ *(INT16 *)outptr = (INT16)rgb;
156
+ }
157
+ }
158
+
159
+
160
+ INLINE
161
+ LOCAL(void)
162
+ h2v2_merged_upsample_565_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
163
+ JDIMENSION in_row_group_ctr,
164
+ JSAMPARRAY output_buf)
165
+ {
166
+ my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
167
+ register int y, cred, cgreen, cblue;
168
+ int cb, cr;
169
+ register JSAMPROW outptr0, outptr1;
170
+ JSAMPROW inptr00, inptr01, inptr1, inptr2;
171
+ JDIMENSION col;
172
+ /* copy these pointers into registers if possible */
173
+ register JSAMPLE *range_limit = cinfo->sample_range_limit;
174
+ int *Crrtab = upsample->Cr_r_tab;
175
+ int *Cbbtab = upsample->Cb_b_tab;
176
+ JLONG *Crgtab = upsample->Cr_g_tab;
177
+ JLONG *Cbgtab = upsample->Cb_g_tab;
178
+ unsigned int r, g, b;
179
+ JLONG rgb;
180
+ SHIFT_TEMPS
181
+
182
+ inptr00 = input_buf[0][in_row_group_ctr * 2];
183
+ inptr01 = input_buf[0][in_row_group_ctr * 2 + 1];
184
+ inptr1 = input_buf[1][in_row_group_ctr];
185
+ inptr2 = input_buf[2][in_row_group_ctr];
186
+ outptr0 = output_buf[0];
187
+ outptr1 = output_buf[1];
188
+
189
+ /* Loop for each group of output pixels */
190
+ for (col = cinfo->output_width >> 1; col > 0; col--) {
191
+ /* Do the chroma part of the calculation */
192
+ cb = GETJSAMPLE(*inptr1++);
193
+ cr = GETJSAMPLE(*inptr2++);
194
+ cred = Crrtab[cr];
195
+ cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
196
+ cblue = Cbbtab[cb];
197
+
198
+ /* Fetch 4 Y values and emit 4 pixels */
199
+ y = GETJSAMPLE(*inptr00++);
200
+ r = range_limit[y + cred];
201
+ g = range_limit[y + cgreen];
202
+ b = range_limit[y + cblue];
203
+ rgb = PACK_SHORT_565(r, g, b);
204
+
205
+ y = GETJSAMPLE(*inptr00++);
206
+ r = range_limit[y + cred];
207
+ g = range_limit[y + cgreen];
208
+ b = range_limit[y + cblue];
209
+ rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(r, g, b));
210
+
211
+ WRITE_TWO_PIXELS(outptr0, rgb);
212
+ outptr0 += 4;
213
+
214
+ y = GETJSAMPLE(*inptr01++);
215
+ r = range_limit[y + cred];
216
+ g = range_limit[y + cgreen];
217
+ b = range_limit[y + cblue];
218
+ rgb = PACK_SHORT_565(r, g, b);
219
+
220
+ y = GETJSAMPLE(*inptr01++);
221
+ r = range_limit[y + cred];
222
+ g = range_limit[y + cgreen];
223
+ b = range_limit[y + cblue];
224
+ rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(r, g, b));
225
+
226
+ WRITE_TWO_PIXELS(outptr1, rgb);
227
+ outptr1 += 4;
228
+ }
229
+
230
+ /* If image width is odd, do the last output column separately */
231
+ if (cinfo->output_width & 1) {
232
+ cb = GETJSAMPLE(*inptr1);
233
+ cr = GETJSAMPLE(*inptr2);
234
+ cred = Crrtab[cr];
235
+ cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
236
+ cblue = Cbbtab[cb];
237
+
238
+ y = GETJSAMPLE(*inptr00);
239
+ r = range_limit[y + cred];
240
+ g = range_limit[y + cgreen];
241
+ b = range_limit[y + cblue];
242
+ rgb = PACK_SHORT_565(r, g, b);
243
+ *(INT16 *)outptr0 = (INT16)rgb;
244
+
245
+ y = GETJSAMPLE(*inptr01);
246
+ r = range_limit[y + cred];
247
+ g = range_limit[y + cgreen];
248
+ b = range_limit[y + cblue];
249
+ rgb = PACK_SHORT_565(r, g, b);
250
+ *(INT16 *)outptr1 = (INT16)rgb;
251
+ }
252
+ }
253
+
254
+
255
+ INLINE
256
+ LOCAL(void)
257
+ h2v2_merged_upsample_565D_internal(j_decompress_ptr cinfo,
258
+ JSAMPIMAGE input_buf,
259
+ JDIMENSION in_row_group_ctr,
260
+ JSAMPARRAY output_buf)
261
+ {
262
+ my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
263
+ register int y, cred, cgreen, cblue;
264
+ int cb, cr;
265
+ register JSAMPROW outptr0, outptr1;
266
+ JSAMPROW inptr00, inptr01, inptr1, inptr2;
267
+ JDIMENSION col;
268
+ /* copy these pointers into registers if possible */
269
+ register JSAMPLE *range_limit = cinfo->sample_range_limit;
270
+ int *Crrtab = upsample->Cr_r_tab;
271
+ int *Cbbtab = upsample->Cb_b_tab;
272
+ JLONG *Crgtab = upsample->Cr_g_tab;
273
+ JLONG *Cbgtab = upsample->Cb_g_tab;
274
+ JLONG d0 = dither_matrix[cinfo->output_scanline & DITHER_MASK];
275
+ JLONG d1 = dither_matrix[(cinfo->output_scanline + 1) & DITHER_MASK];
276
+ unsigned int r, g, b;
277
+ JLONG rgb;
278
+ SHIFT_TEMPS
279
+
280
+ inptr00 = input_buf[0][in_row_group_ctr * 2];
281
+ inptr01 = input_buf[0][in_row_group_ctr * 2 + 1];
282
+ inptr1 = input_buf[1][in_row_group_ctr];
283
+ inptr2 = input_buf[2][in_row_group_ctr];
284
+ outptr0 = output_buf[0];
285
+ outptr1 = output_buf[1];
286
+
287
+ /* Loop for each group of output pixels */
288
+ for (col = cinfo->output_width >> 1; col > 0; col--) {
289
+ /* Do the chroma part of the calculation */
290
+ cb = GETJSAMPLE(*inptr1++);
291
+ cr = GETJSAMPLE(*inptr2++);
292
+ cred = Crrtab[cr];
293
+ cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
294
+ cblue = Cbbtab[cb];
295
+
296
+ /* Fetch 4 Y values and emit 4 pixels */
297
+ y = GETJSAMPLE(*inptr00++);
298
+ r = range_limit[DITHER_565_R(y + cred, d0)];
299
+ g = range_limit[DITHER_565_G(y + cgreen, d0)];
300
+ b = range_limit[DITHER_565_B(y + cblue, d0)];
301
+ d0 = DITHER_ROTATE(d0);
302
+ rgb = PACK_SHORT_565(r, g, b);
303
+
304
+ y = GETJSAMPLE(*inptr00++);
305
+ r = range_limit[DITHER_565_R(y + cred, d0)];
306
+ g = range_limit[DITHER_565_G(y + cgreen, d0)];
307
+ b = range_limit[DITHER_565_B(y + cblue, d0)];
308
+ d0 = DITHER_ROTATE(d0);
309
+ rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(r, g, b));
310
+
311
+ WRITE_TWO_PIXELS(outptr0, rgb);
312
+ outptr0 += 4;
313
+
314
+ y = GETJSAMPLE(*inptr01++);
315
+ r = range_limit[DITHER_565_R(y + cred, d1)];
316
+ g = range_limit[DITHER_565_G(y + cgreen, d1)];
317
+ b = range_limit[DITHER_565_B(y + cblue, d1)];
318
+ d1 = DITHER_ROTATE(d1);
319
+ rgb = PACK_SHORT_565(r, g, b);
320
+
321
+ y = GETJSAMPLE(*inptr01++);
322
+ r = range_limit[DITHER_565_R(y + cred, d1)];
323
+ g = range_limit[DITHER_565_G(y + cgreen, d1)];
324
+ b = range_limit[DITHER_565_B(y + cblue, d1)];
325
+ d1 = DITHER_ROTATE(d1);
326
+ rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(r, g, b));
327
+
328
+ WRITE_TWO_PIXELS(outptr1, rgb);
329
+ outptr1 += 4;
330
+ }
331
+
332
+ /* If image width is odd, do the last output column separately */
333
+ if (cinfo->output_width & 1) {
334
+ cb = GETJSAMPLE(*inptr1);
335
+ cr = GETJSAMPLE(*inptr2);
336
+ cred = Crrtab[cr];
337
+ cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
338
+ cblue = Cbbtab[cb];
339
+
340
+ y = GETJSAMPLE(*inptr00);
341
+ r = range_limit[DITHER_565_R(y + cred, d0)];
342
+ g = range_limit[DITHER_565_G(y + cgreen, d0)];
343
+ b = range_limit[DITHER_565_B(y + cblue, d0)];
344
+ rgb = PACK_SHORT_565(r, g, b);
345
+ *(INT16 *)outptr0 = (INT16)rgb;
346
+
347
+ y = GETJSAMPLE(*inptr01);
348
+ r = range_limit[DITHER_565_R(y + cred, d1)];
349
+ g = range_limit[DITHER_565_G(y + cgreen, d1)];
350
+ b = range_limit[DITHER_565_B(y + cblue, d1)];
351
+ rgb = PACK_SHORT_565(r, g, b);
352
+ *(INT16 *)outptr1 = (INT16)rgb;
353
+ }
354
+ }
@@ -0,0 +1,184 @@
1
+ /*
2
+ * jdmrgext.c
3
+ *
4
+ * This file was part of the Independent JPEG Group's software:
5
+ * Copyright (C) 1994-1996, Thomas G. Lane.
6
+ * libjpeg-turbo Modifications:
7
+ * Copyright (C) 2011, 2015, D. R. Commander.
8
+ * For conditions of distribution and use, see the accompanying README.ijg
9
+ * file.
10
+ *
11
+ * This file contains code for merged upsampling/color conversion.
12
+ */
13
+
14
+
15
+ /* This file is included by jdmerge.c */
16
+
17
+
18
+ /*
19
+ * Upsample and color convert for the case of 2:1 horizontal and 1:1 vertical.
20
+ */
21
+
22
+ INLINE
23
+ LOCAL(void)
24
+ h2v1_merged_upsample_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
25
+ JDIMENSION in_row_group_ctr,
26
+ JSAMPARRAY output_buf)
27
+ {
28
+ my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
29
+ register int y, cred, cgreen, cblue;
30
+ int cb, cr;
31
+ register JSAMPROW outptr;
32
+ JSAMPROW inptr0, inptr1, inptr2;
33
+ JDIMENSION col;
34
+ /* copy these pointers into registers if possible */
35
+ register JSAMPLE *range_limit = cinfo->sample_range_limit;
36
+ int *Crrtab = upsample->Cr_r_tab;
37
+ int *Cbbtab = upsample->Cb_b_tab;
38
+ JLONG *Crgtab = upsample->Cr_g_tab;
39
+ JLONG *Cbgtab = upsample->Cb_g_tab;
40
+ SHIFT_TEMPS
41
+
42
+ inptr0 = input_buf[0][in_row_group_ctr];
43
+ inptr1 = input_buf[1][in_row_group_ctr];
44
+ inptr2 = input_buf[2][in_row_group_ctr];
45
+ outptr = output_buf[0];
46
+ /* Loop for each pair of output pixels */
47
+ for (col = cinfo->output_width >> 1; col > 0; col--) {
48
+ /* Do the chroma part of the calculation */
49
+ cb = GETJSAMPLE(*inptr1++);
50
+ cr = GETJSAMPLE(*inptr2++);
51
+ cred = Crrtab[cr];
52
+ cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
53
+ cblue = Cbbtab[cb];
54
+ /* Fetch 2 Y values and emit 2 pixels */
55
+ y = GETJSAMPLE(*inptr0++);
56
+ outptr[RGB_RED] = range_limit[y + cred];
57
+ outptr[RGB_GREEN] = range_limit[y + cgreen];
58
+ outptr[RGB_BLUE] = range_limit[y + cblue];
59
+ #ifdef RGB_ALPHA
60
+ outptr[RGB_ALPHA] = 0xFF;
61
+ #endif
62
+ outptr += RGB_PIXELSIZE;
63
+ y = GETJSAMPLE(*inptr0++);
64
+ outptr[RGB_RED] = range_limit[y + cred];
65
+ outptr[RGB_GREEN] = range_limit[y + cgreen];
66
+ outptr[RGB_BLUE] = range_limit[y + cblue];
67
+ #ifdef RGB_ALPHA
68
+ outptr[RGB_ALPHA] = 0xFF;
69
+ #endif
70
+ outptr += RGB_PIXELSIZE;
71
+ }
72
+ /* If image width is odd, do the last output column separately */
73
+ if (cinfo->output_width & 1) {
74
+ cb = GETJSAMPLE(*inptr1);
75
+ cr = GETJSAMPLE(*inptr2);
76
+ cred = Crrtab[cr];
77
+ cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
78
+ cblue = Cbbtab[cb];
79
+ y = GETJSAMPLE(*inptr0);
80
+ outptr[RGB_RED] = range_limit[y + cred];
81
+ outptr[RGB_GREEN] = range_limit[y + cgreen];
82
+ outptr[RGB_BLUE] = range_limit[y + cblue];
83
+ #ifdef RGB_ALPHA
84
+ outptr[RGB_ALPHA] = 0xFF;
85
+ #endif
86
+ }
87
+ }
88
+
89
+
90
+ /*
91
+ * Upsample and color convert for the case of 2:1 horizontal and 2:1 vertical.
92
+ */
93
+
94
+ INLINE
95
+ LOCAL(void)
96
+ h2v2_merged_upsample_internal(j_decompress_ptr cinfo, JSAMPIMAGE input_buf,
97
+ JDIMENSION in_row_group_ctr,
98
+ JSAMPARRAY output_buf)
99
+ {
100
+ my_upsample_ptr upsample = (my_upsample_ptr)cinfo->upsample;
101
+ register int y, cred, cgreen, cblue;
102
+ int cb, cr;
103
+ register JSAMPROW outptr0, outptr1;
104
+ JSAMPROW inptr00, inptr01, inptr1, inptr2;
105
+ JDIMENSION col;
106
+ /* copy these pointers into registers if possible */
107
+ register JSAMPLE *range_limit = cinfo->sample_range_limit;
108
+ int *Crrtab = upsample->Cr_r_tab;
109
+ int *Cbbtab = upsample->Cb_b_tab;
110
+ JLONG *Crgtab = upsample->Cr_g_tab;
111
+ JLONG *Cbgtab = upsample->Cb_g_tab;
112
+ SHIFT_TEMPS
113
+
114
+ inptr00 = input_buf[0][in_row_group_ctr * 2];
115
+ inptr01 = input_buf[0][in_row_group_ctr * 2 + 1];
116
+ inptr1 = input_buf[1][in_row_group_ctr];
117
+ inptr2 = input_buf[2][in_row_group_ctr];
118
+ outptr0 = output_buf[0];
119
+ outptr1 = output_buf[1];
120
+ /* Loop for each group of output pixels */
121
+ for (col = cinfo->output_width >> 1; col > 0; col--) {
122
+ /* Do the chroma part of the calculation */
123
+ cb = GETJSAMPLE(*inptr1++);
124
+ cr = GETJSAMPLE(*inptr2++);
125
+ cred = Crrtab[cr];
126
+ cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
127
+ cblue = Cbbtab[cb];
128
+ /* Fetch 4 Y values and emit 4 pixels */
129
+ y = GETJSAMPLE(*inptr00++);
130
+ outptr0[RGB_RED] = range_limit[y + cred];
131
+ outptr0[RGB_GREEN] = range_limit[y + cgreen];
132
+ outptr0[RGB_BLUE] = range_limit[y + cblue];
133
+ #ifdef RGB_ALPHA
134
+ outptr0[RGB_ALPHA] = 0xFF;
135
+ #endif
136
+ outptr0 += RGB_PIXELSIZE;
137
+ y = GETJSAMPLE(*inptr00++);
138
+ outptr0[RGB_RED] = range_limit[y + cred];
139
+ outptr0[RGB_GREEN] = range_limit[y + cgreen];
140
+ outptr0[RGB_BLUE] = range_limit[y + cblue];
141
+ #ifdef RGB_ALPHA
142
+ outptr0[RGB_ALPHA] = 0xFF;
143
+ #endif
144
+ outptr0 += RGB_PIXELSIZE;
145
+ y = GETJSAMPLE(*inptr01++);
146
+ outptr1[RGB_RED] = range_limit[y + cred];
147
+ outptr1[RGB_GREEN] = range_limit[y + cgreen];
148
+ outptr1[RGB_BLUE] = range_limit[y + cblue];
149
+ #ifdef RGB_ALPHA
150
+ outptr1[RGB_ALPHA] = 0xFF;
151
+ #endif
152
+ outptr1 += RGB_PIXELSIZE;
153
+ y = GETJSAMPLE(*inptr01++);
154
+ outptr1[RGB_RED] = range_limit[y + cred];
155
+ outptr1[RGB_GREEN] = range_limit[y + cgreen];
156
+ outptr1[RGB_BLUE] = range_limit[y + cblue];
157
+ #ifdef RGB_ALPHA
158
+ outptr1[RGB_ALPHA] = 0xFF;
159
+ #endif
160
+ outptr1 += RGB_PIXELSIZE;
161
+ }
162
+ /* If image width is odd, do the last output column separately */
163
+ if (cinfo->output_width & 1) {
164
+ cb = GETJSAMPLE(*inptr1);
165
+ cr = GETJSAMPLE(*inptr2);
166
+ cred = Crrtab[cr];
167
+ cgreen = (int)RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
168
+ cblue = Cbbtab[cb];
169
+ y = GETJSAMPLE(*inptr00);
170
+ outptr0[RGB_RED] = range_limit[y + cred];
171
+ outptr0[RGB_GREEN] = range_limit[y + cgreen];
172
+ outptr0[RGB_BLUE] = range_limit[y + cblue];
173
+ #ifdef RGB_ALPHA
174
+ outptr0[RGB_ALPHA] = 0xFF;
175
+ #endif
176
+ y = GETJSAMPLE(*inptr01);
177
+ outptr1[RGB_RED] = range_limit[y + cred];
178
+ outptr1[RGB_GREEN] = range_limit[y + cgreen];
179
+ outptr1[RGB_BLUE] = range_limit[y + cblue];
180
+ #ifdef RGB_ALPHA
181
+ outptr1[RGB_ALPHA] = 0xFF;
182
+ #endif
183
+ }
184
+ }