image_pack 0.2.1 → 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 (86) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +20 -0
  3. data/README.md +75 -16
  4. data/ext/image_pack/extconf.rb +41 -126
  5. data/ext/image_pack/image_pack.c +1151 -596
  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 +124 -41
  13. metadata +13 -79
  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
  86. data/lib/image_pack/backend.rb +0 -8
@@ -1,400 +0,0 @@
1
- /*
2
- * AltiVec optimizations for libjpeg-turbo
3
- *
4
- * Copyright (C) 2015, D. R. Commander. All Rights Reserved.
5
- *
6
- * This software is provided 'as-is', without any express or implied
7
- * warranty. In no event will the authors be held liable for any damages
8
- * arising from the use of this software.
9
- *
10
- * Permission is granted to anyone to use this software for any purpose,
11
- * including commercial applications, and to alter it and redistribute it
12
- * freely, subject to the following restrictions:
13
- *
14
- * 1. The origin of this software must not be misrepresented; you must not
15
- * claim that you wrote the original software. If you use this software
16
- * in a product, an acknowledgment in the product documentation would be
17
- * appreciated but is not required.
18
- * 2. Altered source versions must be plainly marked as such, and must not be
19
- * misrepresented as being the original software.
20
- * 3. This notice may not be removed or altered from any source distribution.
21
- */
22
-
23
- /* CHROMA UPSAMPLING */
24
-
25
- #include "jsimd_altivec.h"
26
-
27
-
28
- void jsimd_h2v1_fancy_upsample_altivec(int max_v_samp_factor,
29
- JDIMENSION downsampled_width,
30
- JSAMPARRAY input_data,
31
- JSAMPARRAY *output_data_ptr)
32
- {
33
- JSAMPARRAY output_data = *output_data_ptr;
34
- JSAMPROW inptr, outptr;
35
- int inrow, incol;
36
-
37
- __vector unsigned char this0, last0, p_last0, next0 = { 0 }, p_next0,
38
- out;
39
- __vector short this0e, this0o, this0l, this0h, last0l, last0h,
40
- next0l, next0h, outle, outhe, outlo, outho;
41
-
42
- /* Constants */
43
- __vector unsigned char pb_zero = { __16X(0) }, pb_three = { __16X(3) },
44
- last_index_col0 =
45
- { 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 },
46
- last_index =
47
- { 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30 },
48
- next_index =
49
- { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 },
50
- next_index_lastcol =
51
- { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 15 },
52
- #if __BIG_ENDIAN__
53
- merge_pack_index =
54
- { 1, 17, 3, 19, 5, 21, 7, 23, 9, 25, 11, 27, 13, 29, 15, 31 };
55
- #else
56
- merge_pack_index =
57
- { 0, 16, 2, 18, 4, 20, 6, 22, 8, 24, 10, 26, 12, 28, 14, 30 };
58
- #endif
59
- __vector short pw_one = { __8X(1) }, pw_two = { __8X(2) };
60
-
61
- for (inrow = 0; inrow < max_v_samp_factor; inrow++) {
62
- inptr = input_data[inrow];
63
- outptr = output_data[inrow];
64
-
65
- if (downsampled_width & 15)
66
- inptr[downsampled_width] = inptr[downsampled_width - 1];
67
-
68
- this0 = vec_ld(0, inptr);
69
- p_last0 = vec_perm(this0, this0, last_index_col0);
70
- last0 = this0;
71
-
72
- for (incol = downsampled_width; incol > 0;
73
- incol -= 16, inptr += 16, outptr += 32) {
74
-
75
- if (downsampled_width - incol > 0) {
76
- p_last0 = vec_perm(last0, this0, last_index);
77
- last0 = this0;
78
- }
79
-
80
- if (incol <= 16)
81
- p_next0 = vec_perm(this0, this0, next_index_lastcol);
82
- else {
83
- next0 = vec_ld(16, inptr);
84
- p_next0 = vec_perm(this0, next0, next_index);
85
- }
86
-
87
- this0e = (__vector short)vec_mule(this0, pb_three);
88
- this0o = (__vector short)vec_mulo(this0, pb_three);
89
- this0l = vec_mergeh(this0e, this0o);
90
- this0h = vec_mergel(this0e, this0o);
91
-
92
- last0l = (__vector short)VEC_UNPACKHU(p_last0);
93
- last0h = (__vector short)VEC_UNPACKLU(p_last0);
94
- last0l = vec_add(last0l, pw_one);
95
-
96
- next0l = (__vector short)VEC_UNPACKHU(p_next0);
97
- next0h = (__vector short)VEC_UNPACKLU(p_next0);
98
- next0l = vec_add(next0l, pw_two);
99
-
100
- outle = vec_add(this0l, last0l);
101
- outlo = vec_add(this0l, next0l);
102
- outle = vec_sr(outle, (__vector unsigned short)pw_two);
103
- outlo = vec_sr(outlo, (__vector unsigned short)pw_two);
104
-
105
- out = vec_perm((__vector unsigned char)outle,
106
- (__vector unsigned char)outlo, merge_pack_index);
107
- vec_st(out, 0, outptr);
108
-
109
- if (incol > 8) {
110
- last0h = vec_add(last0h, pw_one);
111
- next0h = vec_add(next0h, pw_two);
112
-
113
- outhe = vec_add(this0h, last0h);
114
- outho = vec_add(this0h, next0h);
115
- outhe = vec_sr(outhe, (__vector unsigned short)pw_two);
116
- outho = vec_sr(outho, (__vector unsigned short)pw_two);
117
-
118
- out = vec_perm((__vector unsigned char)outhe,
119
- (__vector unsigned char)outho, merge_pack_index);
120
- vec_st(out, 16, outptr);
121
- }
122
-
123
- this0 = next0;
124
- }
125
- }
126
- }
127
-
128
-
129
- void jsimd_h2v2_fancy_upsample_altivec(int max_v_samp_factor,
130
- JDIMENSION downsampled_width,
131
- JSAMPARRAY input_data,
132
- JSAMPARRAY *output_data_ptr)
133
- {
134
- JSAMPARRAY output_data = *output_data_ptr;
135
- JSAMPROW inptr_1, inptr0, inptr1, outptr0, outptr1;
136
- int inrow, outrow, incol;
137
-
138
- __vector unsigned char this_1, this0, this1, out;
139
- __vector short this_1l, this_1h, this0l, this0h, this1l, this1h,
140
- lastcolsum_1h, lastcolsum1h,
141
- p_lastcolsum_1l, p_lastcolsum_1h, p_lastcolsum1l, p_lastcolsum1h,
142
- thiscolsum_1l, thiscolsum_1h, thiscolsum1l, thiscolsum1h,
143
- nextcolsum_1l = { 0 }, nextcolsum_1h = { 0 },
144
- nextcolsum1l = { 0 }, nextcolsum1h = { 0 },
145
- p_nextcolsum_1l, p_nextcolsum_1h, p_nextcolsum1l, p_nextcolsum1h,
146
- tmpl, tmph, outle, outhe, outlo, outho;
147
-
148
- /* Constants */
149
- __vector unsigned char pb_zero = { __16X(0) },
150
- last_index_col0 =
151
- { 0, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 },
152
- last_index =
153
- { 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29 },
154
- next_index =
155
- { 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 },
156
- next_index_lastcol =
157
- { 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 15 },
158
- #if __BIG_ENDIAN__
159
- merge_pack_index =
160
- { 1, 17, 3, 19, 5, 21, 7, 23, 9, 25, 11, 27, 13, 29, 15, 31 };
161
- #else
162
- merge_pack_index =
163
- { 0, 16, 2, 18, 4, 20, 6, 22, 8, 24, 10, 26, 12, 28, 14, 30 };
164
- #endif
165
- __vector short pw_zero = { __8X(0) }, pw_three = { __8X(3) },
166
- pw_seven = { __8X(7) }, pw_eight = { __8X(8) };
167
- __vector unsigned short pw_four = { __8X(4) };
168
-
169
- for (inrow = 0, outrow = 0; outrow < max_v_samp_factor; inrow++) {
170
-
171
- inptr_1 = input_data[inrow - 1];
172
- inptr0 = input_data[inrow];
173
- inptr1 = input_data[inrow + 1];
174
- outptr0 = output_data[outrow++];
175
- outptr1 = output_data[outrow++];
176
-
177
- if (downsampled_width & 15) {
178
- inptr_1[downsampled_width] = inptr_1[downsampled_width - 1];
179
- inptr0[downsampled_width] = inptr0[downsampled_width - 1];
180
- inptr1[downsampled_width] = inptr1[downsampled_width - 1];
181
- }
182
-
183
- this0 = vec_ld(0, inptr0);
184
- this0l = (__vector short)VEC_UNPACKHU(this0);
185
- this0h = (__vector short)VEC_UNPACKLU(this0);
186
- this0l = vec_mladd(this0l, pw_three, pw_zero);
187
- this0h = vec_mladd(this0h, pw_three, pw_zero);
188
-
189
- this_1 = vec_ld(0, inptr_1);
190
- this_1l = (__vector short)VEC_UNPACKHU(this_1);
191
- this_1h = (__vector short)VEC_UNPACKLU(this_1);
192
- thiscolsum_1l = vec_add(this0l, this_1l);
193
- thiscolsum_1h = vec_add(this0h, this_1h);
194
- lastcolsum_1h = thiscolsum_1h;
195
- p_lastcolsum_1l = vec_perm(thiscolsum_1l, thiscolsum_1l, last_index_col0);
196
- p_lastcolsum_1h = vec_perm(thiscolsum_1l, thiscolsum_1h, last_index);
197
-
198
- this1 = vec_ld(0, inptr1);
199
- this1l = (__vector short)VEC_UNPACKHU(this1);
200
- this1h = (__vector short)VEC_UNPACKLU(this1);
201
- thiscolsum1l = vec_add(this0l, this1l);
202
- thiscolsum1h = vec_add(this0h, this1h);
203
- lastcolsum1h = thiscolsum1h;
204
- p_lastcolsum1l = vec_perm(thiscolsum1l, thiscolsum1l, last_index_col0);
205
- p_lastcolsum1h = vec_perm(thiscolsum1l, thiscolsum1h, last_index);
206
-
207
- for (incol = downsampled_width; incol > 0;
208
- incol -= 16, inptr_1 += 16, inptr0 += 16, inptr1 += 16,
209
- outptr0 += 32, outptr1 += 32) {
210
-
211
- if (downsampled_width - incol > 0) {
212
- p_lastcolsum_1l = vec_perm(lastcolsum_1h, thiscolsum_1l, last_index);
213
- p_lastcolsum_1h = vec_perm(thiscolsum_1l, thiscolsum_1h, last_index);
214
- p_lastcolsum1l = vec_perm(lastcolsum1h, thiscolsum1l, last_index);
215
- p_lastcolsum1h = vec_perm(thiscolsum1l, thiscolsum1h, last_index);
216
- lastcolsum_1h = thiscolsum_1h; lastcolsum1h = thiscolsum1h;
217
- }
218
-
219
- if (incol <= 16) {
220
- p_nextcolsum_1l = vec_perm(thiscolsum_1l, thiscolsum_1h, next_index);
221
- p_nextcolsum_1h = vec_perm(thiscolsum_1h, thiscolsum_1h,
222
- next_index_lastcol);
223
- p_nextcolsum1l = vec_perm(thiscolsum1l, thiscolsum1h, next_index);
224
- p_nextcolsum1h = vec_perm(thiscolsum1h, thiscolsum1h,
225
- next_index_lastcol);
226
- } else {
227
- this0 = vec_ld(16, inptr0);
228
- this0l = (__vector short)VEC_UNPACKHU(this0);
229
- this0h = (__vector short)VEC_UNPACKLU(this0);
230
- this0l = vec_mladd(this0l, pw_three, pw_zero);
231
- this0h = vec_mladd(this0h, pw_three, pw_zero);
232
-
233
- this_1 = vec_ld(16, inptr_1);
234
- this_1l = (__vector short)VEC_UNPACKHU(this_1);
235
- this_1h = (__vector short)VEC_UNPACKLU(this_1);
236
- nextcolsum_1l = vec_add(this0l, this_1l);
237
- nextcolsum_1h = vec_add(this0h, this_1h);
238
- p_nextcolsum_1l = vec_perm(thiscolsum_1l, thiscolsum_1h, next_index);
239
- p_nextcolsum_1h = vec_perm(thiscolsum_1h, nextcolsum_1l, next_index);
240
-
241
- this1 = vec_ld(16, inptr1);
242
- this1l = (__vector short)VEC_UNPACKHU(this1);
243
- this1h = (__vector short)VEC_UNPACKLU(this1);
244
- nextcolsum1l = vec_add(this0l, this1l);
245
- nextcolsum1h = vec_add(this0h, this1h);
246
- p_nextcolsum1l = vec_perm(thiscolsum1l, thiscolsum1h, next_index);
247
- p_nextcolsum1h = vec_perm(thiscolsum1h, nextcolsum1l, next_index);
248
- }
249
-
250
- /* Process the upper row */
251
-
252
- tmpl = vec_mladd(thiscolsum_1l, pw_three, pw_zero);
253
- outle = vec_add(tmpl, p_lastcolsum_1l);
254
- outle = vec_add(outle, pw_eight);
255
- outle = vec_sr(outle, pw_four);
256
-
257
- outlo = vec_add(tmpl, p_nextcolsum_1l);
258
- outlo = vec_add(outlo, pw_seven);
259
- outlo = vec_sr(outlo, pw_four);
260
-
261
- out = vec_perm((__vector unsigned char)outle,
262
- (__vector unsigned char)outlo, merge_pack_index);
263
- vec_st(out, 0, outptr0);
264
-
265
- if (incol > 8) {
266
- tmph = vec_mladd(thiscolsum_1h, pw_three, pw_zero);
267
- outhe = vec_add(tmph, p_lastcolsum_1h);
268
- outhe = vec_add(outhe, pw_eight);
269
- outhe = vec_sr(outhe, pw_four);
270
-
271
- outho = vec_add(tmph, p_nextcolsum_1h);
272
- outho = vec_add(outho, pw_seven);
273
- outho = vec_sr(outho, pw_four);
274
-
275
- out = vec_perm((__vector unsigned char)outhe,
276
- (__vector unsigned char)outho, merge_pack_index);
277
- vec_st(out, 16, outptr0);
278
- }
279
-
280
- /* Process the lower row */
281
-
282
- tmpl = vec_mladd(thiscolsum1l, pw_three, pw_zero);
283
- outle = vec_add(tmpl, p_lastcolsum1l);
284
- outle = vec_add(outle, pw_eight);
285
- outle = vec_sr(outle, pw_four);
286
-
287
- outlo = vec_add(tmpl, p_nextcolsum1l);
288
- outlo = vec_add(outlo, pw_seven);
289
- outlo = vec_sr(outlo, pw_four);
290
-
291
- out = vec_perm((__vector unsigned char)outle,
292
- (__vector unsigned char)outlo, merge_pack_index);
293
- vec_st(out, 0, outptr1);
294
-
295
- if (incol > 8) {
296
- tmph = vec_mladd(thiscolsum1h, pw_three, pw_zero);
297
- outhe = vec_add(tmph, p_lastcolsum1h);
298
- outhe = vec_add(outhe, pw_eight);
299
- outhe = vec_sr(outhe, pw_four);
300
-
301
- outho = vec_add(tmph, p_nextcolsum1h);
302
- outho = vec_add(outho, pw_seven);
303
- outho = vec_sr(outho, pw_four);
304
-
305
- out = vec_perm((__vector unsigned char)outhe,
306
- (__vector unsigned char)outho, merge_pack_index);
307
- vec_st(out, 16, outptr1);
308
- }
309
-
310
- thiscolsum_1l = nextcolsum_1l; thiscolsum_1h = nextcolsum_1h;
311
- thiscolsum1l = nextcolsum1l; thiscolsum1h = nextcolsum1h;
312
- }
313
- }
314
- }
315
-
316
-
317
- /* These are rarely used (mainly just for decompressing YCCK images) */
318
-
319
- void jsimd_h2v1_upsample_altivec(int max_v_samp_factor,
320
- JDIMENSION output_width,
321
- JSAMPARRAY input_data,
322
- JSAMPARRAY *output_data_ptr)
323
- {
324
- JSAMPARRAY output_data = *output_data_ptr;
325
- JSAMPROW inptr, outptr;
326
- int inrow, incol;
327
-
328
- __vector unsigned char in, inl, inh;
329
-
330
- for (inrow = 0; inrow < max_v_samp_factor; inrow++) {
331
- inptr = input_data[inrow];
332
- outptr = output_data[inrow];
333
-
334
- for (incol = (output_width + 31) & (~31); incol > 0;
335
- incol -= 64, inptr += 32, outptr += 64) {
336
-
337
- in = vec_ld(0, inptr);
338
- inl = vec_mergeh(in, in);
339
- inh = vec_mergel(in, in);
340
-
341
- vec_st(inl, 0, outptr);
342
- vec_st(inh, 16, outptr);
343
-
344
- if (incol > 32) {
345
- in = vec_ld(16, inptr);
346
- inl = vec_mergeh(in, in);
347
- inh = vec_mergel(in, in);
348
-
349
- vec_st(inl, 32, outptr);
350
- vec_st(inh, 48, outptr);
351
- }
352
- }
353
- }
354
- }
355
-
356
-
357
- void jsimd_h2v2_upsample_altivec(int max_v_samp_factor,
358
- JDIMENSION output_width,
359
- JSAMPARRAY input_data,
360
- JSAMPARRAY *output_data_ptr)
361
- {
362
- JSAMPARRAY output_data = *output_data_ptr;
363
- JSAMPROW inptr, outptr0, outptr1;
364
- int inrow, outrow, incol;
365
-
366
- __vector unsigned char in, inl, inh;
367
-
368
- for (inrow = 0, outrow = 0; outrow < max_v_samp_factor; inrow++) {
369
-
370
- inptr = input_data[inrow];
371
- outptr0 = output_data[outrow++];
372
- outptr1 = output_data[outrow++];
373
-
374
- for (incol = (output_width + 31) & (~31); incol > 0;
375
- incol -= 64, inptr += 32, outptr0 += 64, outptr1 += 64) {
376
-
377
- in = vec_ld(0, inptr);
378
- inl = vec_mergeh(in, in);
379
- inh = vec_mergel(in, in);
380
-
381
- vec_st(inl, 0, outptr0);
382
- vec_st(inl, 0, outptr1);
383
-
384
- vec_st(inh, 16, outptr0);
385
- vec_st(inh, 16, outptr1);
386
-
387
- if (incol > 32) {
388
- in = vec_ld(16, inptr);
389
- inl = vec_mergeh(in, in);
390
- inh = vec_mergel(in, in);
391
-
392
- vec_st(inl, 32, outptr0);
393
- vec_st(inl, 32, outptr1);
394
-
395
- vec_st(inh, 48, outptr0);
396
- vec_st(inh, 48, outptr1);
397
- }
398
- }
399
- }
400
- }
@@ -1,154 +0,0 @@
1
- /*
2
- * AltiVec optimizations for libjpeg-turbo
3
- *
4
- * Copyright (C) 2014, D. R. Commander. All Rights Reserved.
5
- *
6
- * This software is provided 'as-is', without any express or implied
7
- * warranty. In no event will the authors be held liable for any damages
8
- * arising from the use of this software.
9
- *
10
- * Permission is granted to anyone to use this software for any purpose,
11
- * including commercial applications, and to alter it and redistribute it
12
- * freely, subject to the following restrictions:
13
- *
14
- * 1. The origin of this software must not be misrepresented; you must not
15
- * claim that you wrote the original software. If you use this software
16
- * in a product, an acknowledgment in the product documentation would be
17
- * appreciated but is not required.
18
- * 2. Altered source versions must be plainly marked as such, and must not be
19
- * misrepresented as being the original software.
20
- * 3. This notice may not be removed or altered from any source distribution.
21
- */
22
-
23
- /* FAST INTEGER FORWARD DCT
24
- *
25
- * This is similar to the SSE2 implementation, except that we left-shift the
26
- * constants by 1 less bit (the -1 in CONST_SHIFT.) This is because
27
- * vec_madds(arg1, arg2, arg3) generates the 16-bit saturated sum of:
28
- * the elements in arg3 + the most significant 17 bits of
29
- * (the elements in arg1 * the elements in arg2).
30
- */
31
-
32
- #include "jsimd_altivec.h"
33
-
34
-
35
- #define F_0_382 98 /* FIX(0.382683433) */
36
- #define F_0_541 139 /* FIX(0.541196100) */
37
- #define F_0_707 181 /* FIX(0.707106781) */
38
- #define F_1_306 334 /* FIX(1.306562965) */
39
-
40
- #define CONST_BITS 8
41
- #define PRE_MULTIPLY_SCALE_BITS 2
42
- #define CONST_SHIFT (16 - PRE_MULTIPLY_SCALE_BITS - CONST_BITS - 1)
43
-
44
-
45
- #define DO_FDCT() { \
46
- /* Even part */ \
47
- \
48
- tmp10 = vec_add(tmp0, tmp3); \
49
- tmp13 = vec_sub(tmp0, tmp3); \
50
- tmp11 = vec_add(tmp1, tmp2); \
51
- tmp12 = vec_sub(tmp1, tmp2); \
52
- \
53
- out0 = vec_add(tmp10, tmp11); \
54
- out4 = vec_sub(tmp10, tmp11); \
55
- \
56
- z1 = vec_add(tmp12, tmp13); \
57
- z1 = vec_sl(z1, pre_multiply_scale_bits); \
58
- z1 = vec_madds(z1, pw_0707, pw_zero); \
59
- \
60
- out2 = vec_add(tmp13, z1); \
61
- out6 = vec_sub(tmp13, z1); \
62
- \
63
- /* Odd part */ \
64
- \
65
- tmp10 = vec_add(tmp4, tmp5); \
66
- tmp11 = vec_add(tmp5, tmp6); \
67
- tmp12 = vec_add(tmp6, tmp7); \
68
- \
69
- tmp10 = vec_sl(tmp10, pre_multiply_scale_bits); \
70
- tmp12 = vec_sl(tmp12, pre_multiply_scale_bits); \
71
- z5 = vec_sub(tmp10, tmp12); \
72
- z5 = vec_madds(z5, pw_0382, pw_zero); \
73
- \
74
- z2 = vec_madds(tmp10, pw_0541, z5); \
75
- z4 = vec_madds(tmp12, pw_1306, z5); \
76
- \
77
- tmp11 = vec_sl(tmp11, pre_multiply_scale_bits); \
78
- z3 = vec_madds(tmp11, pw_0707, pw_zero); \
79
- \
80
- z11 = vec_add(tmp7, z3); \
81
- z13 = vec_sub(tmp7, z3); \
82
- \
83
- out5 = vec_add(z13, z2); \
84
- out3 = vec_sub(z13, z2); \
85
- out1 = vec_add(z11, z4); \
86
- out7 = vec_sub(z11, z4); \
87
- }
88
-
89
-
90
- void jsimd_fdct_ifast_altivec(DCTELEM *data)
91
- {
92
- __vector short row0, row1, row2, row3, row4, row5, row6, row7,
93
- col0, col1, col2, col3, col4, col5, col6, col7,
94
- tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp10, tmp11, tmp12, tmp13,
95
- z1, z2, z3, z4, z5, z11, z13,
96
- out0, out1, out2, out3, out4, out5, out6, out7;
97
-
98
- /* Constants */
99
- __vector short pw_zero = { __8X(0) },
100
- pw_0382 = { __8X(F_0_382 << CONST_SHIFT) },
101
- pw_0541 = { __8X(F_0_541 << CONST_SHIFT) },
102
- pw_0707 = { __8X(F_0_707 << CONST_SHIFT) },
103
- pw_1306 = { __8X(F_1_306 << CONST_SHIFT) };
104
- __vector unsigned short
105
- pre_multiply_scale_bits = { __8X(PRE_MULTIPLY_SCALE_BITS) };
106
-
107
- /* Pass 1: process rows */
108
-
109
- row0 = vec_ld(0, data);
110
- row1 = vec_ld(16, data);
111
- row2 = vec_ld(32, data);
112
- row3 = vec_ld(48, data);
113
- row4 = vec_ld(64, data);
114
- row5 = vec_ld(80, data);
115
- row6 = vec_ld(96, data);
116
- row7 = vec_ld(112, data);
117
-
118
- TRANSPOSE(row, col);
119
-
120
- tmp0 = vec_add(col0, col7);
121
- tmp7 = vec_sub(col0, col7);
122
- tmp1 = vec_add(col1, col6);
123
- tmp6 = vec_sub(col1, col6);
124
- tmp2 = vec_add(col2, col5);
125
- tmp5 = vec_sub(col2, col5);
126
- tmp3 = vec_add(col3, col4);
127
- tmp4 = vec_sub(col3, col4);
128
-
129
- DO_FDCT();
130
-
131
- /* Pass 2: process columns */
132
-
133
- TRANSPOSE(out, row);
134
-
135
- tmp0 = vec_add(row0, row7);
136
- tmp7 = vec_sub(row0, row7);
137
- tmp1 = vec_add(row1, row6);
138
- tmp6 = vec_sub(row1, row6);
139
- tmp2 = vec_add(row2, row5);
140
- tmp5 = vec_sub(row2, row5);
141
- tmp3 = vec_add(row3, row4);
142
- tmp4 = vec_sub(row3, row4);
143
-
144
- DO_FDCT();
145
-
146
- vec_st(out0, 0, data);
147
- vec_st(out1, 16, data);
148
- vec_st(out2, 32, data);
149
- vec_st(out3, 48, data);
150
- vec_st(out4, 64, data);
151
- vec_st(out5, 80, data);
152
- vec_st(out6, 96, data);
153
- vec_st(out7, 112, data);
154
- }