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,304 +0,0 @@
1
- /*
2
- * Loongson MMI optimizations for libjpeg-turbo
3
- *
4
- * Copyright (C) 2015, 2018-2019, D. R. Commander. All Rights Reserved.
5
- * Copyright (C) 2016-2018, Loongson Technology Corporation Limited, BeiJing.
6
- * All Rights Reserved.
7
- * Authors: ZhuChen <zhuchen@loongson.cn>
8
- * CaiWanwei <caiwanwei@loongson.cn>
9
- * SunZhangzhi <sunzhangzhi-cq@loongson.cn>
10
- * ZhangLixia <zhanglixia-hf@loongson.cn>
11
- *
12
- * Based on the x86 SIMD extension for IJG JPEG library
13
- * Copyright (C) 1999-2006, MIYASAKA Masaru.
14
- *
15
- * This software is provided 'as-is', without any express or implied
16
- * warranty. In no event will the authors be held liable for any damages
17
- * arising from the use of this software.
18
- *
19
- * Permission is granted to anyone to use this software for any purpose,
20
- * including commercial applications, and to alter it and redistribute it
21
- * freely, subject to the following restrictions:
22
- *
23
- * 1. The origin of this software must not be misrepresented; you must not
24
- * claim that you wrote the original software. If you use this software
25
- * in a product, an acknowledgment in the product documentation would be
26
- * appreciated but is not required.
27
- * 2. Altered source versions must be plainly marked as such, and must not be
28
- * misrepresented as being the original software.
29
- * 3. This notice may not be removed or altered from any source distribution.
30
- */
31
-
32
- /* CHROMA UPSAMPLING */
33
-
34
- #include "jsimd_mmi.h"
35
-
36
-
37
- enum const_index {
38
- index_PW_ONE,
39
- index_PW_TWO,
40
- index_PW_THREE,
41
- index_PW_SEVEN,
42
- index_PW_EIGHT,
43
- };
44
-
45
- static uint64_t const_value[] = {
46
- _uint64_set_pi16(1, 1, 1, 1),
47
- _uint64_set_pi16(2, 2, 2, 2),
48
- _uint64_set_pi16(3, 3, 3, 3),
49
- _uint64_set_pi16(7, 7, 7, 7),
50
- _uint64_set_pi16(8, 8, 8, 8),
51
- };
52
-
53
- #define PW_ONE get_const_value(index_PW_ONE)
54
- #define PW_TWO get_const_value(index_PW_TWO)
55
- #define PW_THREE get_const_value(index_PW_THREE)
56
- #define PW_SEVEN get_const_value(index_PW_SEVEN)
57
- #define PW_EIGHT get_const_value(index_PW_EIGHT)
58
-
59
-
60
- #define PROCESS_ROW(row, wkoffset, bias1, bias2, shift) { \
61
- __m64 samp123X, samp3XXX, samp1234, sampX012, samp_1012; \
62
- __m64 sampXXX4, sampX456, samp3456, samp567X, samp7XXX, samp5678; \
63
- __m64 outle, outhe, outlo, outho, outl, outh; \
64
- \
65
- samp123X = _mm_srli_si64(samp0123, 2 * BYTE_BIT); /* ( 1 2 3 -) */ \
66
- sampXXX4 = _mm_slli_si64(samp4567, (SIZEOF_MMWORD - 2) * BYTE_BIT); /* ( - - - 4) */ \
67
- samp3XXX = _mm_srli_si64(samp0123, (SIZEOF_MMWORD - 2) * BYTE_BIT); /* ( 3 - - -) */ \
68
- sampX456 = _mm_slli_si64(samp4567, 2 * BYTE_BIT); /* ( - 4 5 6) */ \
69
- \
70
- samp1234 = _mm_or_si64(samp123X, sampXXX4); /* ( 1 2 3 4) */ \
71
- samp3456 = _mm_or_si64(samp3XXX, sampX456); /* ( 3 4 5 6) */ \
72
- \
73
- sampX012 = _mm_slli_si64(samp0123, 2 * BYTE_BIT); /* ( - 0 1 2) */ \
74
- samp567X = _mm_srli_si64(samp4567, 2 * BYTE_BIT); /* ( 5 6 7 -) */ \
75
- samp7XXX = _mm_srli_si64(samp4567, (SIZEOF_MMWORD - 2) * BYTE_BIT); /* ( 7 - - -) */ \
76
- \
77
- samp_1012 = _mm_or_si64(sampX012, wk[row]); /* (-1 0 1 2) */ \
78
- samp5678 = _mm_or_si64(samp567X, wk[row + wkoffset]); /* ( 5 6 7 8) */ \
79
- \
80
- wk[row] = samp7XXX; \
81
- \
82
- samp0123 = _mm_mullo_pi16(samp0123, PW_THREE); \
83
- samp4567 = _mm_mullo_pi16(samp4567, PW_THREE); \
84
- samp_1012 = _mm_add_pi16(samp_1012, bias1); \
85
- samp3456 = _mm_add_pi16(samp3456, bias1); \
86
- samp1234 = _mm_add_pi16(samp1234, bias2); \
87
- samp5678 = _mm_add_pi16(samp5678, bias2); \
88
- \
89
- outle = _mm_add_pi16(samp_1012, samp0123); \
90
- outhe = _mm_add_pi16(samp3456, samp4567); \
91
- outle = _mm_srli_pi16(outle, shift); /* ( 0 2 4 6) */ \
92
- outhe = _mm_srli_pi16(outhe, shift); /* ( 8 10 12 14) */ \
93
- outlo = _mm_add_pi16(samp1234, samp0123); \
94
- outho = _mm_add_pi16(samp5678, samp4567); \
95
- outlo = _mm_srli_pi16(outlo, shift); /* ( 1 3 5 7) */ \
96
- outho = _mm_srli_pi16(outho, shift); /* ( 9 11 13 15) */ \
97
- \
98
- outlo = _mm_slli_pi16(outlo, BYTE_BIT); \
99
- outho = _mm_slli_pi16(outho, BYTE_BIT); \
100
- outl = _mm_or_si64(outle, outlo); /* ( 0 1 2 3 4 5 6 7) */ \
101
- outh = _mm_or_si64(outhe, outho); /* ( 8 9 10 11 12 13 14 15) */ \
102
- \
103
- _mm_store_si64((__m64 *)outptr##row, outl); \
104
- _mm_store_si64((__m64 *)outptr##row + 1, outh); \
105
- }
106
-
107
- void jsimd_h2v2_fancy_upsample_mmi(int max_v_samp_factor,
108
- JDIMENSION downsampled_width,
109
- JSAMPARRAY input_data,
110
- JSAMPARRAY *output_data_ptr)
111
- {
112
- JSAMPARRAY output_data = *output_data_ptr;
113
- JSAMPROW inptr_1, inptr0, inptr1, outptr0, outptr1;
114
- int inrow, outrow, incol, tmp, tmp1;
115
- __m64 this_1l, this_1h, this_1, thiscolsum_1l, thiscolsum_1h;
116
- __m64 this0l, this0h, this0;
117
- __m64 this1l, this1h, this1, thiscolsum1l, thiscolsum1h;
118
- __m64 next_1l, next_1h, next_1, nextcolsum_1l, nextcolsum_1h;
119
- __m64 next0l, next0h, next0;
120
- __m64 next1l, next1h, next1, nextcolsum1l, nextcolsum1h;
121
- __m64 mask0 = 0.0, masklast, samp0123, samp4567, wk[4], zero = 0.0;
122
-
123
- mask0 = _mm_cmpeq_pi8(mask0, mask0);
124
- masklast = _mm_slli_si64(mask0, (SIZEOF_MMWORD - 2) * BYTE_BIT);
125
- mask0 = _mm_srli_si64(mask0, (SIZEOF_MMWORD - 2) * BYTE_BIT);
126
-
127
- for (inrow = 0, outrow = 0; outrow < max_v_samp_factor; inrow++) {
128
-
129
- inptr_1 = input_data[inrow - 1];
130
- inptr0 = input_data[inrow];
131
- inptr1 = input_data[inrow + 1];
132
- outptr0 = output_data[outrow++];
133
- outptr1 = output_data[outrow++];
134
-
135
- if (downsampled_width & 7) {
136
- tmp = (downsampled_width - 1) * sizeof(JSAMPLE);
137
- tmp1 = downsampled_width * sizeof(JSAMPLE);
138
- asm(PTR_ADDU "$8, %3, %6\r\n"
139
- "lb $9, ($8)\r\n"
140
- PTR_ADDU "$8, %3, %7\r\n"
141
- "sb $9, ($8)\r\n"
142
- PTR_ADDU "$8, %4, %6\r\n"
143
- "lb $9, ($8)\r\n"
144
- PTR_ADDU "$8, %4, %7\r\n"
145
- "sb $9, ($8)\r\n"
146
- PTR_ADDU "$8, %5, %6\r\n"
147
- "lb $9, ($8)\r\n"
148
- PTR_ADDU "$8, %5, %7\r\n"
149
- "sb $9, ($8)\r\n"
150
- : "=m" (*inptr_1), "=m" (*inptr0), "=m" (*inptr1)
151
- : "r" (inptr_1), "r" (inptr0), "r" (inptr1), "r" (tmp), "r" (tmp1)
152
- : "$8", "$9"
153
- );
154
- }
155
-
156
- /* process the first column block */
157
- this0 = _mm_load_si64((__m64 *)inptr0); /* row[ 0][0] */
158
- this_1 = _mm_load_si64((__m64 *)inptr_1); /* row[-1][0] */
159
- this1 = _mm_load_si64((__m64 *)inptr1); /* row[ 1][0] */
160
-
161
- this0l = _mm_unpacklo_pi8(this0, zero); /* row[ 0][0]( 0 1 2 3) */
162
- this0h = _mm_unpackhi_pi8(this0, zero); /* row[ 0][0]( 4 5 6 7) */
163
- this_1l = _mm_unpacklo_pi8(this_1, zero); /* row[-1][0]( 0 1 2 3) */
164
- this_1h = _mm_unpackhi_pi8(this_1, zero); /* row[-1][0]( 4 5 6 7) */
165
- this1l = _mm_unpacklo_pi8(this1, zero); /* row[+1][0]( 0 1 2 3) */
166
- this1h = _mm_unpackhi_pi8(this1, zero); /* row[+1][0]( 4 5 6 7) */
167
-
168
- this0l = _mm_mullo_pi16(this0l, PW_THREE);
169
- this0h = _mm_mullo_pi16(this0h, PW_THREE);
170
-
171
- thiscolsum_1l = _mm_add_pi16(this_1l, this0l); /* ( 0 1 2 3) */
172
- thiscolsum_1h = _mm_add_pi16(this_1h, this0h); /* ( 4 5 6 7) */
173
- thiscolsum1l = _mm_add_pi16(this0l, this1l); /* ( 0 1 2 3) */
174
- thiscolsum1h = _mm_add_pi16(this0h, this1h); /* ( 4 5 6 7) */
175
-
176
- /* temporarily save the intermediate data */
177
- _mm_store_si64((__m64 *)outptr0, thiscolsum_1l);
178
- _mm_store_si64((__m64 *)outptr0 + 1, thiscolsum_1h);
179
- _mm_store_si64((__m64 *)outptr1, thiscolsum1l);
180
- _mm_store_si64((__m64 *)outptr1 + 1, thiscolsum1h);
181
-
182
- wk[0] = _mm_and_si64(thiscolsum_1l, mask0); /* ( 0 - - -) */
183
- wk[1] = _mm_and_si64(thiscolsum1l, mask0); /* ( 0 - - -) */
184
-
185
- for (incol = downsampled_width; incol > 0;
186
- incol -= 8, inptr_1 += 8, inptr0 += 8, inptr1 += 8,
187
- outptr0 += 16, outptr1 += 16) {
188
-
189
- if (incol > 8) {
190
- /* process the next column block */
191
- next0 = _mm_load_si64((__m64 *)inptr0 + 1); /* row[ 0][1] */
192
- next_1 = _mm_load_si64((__m64 *)inptr_1 + 1); /* row[-1][1] */
193
- next1 = _mm_load_si64((__m64 *)inptr1 + 1); /* row[+1][1] */
194
-
195
- next0l = _mm_unpacklo_pi8(next0, zero); /* row[ 0][1]( 0 1 2 3) */
196
- next0h = _mm_unpackhi_pi8(next0, zero); /* row[ 0][1]( 4 5 6 7) */
197
- next_1l = _mm_unpacklo_pi8(next_1, zero); /* row[-1][1]( 0 1 2 3) */
198
- next_1h = _mm_unpackhi_pi8(next_1, zero); /* row[-1][1]( 4 5 6 7) */
199
- next1l = _mm_unpacklo_pi8(next1, zero); /* row[+1][1]( 0 1 2 3) */
200
- next1h = _mm_unpackhi_pi8(next1, zero); /* row[+1][1]( 4 5 6 7) */
201
-
202
- next0l = _mm_mullo_pi16(next0l, PW_THREE);
203
- next0h = _mm_mullo_pi16(next0h, PW_THREE);
204
-
205
- nextcolsum_1l = _mm_add_pi16(next_1l, next0l); /* ( 0 1 2 3) */
206
- nextcolsum_1h = _mm_add_pi16(next_1h, next0h); /* ( 4 5 6 7) */
207
- nextcolsum1l = _mm_add_pi16(next0l, next1l); /* ( 0 1 2 3) */
208
- nextcolsum1h = _mm_add_pi16(next0h, next1h); /* ( 4 5 6 7) */
209
-
210
- /* temporarily save the intermediate data */
211
- _mm_store_si64((__m64 *)outptr0 + 2, nextcolsum_1l);
212
- _mm_store_si64((__m64 *)outptr0 + 3, nextcolsum_1h);
213
- _mm_store_si64((__m64 *)outptr1 + 2, nextcolsum1l);
214
- _mm_store_si64((__m64 *)outptr1 + 3, nextcolsum1h);
215
-
216
- wk[2] = _mm_slli_si64(nextcolsum_1l, (SIZEOF_MMWORD - 2) * BYTE_BIT); /* ( - - - 0) */
217
- wk[3] = _mm_slli_si64(nextcolsum1l, (SIZEOF_MMWORD - 2) * BYTE_BIT); /* ( - - - 0) */
218
- } else {
219
- __m64 tmp;
220
-
221
- /* process the last column block */
222
- tmp = _mm_load_si64((__m64 *)outptr0 + 1);
223
- wk[2] = _mm_and_si64(masklast, tmp); /* ( - - - 7) */
224
- tmp = _mm_load_si64((__m64 *)outptr1 + 1);
225
- wk[3] = _mm_and_si64(masklast, tmp); /* ( - - - 7) */
226
- }
227
-
228
- /* process the upper row */
229
- samp0123 = _mm_load_si64((__m64 *)outptr0); /* ( 0 1 2 3) */ \
230
- samp4567 = _mm_load_si64((__m64 *)outptr0 + 1); /* ( 4 5 6 7) */ \
231
- PROCESS_ROW(0, 2, PW_EIGHT, PW_SEVEN, 4)
232
-
233
- /* process the lower row */
234
- samp0123 = _mm_load_si64((__m64 *)outptr1); /* ( 0 1 2 3) */ \
235
- samp4567 = _mm_load_si64((__m64 *)outptr1 + 1); /* ( 4 5 6 7) */ \
236
- PROCESS_ROW(1, 2, PW_EIGHT, PW_SEVEN, 4)
237
- }
238
- }
239
- }
240
-
241
-
242
- void jsimd_h2v1_fancy_upsample_mmi(int max_v_samp_factor,
243
- JDIMENSION downsampled_width,
244
- JSAMPARRAY input_data,
245
- JSAMPARRAY *output_data_ptr)
246
- {
247
- JSAMPARRAY output_data = *output_data_ptr;
248
- JSAMPROW inptr0, outptr0;
249
- int inrow, incol, tmp, tmp1;
250
- __m64 thisl, this, nextl, next;
251
- __m64 mask0 = 0.0, masklast, samp0123, samp4567, wk[2], zero = 0.0;
252
-
253
- mask0 = _mm_cmpeq_pi8(mask0, mask0);
254
- masklast = _mm_slli_si64(mask0, (SIZEOF_MMWORD - 2) * BYTE_BIT);
255
- mask0 = _mm_srli_si64(mask0, (SIZEOF_MMWORD - 2) * BYTE_BIT);
256
-
257
- for (inrow = 0; inrow < max_v_samp_factor; inrow++) {
258
-
259
- inptr0 = input_data[inrow];
260
- outptr0 = output_data[inrow];
261
-
262
- if (downsampled_width & 7) {
263
- tmp = (downsampled_width - 1) * sizeof(JSAMPLE);
264
- tmp1 = downsampled_width * sizeof(JSAMPLE);
265
- asm(PTR_ADDU "$8, %1, %2\r\n"
266
- "lb $9, ($8)\r\n"
267
- PTR_ADDU "$8, %1, %3\r\n"
268
- "sb $9, ($8)\r\n"
269
- : "=m" (*inptr0)
270
- : "r" (inptr0), "r" (tmp), "r" (tmp1)
271
- : "$8", "$9"
272
- );
273
- }
274
-
275
- /* process the first column block */
276
- this = _mm_load_si64((__m64 *)inptr0); /* row[ 0][0] */
277
- thisl = _mm_unpacklo_pi8(this, zero); /* row[ 0][0]( 0 1 2 3) */
278
- wk[0] = _mm_and_si64(thisl, mask0); /* ( 0 - - -) */
279
-
280
- for (incol = downsampled_width; incol > 0;
281
- incol -= 8, inptr0 += 8, outptr0 += 16) {
282
-
283
- if (incol > 8) {
284
- /* process the next column block */
285
- next = _mm_load_si64((__m64 *)inptr0 + 1); /* row[ 0][1] */
286
- nextl = _mm_unpacklo_pi8(next, zero); /* row[ 0][1]( 0 1 2 3) */
287
- wk[1] = _mm_slli_si64(nextl, (SIZEOF_MMWORD - 2) * BYTE_BIT); /* ( - - - 0) */
288
- } else {
289
- __m64 thish;
290
-
291
- /* process the last column block */
292
- this = _mm_load_si64((__m64 *)inptr0); /* row[ 0][0] */
293
- thish = _mm_unpackhi_pi8(this, zero); /* row[ 0][1]( 4 5 6 7) */
294
- wk[1] = _mm_and_si64(masklast, thish); /* ( - - - 7) */
295
- }
296
-
297
- /* process the row */
298
- this = _mm_load_si64((__m64 *)inptr0); /* row[ 0][0] */
299
- samp0123 = _mm_unpacklo_pi8(this, zero); /* ( 0 1 2 3) */
300
- samp4567 = _mm_unpackhi_pi8(this, zero); /* ( 4 5 6 7) */
301
- PROCESS_ROW(0, 1, PW_ONE, PW_TWO, 2)
302
- }
303
- }
304
- }
@@ -1,255 +0,0 @@
1
- /*
2
- * Loongson MMI optimizations for libjpeg-turbo
3
- *
4
- * Copyright (C) 2014, 2018-2019, D. R. Commander. All Rights Reserved.
5
- * Copyright (C) 2016-2018, Loongson Technology Corporation Limited, BeiJing.
6
- * All Rights Reserved.
7
- * Authors: LiuQingfa <liuqingfa-hf@loongson.cn>
8
- *
9
- * Based on the x86 SIMD extension for IJG JPEG library
10
- * Copyright (C) 1999-2006, MIYASAKA Masaru.
11
- *
12
- * This software is provided 'as-is', without any express or implied
13
- * warranty. In no event will the authors be held liable for any damages
14
- * arising from the use of this software.
15
- *
16
- * Permission is granted to anyone to use this software for any purpose,
17
- * including commercial applications, and to alter it and redistribute it
18
- * freely, subject to the following restrictions:
19
- *
20
- * 1. The origin of this software must not be misrepresented; you must not
21
- * claim that you wrote the original software. If you use this software
22
- * in a product, an acknowledgment in the product documentation would be
23
- * appreciated but is not required.
24
- * 2. Altered source versions must be plainly marked as such, and must not be
25
- * misrepresented as being the original software.
26
- * 3. This notice may not be removed or altered from any source distribution.
27
- */
28
-
29
- /* FAST INTEGER FORWARD DCT */
30
-
31
- #include "jsimd_mmi.h"
32
-
33
-
34
- #define CONST_BITS 8
35
-
36
- #define F_0_382 ((short)98) /* FIX(0.382683433) */
37
- #define F_0_541 ((short)139) /* FIX(0.541196100) */
38
- #define F_0_707 ((short)181) /* FIX(0.707106781) */
39
- #define F_1_306 ((short)334) /* FIX(1.306562965) */
40
-
41
- #define PRE_MULTIPLY_SCALE_BITS 2
42
- #define CONST_SHIFT (16 - PRE_MULTIPLY_SCALE_BITS - CONST_BITS)
43
-
44
- enum const_index {
45
- index_PW_F0707,
46
- index_PW_F0382,
47
- index_PW_F0541,
48
- index_PW_F1306
49
- };
50
-
51
- static uint64_t const_value[] = {
52
- _uint64_set1_pi16(F_0_707),
53
- _uint64_set1_pi16(F_0_382),
54
- _uint64_set1_pi16(F_0_541),
55
- _uint64_set1_pi16(F_1_306)
56
- };
57
-
58
- #define PW_F0707 get_const_value(index_PW_F0707)
59
- #define PW_F0382 get_const_value(index_PW_F0382)
60
- #define PW_F0541 get_const_value(index_PW_F0541)
61
- #define PW_F1306 get_const_value(index_PW_F1306)
62
-
63
-
64
- #define DO_FDCT_MULTIPLY(out, in, multiplier) { \
65
- __m64 mulhi, mullo, mul12, mul34; \
66
- \
67
- mullo = _mm_mullo_pi16(in, multiplier); \
68
- mulhi = _mm_mulhi_pi16(in, multiplier); \
69
- mul12 = _mm_unpacklo_pi16(mullo, mulhi); \
70
- mul34 = _mm_unpackhi_pi16(mullo, mulhi); \
71
- mul12 = _mm_srai_pi32(mul12, CONST_BITS); \
72
- mul34 = _mm_srai_pi32(mul34, CONST_BITS); \
73
- out = _mm_packs_pi32(mul12, mul34); \
74
- }
75
-
76
- #define DO_FDCT_COMMON() { \
77
- \
78
- /* Even part */ \
79
- \
80
- tmp10 = _mm_add_pi16(tmp0, tmp3); \
81
- tmp13 = _mm_sub_pi16(tmp0, tmp3); \
82
- tmp11 = _mm_add_pi16(tmp1, tmp2); \
83
- tmp12 = _mm_sub_pi16(tmp1, tmp2); \
84
- \
85
- out0 = _mm_add_pi16(tmp10, tmp11); \
86
- out4 = _mm_sub_pi16(tmp10, tmp11); \
87
- \
88
- z1 = _mm_add_pi16(tmp12, tmp13); \
89
- DO_FDCT_MULTIPLY(z1, z1, PW_F0707) \
90
- \
91
- out2 = _mm_add_pi16(tmp13, z1); \
92
- out6 = _mm_sub_pi16(tmp13, z1); \
93
- \
94
- /* Odd part */ \
95
- \
96
- tmp10 = _mm_add_pi16(tmp4, tmp5); \
97
- tmp11 = _mm_add_pi16(tmp5, tmp6); \
98
- tmp12 = _mm_add_pi16(tmp6, tmp7); \
99
- \
100
- z5 = _mm_sub_pi16(tmp10, tmp12); \
101
- DO_FDCT_MULTIPLY(z5, z5, PW_F0382) \
102
- \
103
- DO_FDCT_MULTIPLY(z2, tmp10, PW_F0541) \
104
- z2 = _mm_add_pi16(z2, z5); \
105
- \
106
- DO_FDCT_MULTIPLY(z4, tmp12, PW_F1306) \
107
- z4 = _mm_add_pi16(z4, z5); \
108
- \
109
- DO_FDCT_MULTIPLY(z3, tmp11, PW_F0707) \
110
- \
111
- z11 = _mm_add_pi16(tmp7, z3); \
112
- z13 = _mm_sub_pi16(tmp7, z3); \
113
- \
114
- out5 = _mm_add_pi16(z13, z2); \
115
- out3 = _mm_sub_pi16(z13, z2); \
116
- out1 = _mm_add_pi16(z11, z4); \
117
- out7 = _mm_sub_pi16(z11, z4); \
118
- }
119
-
120
- #define DO_FDCT_PASS1() { \
121
- __m64 row0l, row0h, row1l, row1h, row2l, row2h, row3l, row3h; \
122
- __m64 row01a, row01b, row01c, row01d, row23a, row23b, row23c, row23d; \
123
- __m64 col0, col1, col2, col3, col4, col5, col6, col7; \
124
- \
125
- row0l = _mm_load_si64((__m64 *)&dataptr[DCTSIZE * 0]); /* (00 01 02 03) */ \
126
- row0h = _mm_load_si64((__m64 *)&dataptr[DCTSIZE * 0 + 4]); /* (04 05 06 07) */ \
127
- row1l = _mm_load_si64((__m64 *)&dataptr[DCTSIZE * 1]); /* (10 11 12 13) */ \
128
- row1h = _mm_load_si64((__m64 *)&dataptr[DCTSIZE * 1 + 4]); /* (14 15 16 17) */ \
129
- row2l = _mm_load_si64((__m64 *)&dataptr[DCTSIZE * 2]); /* (20 21 22 23) */ \
130
- row2h = _mm_load_si64((__m64 *)&dataptr[DCTSIZE * 2 + 4]); /* (24 25 26 27) */ \
131
- row3l = _mm_load_si64((__m64 *)&dataptr[DCTSIZE * 3]); /* (30 31 32 33) */ \
132
- row3h = _mm_load_si64((__m64 *)&dataptr[DCTSIZE * 3 + 4]); /* (34 35 36 37) */ \
133
- \
134
- /* Transpose coefficients */ \
135
- \
136
- row23a = _mm_unpacklo_pi16(row2l, row3l); /* row23a=(20 30 21 31) */ \
137
- row23b = _mm_unpackhi_pi16(row2l, row3l); /* row23b=(22 32 23 33) */ \
138
- row23c = _mm_unpacklo_pi16(row2h, row3h); /* row23c=(24 34 25 35) */ \
139
- row23d = _mm_unpackhi_pi16(row2h, row3h); /* row23d=(26 36 27 37) */ \
140
- \
141
- row01a = _mm_unpacklo_pi16(row0l, row1l); /* row01a=(00 10 01 11) */ \
142
- row01b = _mm_unpackhi_pi16(row0l, row1l); /* row01b=(02 12 03 13) */ \
143
- row01c = _mm_unpacklo_pi16(row0h, row1h); /* row01c=(04 14 05 15) */ \
144
- row01d = _mm_unpackhi_pi16(row0h, row1h); /* row01d=(06 16 07 17) */ \
145
- \
146
- col0 = _mm_unpacklo_pi32(row01a, row23a); /* col0=(00 10 20 30) */ \
147
- col1 = _mm_unpackhi_pi32(row01a, row23a); /* col1=(01 11 21 31) */ \
148
- col6 = _mm_unpacklo_pi32(row01d, row23d); /* col6=(06 16 26 36) */ \
149
- col7 = _mm_unpackhi_pi32(row01d, row23d); /* col7=(07 17 27 37) */ \
150
- \
151
- tmp6 = _mm_sub_pi16(col1, col6); /* tmp6=col1-col6 */ \
152
- tmp7 = _mm_sub_pi16(col0, col7); /* tmp7=col0-col7 */ \
153
- tmp1 = _mm_add_pi16(col1, col6); /* tmp1=col1+col6 */ \
154
- tmp0 = _mm_add_pi16(col0, col7); /* tmp0=col0+col7 */ \
155
- \
156
- col2 = _mm_unpacklo_pi32(row01b, row23b); /* col2=(02 12 22 32) */ \
157
- col3 = _mm_unpackhi_pi32(row01b, row23b); /* col3=(03 13 23 33) */ \
158
- col4 = _mm_unpacklo_pi32(row01c, row23c); /* col4=(04 14 24 34) */ \
159
- col5 = _mm_unpackhi_pi32(row01c, row23c); /* col5=(05 15 25 35) */ \
160
- \
161
- tmp3 = _mm_add_pi16(col3, col4); /* tmp3=col3+col4 */ \
162
- tmp2 = _mm_add_pi16(col2, col5); /* tmp2=col2+col5 */ \
163
- tmp4 = _mm_sub_pi16(col3, col4); /* tmp4=col3-col4 */ \
164
- tmp5 = _mm_sub_pi16(col2, col5); /* tmp5=col2-col5 */ \
165
- \
166
- DO_FDCT_COMMON() \
167
- \
168
- _mm_store_si64((__m64 *)&dataptr[DCTSIZE * 0], out0); \
169
- _mm_store_si64((__m64 *)&dataptr[DCTSIZE * 0 + 4], out4); \
170
- _mm_store_si64((__m64 *)&dataptr[DCTSIZE * 1], out1); \
171
- _mm_store_si64((__m64 *)&dataptr[DCTSIZE * 1 + 4], out5); \
172
- _mm_store_si64((__m64 *)&dataptr[DCTSIZE * 2], out2); \
173
- _mm_store_si64((__m64 *)&dataptr[DCTSIZE * 2 + 4], out6); \
174
- _mm_store_si64((__m64 *)&dataptr[DCTSIZE * 3], out3); \
175
- _mm_store_si64((__m64 *)&dataptr[DCTSIZE * 3 + 4], out7); \
176
- }
177
-
178
- #define DO_FDCT_PASS2() { \
179
- __m64 col0l, col0h, col1l, col1h, col2l, col2h, col3l, col3h; \
180
- __m64 col01a, col01b, col01c, col01d, col23a, col23b, col23c, col23d; \
181
- __m64 row0, row1, row2, row3, row4, row5, row6, row7; \
182
- \
183
- col0l = _mm_load_si64((__m64 *)&dataptr[DCTSIZE * 0]); /* (00 10 20 30) */ \
184
- col1l = _mm_load_si64((__m64 *)&dataptr[DCTSIZE * 1]); /* (01 11 21 31) */ \
185
- col2l = _mm_load_si64((__m64 *)&dataptr[DCTSIZE * 2]); /* (02 12 22 32) */ \
186
- col3l = _mm_load_si64((__m64 *)&dataptr[DCTSIZE * 3]); /* (03 13 23 33) */ \
187
- col0h = _mm_load_si64((__m64 *)&dataptr[DCTSIZE * 4]); /* (40 50 60 70) */ \
188
- col1h = _mm_load_si64((__m64 *)&dataptr[DCTSIZE * 5]); /* (41 51 61 71) */ \
189
- col2h = _mm_load_si64((__m64 *)&dataptr[DCTSIZE * 6]); /* (42 52 62 72) */ \
190
- col3h = _mm_load_si64((__m64 *)&dataptr[DCTSIZE * 7]); /* (43 53 63 73) */ \
191
- \
192
- /* Transpose coefficients */ \
193
- \
194
- col23a = _mm_unpacklo_pi16(col2l, col3l); /* col23a=(02 03 12 13) */ \
195
- col23b = _mm_unpackhi_pi16(col2l, col3l); /* col23b=(22 23 32 33) */ \
196
- col23c = _mm_unpacklo_pi16(col2h, col3h); /* col23c=(42 43 52 53) */ \
197
- col23d = _mm_unpackhi_pi16(col2h, col3h); /* col23d=(62 63 72 73) */ \
198
- \
199
- col01a = _mm_unpacklo_pi16(col0l, col1l); /* col01a=(00 01 10 11) */ \
200
- col01b = _mm_unpackhi_pi16(col0l, col1l); /* col01b=(20 21 30 31) */ \
201
- col01c = _mm_unpacklo_pi16(col0h, col1h); /* col01c=(40 41 50 51) */ \
202
- col01d = _mm_unpackhi_pi16(col0h, col1h); /* col01d=(60 61 70 71) */ \
203
- \
204
- row0 = _mm_unpacklo_pi32(col01a, col23a); /* row0=(00 01 02 03) */ \
205
- row1 = _mm_unpackhi_pi32(col01a, col23a); /* row1=(10 11 12 13) */ \
206
- row6 = _mm_unpacklo_pi32(col01d, col23d); /* row6=(60 61 62 63) */ \
207
- row7 = _mm_unpackhi_pi32(col01d, col23d); /* row7=(70 71 72 73) */ \
208
- \
209
- tmp6 = _mm_sub_pi16(row1, row6); /* tmp6=row1-row6 */ \
210
- tmp7 = _mm_sub_pi16(row0, row7); /* tmp7=row0-row7 */ \
211
- tmp1 = _mm_add_pi16(row1, row6); /* tmp1=row1+row6 */ \
212
- tmp0 = _mm_add_pi16(row0, row7); /* tmp0=row0+row7 */ \
213
- \
214
- row2 = _mm_unpacklo_pi32(col01b, col23b); /* row2=(20 21 22 23) */ \
215
- row3 = _mm_unpackhi_pi32(col01b, col23b); /* row3=(30 31 32 33) */ \
216
- row4 = _mm_unpacklo_pi32(col01c, col23c); /* row4=(40 41 42 43) */ \
217
- row5 = _mm_unpackhi_pi32(col01c, col23c); /* row5=(50 51 52 53) */ \
218
- \
219
- tmp3 = _mm_add_pi16(row3, row4); /* tmp3=row3+row4 */ \
220
- tmp2 = _mm_add_pi16(row2, row5); /* tmp2=row2+row5 */ \
221
- tmp4 = _mm_sub_pi16(row3, row4); /* tmp4=row3-row4 */ \
222
- tmp5 = _mm_sub_pi16(row2, row5); /* tmp5=row2-row5 */ \
223
- \
224
- DO_FDCT_COMMON() \
225
- \
226
- _mm_store_si64((__m64 *)&dataptr[DCTSIZE * 0], out0); \
227
- _mm_store_si64((__m64 *)&dataptr[DCTSIZE * 1], out1); \
228
- _mm_store_si64((__m64 *)&dataptr[DCTSIZE * 2], out2); \
229
- _mm_store_si64((__m64 *)&dataptr[DCTSIZE * 3], out3); \
230
- _mm_store_si64((__m64 *)&dataptr[DCTSIZE * 4], out4); \
231
- _mm_store_si64((__m64 *)&dataptr[DCTSIZE * 5], out5); \
232
- _mm_store_si64((__m64 *)&dataptr[DCTSIZE * 6], out6); \
233
- _mm_store_si64((__m64 *)&dataptr[DCTSIZE * 7], out7); \
234
- }
235
-
236
- void jsimd_fdct_ifast_mmi(DCTELEM *data)
237
- {
238
- __m64 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
239
- __m64 out0, out1, out2, out3, out4, out5, out6, out7;
240
- __m64 tmp10, tmp11, tmp12, tmp13, z1, z2, z3, z4, z5, z11, z13;
241
- DCTELEM *dataptr = data;
242
-
243
- /* Pass 1: process rows. */
244
-
245
- DO_FDCT_PASS1()
246
- dataptr += DCTSIZE * 4;
247
- DO_FDCT_PASS1()
248
-
249
- /* Pass 2: process columns. */
250
-
251
- dataptr = data;
252
- DO_FDCT_PASS2()
253
- dataptr += 4;
254
- DO_FDCT_PASS2()
255
- }