/src/libjpeg-turbo.dev/simd/jsimd.c
Line | Count | Source |
1 | | /* |
2 | | * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB |
3 | | * Copyright (C) 2009-2011, 2013-2014, 2016, 2018, 2020, 2022-2025, |
4 | | * D. R. Commander. |
5 | | * Copyright (C) 2011, Nokia Corporation and/or its subsidiary(-ies). |
6 | | * Copyright (C) 2015-2016, 2018, 2022, Matthieu Darbois. |
7 | | * Copyright (C) 2016-2018, Loongson Technology Corporation Limited, BeiJing. |
8 | | * Copyright (C) 2019, Google LLC. |
9 | | * Copyright (C) 2020, Arm Limited. |
10 | | * |
11 | | * This software is provided 'as-is', without any express or implied |
12 | | * warranty. In no event will the authors be held liable for any damages |
13 | | * arising from the use of this software. |
14 | | * |
15 | | * Permission is granted to anyone to use this software for any purpose, |
16 | | * including commercial applications, and to alter it and redistribute it |
17 | | * freely, subject to the following restrictions: |
18 | | * |
19 | | * 1. The origin of this software must not be misrepresented; you must not |
20 | | * claim that you wrote the original software. If you use this software |
21 | | * in a product, an acknowledgment in the product documentation would be |
22 | | * appreciated but is not required. |
23 | | * 2. Altered source versions must be plainly marked as such, and must not be |
24 | | * misrepresented as being the original software. |
25 | | * 3. This notice may not be removed or altered from any source distribution. |
26 | | * |
27 | | * This file contains the interface between the "normal" portions |
28 | | * of the library and the SIMD implementations. |
29 | | */ |
30 | | |
31 | | #include "jsimddct.h" |
32 | | #include "jsimd.h" |
33 | | #include "jsimdint.h" |
34 | | |
35 | | #if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386 |
36 | | |
37 | | /* |
38 | | * In the PIC cases, we have no guarantee that constants will keep |
39 | | * their alignment. This macro allows us to verify it at runtime. |
40 | | */ |
41 | 0 | #define IS_ALIGNED(ptr, order) (((JUINTPTR)ptr & ((1 << order) - 1)) == 0) |
42 | | |
43 | 0 | #define IS_ALIGNED_SSE(ptr) (IS_ALIGNED(ptr, 4)) /* 16 byte alignment */ |
44 | 0 | #define IS_ALIGNED_AVX(ptr) (IS_ALIGNED(ptr, 5)) /* 32 byte alignment */ |
45 | | |
46 | | #endif |
47 | | |
48 | | |
49 | | /* |
50 | | * Check what SIMD accelerations are supported. |
51 | | */ |
52 | | LOCAL(void) |
53 | | init_simd(j_common_ptr cinfo) |
54 | 0 | { |
55 | 0 | #ifndef NO_GETENV |
56 | 0 | char env[2] = { 0 }; |
57 | 0 | #endif |
58 | 0 | unsigned int simd_support = cinfo->is_decompressor ? |
59 | 0 | ((j_decompress_ptr)cinfo)->master->simd_support : |
60 | 0 | ((j_compress_ptr)cinfo)->master->simd_support; |
61 | 0 | unsigned int simd_huffman = cinfo->is_decompressor ? |
62 | 0 | ((j_decompress_ptr)cinfo)->master->simd_huffman : |
63 | 0 | ((j_compress_ptr)cinfo)->master->simd_huffman; |
64 | |
|
65 | 0 | if (simd_support != JSIMD_UNDEFINED) |
66 | 0 | return; |
67 | | |
68 | 0 | simd_support = jpeg_simd_cpu_support(); |
69 | |
|
70 | 0 | #ifndef NO_GETENV |
71 | | /* Force different settings through environment variables */ |
72 | 0 | #if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386 |
73 | 0 | if (!GETENV_S(env, 2, "JSIMD_FORCESSE2") && !strcmp(env, "1")) |
74 | 0 | simd_support &= JSIMD_SSE2 | JSIMD_SSE; |
75 | | #if SIMD_ARCHITECTURE == I386 |
76 | | if (!GETENV_S(env, 2, "JSIMD_FORCESSE") && !strcmp(env, "1")) |
77 | | simd_support &= JSIMD_SSE | JSIMD_MMX; |
78 | | if (!GETENV_S(env, 2, "JSIMD_FORCEMMX") && !strcmp(env, "1")) |
79 | | simd_support &= JSIMD_MMX; |
80 | | if (!GETENV_S(env, 2, "JSIMD_FORCE3DNOW") && !strcmp(env, "1")) |
81 | | simd_support &= JSIMD_3DNOW | JSIMD_MMX; |
82 | | #endif |
83 | | #elif SIMD_ARCHITECTURE == ARM |
84 | | if (!GETENV_S(env, 2, "JSIMD_FORCENEON") && !strcmp(env, "1")) |
85 | | simd_support = JSIMD_NEON; |
86 | | #elif SIMD_ARCHITECTURE == MIPS64 |
87 | | if (!GETENV_S(env, 2, "JSIMD_FORCEMMI") && !strcmp(env, "1")) |
88 | | simd_support = JSIMD_MMI; |
89 | | #endif |
90 | 0 | if (!GETENV_S(env, 2, "JSIMD_FORCENONE") && !strcmp(env, "1")) |
91 | 0 | simd_support = 0; |
92 | 0 | if (!GETENV_S(env, 2, "JSIMD_NOHUFFENC") && !strcmp(env, "1")) |
93 | 0 | simd_huffman = 0; |
94 | 0 | #endif |
95 | |
|
96 | 0 | if (cinfo->is_decompressor) { |
97 | 0 | ((j_decompress_ptr)cinfo)->master->simd_support = simd_support; |
98 | 0 | ((j_decompress_ptr)cinfo)->master->simd_huffman = simd_huffman; |
99 | 0 | } else { |
100 | 0 | ((j_compress_ptr)cinfo)->master->simd_support = simd_support; |
101 | 0 | ((j_compress_ptr)cinfo)->master->simd_huffman = simd_huffman; |
102 | 0 | } |
103 | 0 | } |
104 | | |
105 | | |
106 | | HIDDEN unsigned int |
107 | | jsimd_set_rgb_ycc(j_compress_ptr cinfo) |
108 | 0 | { |
109 | 0 | init_simd((j_common_ptr)cinfo); |
110 | |
|
111 | 0 | if (BITS_IN_JSAMPLE != 8) |
112 | 0 | return JSIMD_NONE; |
113 | 0 | if (sizeof(JDIMENSION) != 4) |
114 | 0 | return JSIMD_NONE; |
115 | 0 | if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4)) |
116 | 0 | return JSIMD_NONE; |
117 | 0 | if (!cinfo->cconvert) |
118 | 0 | return JSIMD_NONE; |
119 | | |
120 | 0 | #if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386 |
121 | 0 | if ((cinfo->master->simd_support & JSIMD_AVX2) && |
122 | 0 | IS_ALIGNED_AVX(jconst_rgb_ycc_convert_avx2)) { |
123 | 0 | SET_SIMD_EXTRGB_COLOR_CONVERTER(ycc, avx2); |
124 | 0 | return JSIMD_AVX2; |
125 | 0 | } |
126 | 0 | if ((cinfo->master->simd_support & JSIMD_SSE2) && |
127 | 0 | IS_ALIGNED_SSE(jconst_rgb_ycc_convert_sse2)) { |
128 | 0 | SET_SIMD_EXTRGB_COLOR_CONVERTER(ycc, sse2); |
129 | 0 | return JSIMD_SSE2; |
130 | 0 | } |
131 | | #if SIMD_ARCHITECTURE == I386 |
132 | | if (cinfo->master->simd_support & JSIMD_MMX) { |
133 | | SET_SIMD_EXTRGB_COLOR_CONVERTER(ycc, mmx); |
134 | | return JSIMD_MMX; |
135 | | } |
136 | | #endif |
137 | | #elif SIMD_ARCHITECTURE == ARM64 || SIMD_ARCHITECTURE == ARM |
138 | | if (cinfo->master->simd_support & JSIMD_NEON) { |
139 | | SET_SIMD_EXTRGB_COLOR_CONVERTER(ycc, neon); |
140 | | return JSIMD_NEON; |
141 | | } |
142 | | #elif SIMD_ARCHITECTURE == POWERPC |
143 | | if (cinfo->master->simd_support & JSIMD_ALTIVEC) { |
144 | | SET_SIMD_EXTRGB_COLOR_CONVERTER(ycc, altivec); |
145 | | return JSIMD_ALTIVEC; |
146 | | } |
147 | | #elif SIMD_ARCHITECTURE == MIPS64 |
148 | | if (cinfo->master->simd_support & JSIMD_MMI) { |
149 | | SET_SIMD_EXTRGB_COLOR_CONVERTER(ycc, mmi); |
150 | | return JSIMD_MMI; |
151 | | } |
152 | | #endif |
153 | | |
154 | 0 | return JSIMD_NONE; |
155 | 0 | } |
156 | | |
157 | | |
158 | | HIDDEN unsigned int |
159 | | jsimd_set_rgb_gray(j_compress_ptr cinfo) |
160 | 0 | { |
161 | 0 | init_simd((j_common_ptr)cinfo); |
162 | |
|
163 | 0 | if (BITS_IN_JSAMPLE != 8) |
164 | 0 | return JSIMD_NONE; |
165 | 0 | if (sizeof(JDIMENSION) != 4) |
166 | 0 | return JSIMD_NONE; |
167 | 0 | if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4)) |
168 | 0 | return JSIMD_NONE; |
169 | 0 | if (!cinfo->cconvert) |
170 | 0 | return JSIMD_NONE; |
171 | | |
172 | 0 | #if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386 |
173 | 0 | if ((cinfo->master->simd_support & JSIMD_AVX2) && |
174 | 0 | IS_ALIGNED_AVX(jconst_rgb_gray_convert_avx2)) { |
175 | 0 | SET_SIMD_EXTRGB_COLOR_CONVERTER(gray, avx2); |
176 | 0 | return JSIMD_AVX2; |
177 | 0 | } |
178 | 0 | if ((cinfo->master->simd_support & JSIMD_SSE2) && |
179 | 0 | IS_ALIGNED_SSE(jconst_rgb_gray_convert_sse2)) { |
180 | 0 | SET_SIMD_EXTRGB_COLOR_CONVERTER(gray, sse2); |
181 | 0 | return JSIMD_SSE2; |
182 | 0 | } |
183 | | #if SIMD_ARCHITECTURE == I386 |
184 | | if (cinfo->master->simd_support & JSIMD_MMX) { |
185 | | SET_SIMD_EXTRGB_COLOR_CONVERTER(gray, mmx); |
186 | | return JSIMD_MMX; |
187 | | } |
188 | | #endif |
189 | | #elif SIMD_ARCHITECTURE == ARM64 || SIMD_ARCHITECTURE == ARM |
190 | | if (cinfo->master->simd_support & JSIMD_NEON) { |
191 | | SET_SIMD_EXTRGB_COLOR_CONVERTER(gray, neon); |
192 | | return JSIMD_NEON; |
193 | | } |
194 | | #elif SIMD_ARCHITECTURE == POWERPC |
195 | | if (cinfo->master->simd_support & JSIMD_ALTIVEC) { |
196 | | SET_SIMD_EXTRGB_COLOR_CONVERTER(gray, altivec); |
197 | | return JSIMD_ALTIVEC; |
198 | | } |
199 | | #elif SIMD_ARCHITECTURE == MIPS64 |
200 | | if (cinfo->master->simd_support & JSIMD_MMI) { |
201 | | SET_SIMD_EXTRGB_COLOR_CONVERTER(gray, mmi); |
202 | | return JSIMD_MMI; |
203 | | } |
204 | | #endif |
205 | | |
206 | 0 | return JSIMD_NONE; |
207 | 0 | } |
208 | | |
209 | | |
210 | | HIDDEN void |
211 | | jsimd_color_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf, |
212 | | JSAMPIMAGE output_buf, JDIMENSION output_row, int num_rows) |
213 | 0 | { |
214 | 0 | cinfo->cconvert->color_convert_simd(cinfo->image_width, input_buf, |
215 | 0 | output_buf, output_row, num_rows); |
216 | 0 | } |
217 | | |
218 | | |
219 | | HIDDEN unsigned int |
220 | | jsimd_set_ycc_rgb(j_decompress_ptr cinfo) |
221 | 0 | { |
222 | 0 | init_simd((j_common_ptr)cinfo); |
223 | |
|
224 | 0 | if (BITS_IN_JSAMPLE != 8) |
225 | 0 | return JSIMD_NONE; |
226 | 0 | if (sizeof(JDIMENSION) != 4) |
227 | 0 | return JSIMD_NONE; |
228 | 0 | if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4)) |
229 | 0 | return JSIMD_NONE; |
230 | 0 | if (!cinfo->cconvert) |
231 | 0 | return JSIMD_NONE; |
232 | | |
233 | 0 | #if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386 |
234 | 0 | if ((cinfo->master->simd_support & JSIMD_AVX2) && |
235 | 0 | IS_ALIGNED_AVX(jconst_ycc_rgb_convert_avx2)) { |
236 | 0 | SET_SIMD_EXTRGB_COLOR_DECONVERTER(avx2); |
237 | 0 | return JSIMD_AVX2; |
238 | 0 | } |
239 | 0 | if ((cinfo->master->simd_support & JSIMD_SSE2) && |
240 | 0 | IS_ALIGNED_SSE(jconst_ycc_rgb_convert_sse2)) { |
241 | 0 | SET_SIMD_EXTRGB_COLOR_DECONVERTER(sse2); |
242 | 0 | return JSIMD_SSE2; |
243 | 0 | } |
244 | | #if SIMD_ARCHITECTURE == I386 |
245 | | if (cinfo->master->simd_support & JSIMD_MMX) { |
246 | | SET_SIMD_EXTRGB_COLOR_DECONVERTER(mmx); |
247 | | return JSIMD_MMX; |
248 | | } |
249 | | #endif |
250 | | #elif SIMD_ARCHITECTURE == ARM64 || SIMD_ARCHITECTURE == ARM |
251 | | if (cinfo->master->simd_support & JSIMD_NEON) { |
252 | | SET_SIMD_EXTRGB_COLOR_DECONVERTER(neon); |
253 | | return JSIMD_NEON; |
254 | | } |
255 | | #elif SIMD_ARCHITECTURE == POWERPC |
256 | | if (cinfo->master->simd_support & JSIMD_ALTIVEC) { |
257 | | SET_SIMD_EXTRGB_COLOR_DECONVERTER(altivec); |
258 | | return JSIMD_ALTIVEC; |
259 | | } |
260 | | #elif SIMD_ARCHITECTURE == MIPS64 |
261 | | if (cinfo->master->simd_support & JSIMD_MMI) { |
262 | | SET_SIMD_EXTRGB_COLOR_DECONVERTER(mmi); |
263 | | return JSIMD_MMI; |
264 | | } |
265 | | #endif |
266 | | |
267 | 0 | return JSIMD_NONE; |
268 | 0 | } |
269 | | |
270 | | |
271 | | HIDDEN unsigned int |
272 | | jsimd_set_ycc_rgb565(j_decompress_ptr cinfo) |
273 | 0 | { |
274 | | #if SIMD_ARCHITECTURE == ARM64 || SIMD_ARCHITECTURE == ARM |
275 | | init_simd((j_common_ptr)cinfo); |
276 | | |
277 | | if (BITS_IN_JSAMPLE != 8) |
278 | | return JSIMD_NONE; |
279 | | if (sizeof(JDIMENSION) != 4) |
280 | | return JSIMD_NONE; |
281 | | if (!cinfo->cconvert) |
282 | | return JSIMD_NONE; |
283 | | |
284 | | if (cinfo->master->simd_support & JSIMD_NEON) { |
285 | | cinfo->cconvert->color_convert_simd = jsimd_ycc_rgb565_convert_neon; |
286 | | return JSIMD_NEON; |
287 | | } |
288 | | #endif |
289 | |
|
290 | 0 | return JSIMD_NONE; |
291 | 0 | } |
292 | | |
293 | | |
294 | | HIDDEN void |
295 | | jsimd_color_deconvert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf, |
296 | | JDIMENSION input_row, JSAMPARRAY output_buf, |
297 | | int num_rows) |
298 | 0 | { |
299 | 0 | cinfo->cconvert->color_convert_simd(cinfo->output_width, input_buf, |
300 | 0 | input_row, output_buf, num_rows); |
301 | 0 | } |
302 | | |
303 | | |
304 | | HIDDEN unsigned int |
305 | | jsimd_set_h2v1_downsample(j_compress_ptr cinfo) |
306 | 0 | { |
307 | 0 | init_simd((j_common_ptr)cinfo); |
308 | |
|
309 | 0 | if (BITS_IN_JSAMPLE != 8) |
310 | 0 | return JSIMD_NONE; |
311 | 0 | if (sizeof(JDIMENSION) != 4) |
312 | 0 | return JSIMD_NONE; |
313 | 0 | if (!cinfo->downsample) |
314 | 0 | return JSIMD_NONE; |
315 | | |
316 | 0 | #if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386 |
317 | 0 | if (cinfo->master->simd_support & JSIMD_AVX2) { |
318 | 0 | cinfo->downsample->h2v1_downsample_simd = jsimd_h2v1_downsample_avx2; |
319 | 0 | return JSIMD_AVX2; |
320 | 0 | } |
321 | 0 | if (cinfo->master->simd_support & JSIMD_SSE2) { |
322 | 0 | cinfo->downsample->h2v1_downsample_simd = jsimd_h2v1_downsample_sse2; |
323 | 0 | return JSIMD_SSE2; |
324 | 0 | } |
325 | | #if SIMD_ARCHITECTURE == I386 |
326 | | if (cinfo->master->simd_support & JSIMD_MMX) { |
327 | | cinfo->downsample->h2v1_downsample_simd = jsimd_h2v1_downsample_mmx; |
328 | | return JSIMD_MMX; |
329 | | } |
330 | | #endif |
331 | | #elif SIMD_ARCHITECTURE == ARM64 || SIMD_ARCHITECTURE == ARM |
332 | | if (cinfo->master->simd_support & JSIMD_NEON) { |
333 | | cinfo->downsample->h2v1_downsample_simd = jsimd_h2v1_downsample_neon; |
334 | | return JSIMD_NEON; |
335 | | } |
336 | | #elif SIMD_ARCHITECTURE == POWERPC |
337 | | if (cinfo->master->simd_support & JSIMD_ALTIVEC) { |
338 | | cinfo->downsample->h2v1_downsample_simd = jsimd_h2v1_downsample_altivec; |
339 | | return JSIMD_ALTIVEC; |
340 | | } |
341 | | #endif |
342 | | |
343 | 0 | return JSIMD_NONE; |
344 | 0 | } |
345 | | |
346 | | |
347 | | HIDDEN void |
348 | | jsimd_h2v1_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr, |
349 | | JSAMPARRAY input_data, JSAMPARRAY output_data) |
350 | 0 | { |
351 | 0 | cinfo->downsample->h2v1_downsample_simd(cinfo->image_width, |
352 | 0 | cinfo->max_v_samp_factor, |
353 | 0 | compptr->v_samp_factor, |
354 | 0 | compptr->width_in_blocks, input_data, |
355 | 0 | output_data); |
356 | 0 | } |
357 | | |
358 | | |
359 | | HIDDEN unsigned int |
360 | | jsimd_set_h2v2_downsample(j_compress_ptr cinfo) |
361 | 0 | { |
362 | 0 | init_simd((j_common_ptr)cinfo); |
363 | |
|
364 | 0 | if (BITS_IN_JSAMPLE != 8) |
365 | 0 | return JSIMD_NONE; |
366 | 0 | if (sizeof(JDIMENSION) != 4) |
367 | 0 | return JSIMD_NONE; |
368 | 0 | if (!cinfo->downsample) |
369 | 0 | return JSIMD_NONE; |
370 | | |
371 | 0 | #if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386 |
372 | 0 | if (cinfo->master->simd_support & JSIMD_AVX2) { |
373 | 0 | cinfo->downsample->h2v2_downsample_simd = jsimd_h2v2_downsample_avx2; |
374 | 0 | return JSIMD_AVX2; |
375 | 0 | } |
376 | 0 | if (cinfo->master->simd_support & JSIMD_SSE2) { |
377 | 0 | cinfo->downsample->h2v2_downsample_simd = jsimd_h2v2_downsample_sse2; |
378 | 0 | return JSIMD_SSE2; |
379 | 0 | } |
380 | | #if SIMD_ARCHITECTURE == I386 |
381 | | if (cinfo->master->simd_support & JSIMD_MMX) { |
382 | | cinfo->downsample->h2v2_downsample_simd = jsimd_h2v2_downsample_mmx; |
383 | | return JSIMD_MMX; |
384 | | } |
385 | | #endif |
386 | | #elif SIMD_ARCHITECTURE == ARM64 || SIMD_ARCHITECTURE == ARM |
387 | | if (cinfo->master->simd_support & JSIMD_NEON) { |
388 | | cinfo->downsample->h2v2_downsample_simd = jsimd_h2v2_downsample_neon; |
389 | | return JSIMD_NEON; |
390 | | } |
391 | | #elif SIMD_ARCHITECTURE == POWERPC |
392 | | if (cinfo->master->simd_support & JSIMD_ALTIVEC) { |
393 | | cinfo->downsample->h2v2_downsample_simd = jsimd_h2v2_downsample_altivec; |
394 | | return JSIMD_ALTIVEC; |
395 | | } |
396 | | #elif SIMD_ARCHITECTURE == MIPS64 |
397 | | if (cinfo->master->simd_support & JSIMD_MMI) { |
398 | | cinfo->downsample->h2v2_downsample_simd = jsimd_h2v2_downsample_mmi; |
399 | | return JSIMD_MMI; |
400 | | } |
401 | | #endif |
402 | | |
403 | 0 | return JSIMD_NONE; |
404 | 0 | } |
405 | | |
406 | | |
407 | | HIDDEN void |
408 | | jsimd_h2v2_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr, |
409 | | JSAMPARRAY input_data, JSAMPARRAY output_data) |
410 | 0 | { |
411 | 0 | cinfo->downsample->h2v2_downsample_simd(cinfo->image_width, |
412 | 0 | cinfo->max_v_samp_factor, |
413 | 0 | compptr->v_samp_factor, |
414 | 0 | compptr->width_in_blocks, input_data, |
415 | 0 | output_data); |
416 | 0 | } |
417 | | |
418 | | |
419 | | HIDDEN unsigned int |
420 | | jsimd_set_h2v1_upsample(j_decompress_ptr cinfo) |
421 | 0 | { |
422 | 0 | init_simd((j_common_ptr)cinfo); |
423 | |
|
424 | 0 | if (BITS_IN_JSAMPLE != 8) |
425 | 0 | return JSIMD_NONE; |
426 | 0 | if (sizeof(JDIMENSION) != 4) |
427 | 0 | return JSIMD_NONE; |
428 | 0 | if (!cinfo->upsample) |
429 | 0 | return JSIMD_NONE; |
430 | | |
431 | 0 | #if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386 |
432 | 0 | if (cinfo->master->simd_support & JSIMD_AVX2) { |
433 | 0 | cinfo->upsample->h2v1_upsample_simd = jsimd_h2v1_upsample_avx2; |
434 | 0 | return JSIMD_AVX2; |
435 | 0 | } |
436 | 0 | if (cinfo->master->simd_support & JSIMD_SSE2) { |
437 | 0 | cinfo->upsample->h2v1_upsample_simd = jsimd_h2v1_upsample_sse2; |
438 | 0 | return JSIMD_SSE2; |
439 | 0 | } |
440 | | #if SIMD_ARCHITECTURE == I386 |
441 | | if (cinfo->master->simd_support & JSIMD_MMX) { |
442 | | cinfo->upsample->h2v1_upsample_simd = jsimd_h2v1_upsample_mmx; |
443 | | return JSIMD_MMX; |
444 | | } |
445 | | #endif |
446 | | #elif SIMD_ARCHITECTURE == ARM64 || SIMD_ARCHITECTURE == ARM |
447 | | if (cinfo->master->simd_support & JSIMD_NEON) { |
448 | | cinfo->upsample->h2v1_upsample_simd = jsimd_h2v1_upsample_neon; |
449 | | return JSIMD_NEON; |
450 | | } |
451 | | #elif SIMD_ARCHITECTURE == POWERPC |
452 | | if (cinfo->master->simd_support & JSIMD_ALTIVEC) { |
453 | | cinfo->upsample->h2v1_upsample_simd = jsimd_h2v1_upsample_altivec; |
454 | | return JSIMD_ALTIVEC; |
455 | | } |
456 | | #endif |
457 | | |
458 | 0 | return JSIMD_NONE; |
459 | 0 | } |
460 | | |
461 | | |
462 | | HIDDEN void |
463 | | jsimd_h2v1_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr, |
464 | | JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr) |
465 | 0 | { |
466 | 0 | cinfo->upsample->h2v1_upsample_simd(cinfo->max_v_samp_factor, |
467 | 0 | cinfo->output_width, input_data, |
468 | 0 | output_data_ptr); |
469 | 0 | } |
470 | | |
471 | | |
472 | | HIDDEN unsigned int |
473 | | jsimd_set_h2v2_upsample(j_decompress_ptr cinfo) |
474 | 0 | { |
475 | 0 | init_simd((j_common_ptr)cinfo); |
476 | |
|
477 | 0 | if (BITS_IN_JSAMPLE != 8) |
478 | 0 | return JSIMD_NONE; |
479 | 0 | if (sizeof(JDIMENSION) != 4) |
480 | 0 | return JSIMD_NONE; |
481 | 0 | if (!cinfo->upsample) |
482 | 0 | return JSIMD_NONE; |
483 | | |
484 | 0 | #if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386 |
485 | 0 | if (cinfo->master->simd_support & JSIMD_AVX2) { |
486 | 0 | cinfo->upsample->h2v2_upsample_simd = jsimd_h2v2_upsample_avx2; |
487 | 0 | return JSIMD_AVX2; |
488 | 0 | } |
489 | 0 | if (cinfo->master->simd_support & JSIMD_SSE2) { |
490 | 0 | cinfo->upsample->h2v2_upsample_simd = jsimd_h2v2_upsample_sse2; |
491 | 0 | return JSIMD_SSE2; |
492 | 0 | } |
493 | | #if SIMD_ARCHITECTURE == I386 |
494 | | if (cinfo->master->simd_support & JSIMD_MMX) { |
495 | | cinfo->upsample->h2v2_upsample_simd = jsimd_h2v2_upsample_mmx; |
496 | | return JSIMD_MMX; |
497 | | } |
498 | | #endif |
499 | | #elif SIMD_ARCHITECTURE == ARM64 || SIMD_ARCHITECTURE == ARM |
500 | | if (cinfo->master->simd_support & JSIMD_NEON) { |
501 | | cinfo->upsample->h2v2_upsample_simd = jsimd_h2v2_upsample_neon; |
502 | | return JSIMD_NEON; |
503 | | } |
504 | | #elif SIMD_ARCHITECTURE == POWERPC |
505 | | if (cinfo->master->simd_support & JSIMD_ALTIVEC) { |
506 | | cinfo->upsample->h2v2_upsample_simd = jsimd_h2v2_upsample_altivec; |
507 | | return JSIMD_ALTIVEC; |
508 | | } |
509 | | #endif |
510 | | |
511 | 0 | return JSIMD_NONE; |
512 | 0 | } |
513 | | |
514 | | |
515 | | HIDDEN void |
516 | | jsimd_h2v2_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr, |
517 | | JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr) |
518 | 0 | { |
519 | 0 | cinfo->upsample->h2v2_upsample_simd(cinfo->max_v_samp_factor, |
520 | 0 | cinfo->output_width, input_data, |
521 | 0 | output_data_ptr); |
522 | 0 | } |
523 | | |
524 | | |
525 | | HIDDEN unsigned int |
526 | | jsimd_set_h2v1_fancy_upsample(j_decompress_ptr cinfo) |
527 | 0 | { |
528 | 0 | init_simd((j_common_ptr)cinfo); |
529 | |
|
530 | 0 | if (BITS_IN_JSAMPLE != 8) |
531 | 0 | return JSIMD_NONE; |
532 | 0 | if (sizeof(JDIMENSION) != 4) |
533 | 0 | return JSIMD_NONE; |
534 | 0 | if (!cinfo->upsample) |
535 | 0 | return JSIMD_NONE; |
536 | | |
537 | 0 | #if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386 |
538 | 0 | if ((cinfo->master->simd_support & JSIMD_AVX2) && |
539 | 0 | IS_ALIGNED_AVX(jconst_fancy_upsample_avx2)) { |
540 | 0 | cinfo->upsample->h2v1_upsample_simd = jsimd_h2v1_fancy_upsample_avx2; |
541 | 0 | return JSIMD_AVX2; |
542 | 0 | } |
543 | 0 | if ((cinfo->master->simd_support & JSIMD_SSE2) && |
544 | 0 | IS_ALIGNED_SSE(jconst_fancy_upsample_sse2)) { |
545 | 0 | cinfo->upsample->h2v1_upsample_simd = jsimd_h2v1_fancy_upsample_sse2; |
546 | 0 | return JSIMD_SSE2; |
547 | 0 | } |
548 | | #if SIMD_ARCHITECTURE == I386 |
549 | | if (cinfo->master->simd_support & JSIMD_MMX) { |
550 | | cinfo->upsample->h2v1_upsample_simd = jsimd_h2v1_fancy_upsample_mmx; |
551 | | return JSIMD_MMX; |
552 | | } |
553 | | #endif |
554 | | #elif SIMD_ARCHITECTURE == ARM64 || SIMD_ARCHITECTURE == ARM |
555 | | if (cinfo->master->simd_support & JSIMD_NEON) { |
556 | | cinfo->upsample->h2v1_upsample_simd = jsimd_h2v1_fancy_upsample_neon; |
557 | | return JSIMD_NEON; |
558 | | } |
559 | | #elif SIMD_ARCHITECTURE == POWERPC |
560 | | if (cinfo->master->simd_support & JSIMD_ALTIVEC) { |
561 | | cinfo->upsample->h2v1_upsample_simd = jsimd_h2v1_fancy_upsample_altivec; |
562 | | return JSIMD_ALTIVEC; |
563 | | } |
564 | | #elif SIMD_ARCHITECTURE == MIPS64 |
565 | | if (cinfo->master->simd_support & JSIMD_MMI) { |
566 | | cinfo->upsample->h2v1_upsample_simd = jsimd_h2v1_fancy_upsample_mmi; |
567 | | return JSIMD_MMI; |
568 | | } |
569 | | #endif |
570 | | |
571 | 0 | return JSIMD_NONE; |
572 | 0 | } |
573 | | |
574 | | |
575 | | HIDDEN void |
576 | | jsimd_h2v1_fancy_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr, |
577 | | JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr) |
578 | 0 | { |
579 | 0 | cinfo->upsample->h2v1_upsample_simd(cinfo->max_v_samp_factor, |
580 | 0 | compptr->downsampled_width, input_data, |
581 | 0 | output_data_ptr); |
582 | 0 | } |
583 | | |
584 | | |
585 | | HIDDEN unsigned int |
586 | | jsimd_set_h2v2_fancy_upsample(j_decompress_ptr cinfo) |
587 | 0 | { |
588 | 0 | init_simd((j_common_ptr)cinfo); |
589 | |
|
590 | 0 | if (BITS_IN_JSAMPLE != 8) |
591 | 0 | return JSIMD_NONE; |
592 | 0 | if (sizeof(JDIMENSION) != 4) |
593 | 0 | return JSIMD_NONE; |
594 | 0 | if (!cinfo->upsample) |
595 | 0 | return JSIMD_NONE; |
596 | | |
597 | 0 | #if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386 |
598 | 0 | if ((cinfo->master->simd_support & JSIMD_AVX2) && |
599 | 0 | IS_ALIGNED_AVX(jconst_fancy_upsample_avx2)) { |
600 | 0 | cinfo->upsample->h2v2_upsample_simd = jsimd_h2v2_fancy_upsample_avx2; |
601 | 0 | return JSIMD_AVX2; |
602 | 0 | } |
603 | 0 | if ((cinfo->master->simd_support & JSIMD_SSE2) && |
604 | 0 | IS_ALIGNED_SSE(jconst_fancy_upsample_sse2)) { |
605 | 0 | cinfo->upsample->h2v2_upsample_simd = jsimd_h2v2_fancy_upsample_sse2; |
606 | 0 | return JSIMD_SSE2; |
607 | 0 | } |
608 | | #if SIMD_ARCHITECTURE == I386 |
609 | | if (cinfo->master->simd_support & JSIMD_MMX) { |
610 | | cinfo->upsample->h2v2_upsample_simd = jsimd_h2v2_fancy_upsample_mmx; |
611 | | return JSIMD_MMX; |
612 | | } |
613 | | #endif |
614 | | #elif SIMD_ARCHITECTURE == ARM64 || SIMD_ARCHITECTURE == ARM |
615 | | if (cinfo->master->simd_support & JSIMD_NEON) { |
616 | | cinfo->upsample->h2v2_upsample_simd = jsimd_h2v2_fancy_upsample_neon; |
617 | | return JSIMD_NEON; |
618 | | } |
619 | | #elif SIMD_ARCHITECTURE == POWERPC |
620 | | if (cinfo->master->simd_support & JSIMD_ALTIVEC) { |
621 | | cinfo->upsample->h2v2_upsample_simd = jsimd_h2v2_fancy_upsample_altivec; |
622 | | return JSIMD_ALTIVEC; |
623 | | } |
624 | | #elif SIMD_ARCHITECTURE == MIPS64 |
625 | | if (cinfo->master->simd_support & JSIMD_MMI) { |
626 | | cinfo->upsample->h2v2_upsample_simd = jsimd_h2v2_fancy_upsample_mmi; |
627 | | return JSIMD_MMI; |
628 | | } |
629 | | #endif |
630 | | |
631 | 0 | return JSIMD_NONE; |
632 | 0 | } |
633 | | |
634 | | |
635 | | HIDDEN void |
636 | | jsimd_h2v2_fancy_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr, |
637 | | JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr) |
638 | 0 | { |
639 | 0 | cinfo->upsample->h2v2_upsample_simd(cinfo->max_v_samp_factor, |
640 | 0 | compptr->downsampled_width, input_data, |
641 | 0 | output_data_ptr); |
642 | 0 | } |
643 | | |
644 | | |
645 | | #if SIMD_ARCHITECTURE == ARM64 || SIMD_ARCHITECTURE == ARM |
646 | | |
647 | | HIDDEN unsigned int |
648 | | jsimd_set_h1v2_fancy_upsample(j_decompress_ptr cinfo) |
649 | | { |
650 | | init_simd((j_common_ptr)cinfo); |
651 | | |
652 | | if (BITS_IN_JSAMPLE != 8) |
653 | | return JSIMD_NONE; |
654 | | if (sizeof(JDIMENSION) != 4) |
655 | | return JSIMD_NONE; |
656 | | if (!cinfo->upsample) |
657 | | return JSIMD_NONE; |
658 | | |
659 | | if (cinfo->master->simd_support & JSIMD_NEON) { |
660 | | cinfo->upsample->h1v2_upsample_simd = jsimd_h1v2_fancy_upsample_neon; |
661 | | return JSIMD_NEON; |
662 | | } |
663 | | |
664 | | return JSIMD_NONE; |
665 | | } |
666 | | |
667 | | |
668 | | HIDDEN void |
669 | | jsimd_h1v2_fancy_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr, |
670 | | JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr) |
671 | | { |
672 | | cinfo->upsample->h1v2_upsample_simd(cinfo->max_v_samp_factor, |
673 | | compptr->downsampled_width, input_data, |
674 | | output_data_ptr); |
675 | | } |
676 | | |
677 | | #endif |
678 | | |
679 | | |
680 | | HIDDEN unsigned int |
681 | | jsimd_set_h2v1_merged_upsample(j_decompress_ptr cinfo) |
682 | 0 | { |
683 | 0 | init_simd((j_common_ptr)cinfo); |
684 | |
|
685 | 0 | if (BITS_IN_JSAMPLE != 8) |
686 | 0 | return JSIMD_NONE; |
687 | 0 | if (sizeof(JDIMENSION) != 4) |
688 | 0 | return JSIMD_NONE; |
689 | 0 | if (!cinfo->upsample) |
690 | 0 | return JSIMD_NONE; |
691 | | |
692 | 0 | #if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386 |
693 | 0 | if ((cinfo->master->simd_support & JSIMD_AVX2) && |
694 | 0 | IS_ALIGNED_AVX(jconst_merged_upsample_avx2)) { |
695 | 0 | SET_SIMD_EXTRGB_MERGED_UPSAMPLER(h2v1, avx2); |
696 | 0 | return JSIMD_AVX2; |
697 | 0 | } |
698 | 0 | if ((cinfo->master->simd_support & JSIMD_SSE2) && |
699 | 0 | IS_ALIGNED_SSE(jconst_merged_upsample_sse2)) { |
700 | 0 | SET_SIMD_EXTRGB_MERGED_UPSAMPLER(h2v1, sse2); |
701 | 0 | return JSIMD_SSE2; |
702 | 0 | } |
703 | | #if SIMD_ARCHITECTURE == I386 |
704 | | if (cinfo->master->simd_support & JSIMD_MMX) { |
705 | | SET_SIMD_EXTRGB_MERGED_UPSAMPLER(h2v1, mmx); |
706 | | return JSIMD_MMX; |
707 | | } |
708 | | #endif |
709 | | #elif SIMD_ARCHITECTURE == ARM64 || SIMD_ARCHITECTURE == ARM |
710 | | if (cinfo->master->simd_support & JSIMD_NEON) { |
711 | | SET_SIMD_EXTRGB_MERGED_UPSAMPLER(h2v1, neon); |
712 | | return JSIMD_NEON; |
713 | | } |
714 | | #elif SIMD_ARCHITECTURE == POWERPC |
715 | | if (cinfo->master->simd_support & JSIMD_ALTIVEC) { |
716 | | SET_SIMD_EXTRGB_MERGED_UPSAMPLER(h2v1, altivec); |
717 | | return JSIMD_ALTIVEC; |
718 | | } |
719 | | #elif SIMD_ARCHITECTURE == MIPS64 |
720 | | if (cinfo->master->simd_support & JSIMD_MMI) { |
721 | | SET_SIMD_EXTRGB_MERGED_UPSAMPLER(h2v1, mmi); |
722 | | return JSIMD_MMI; |
723 | | } |
724 | | #endif |
725 | | |
726 | 0 | return JSIMD_NONE; |
727 | 0 | } |
728 | | |
729 | | |
730 | | HIDDEN void |
731 | | jsimd_h2v1_merged_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf, |
732 | | JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf) |
733 | 0 | { |
734 | 0 | cinfo->upsample->merged_upsample_simd(cinfo->output_width, input_buf, |
735 | 0 | in_row_group_ctr, output_buf); |
736 | 0 | } |
737 | | |
738 | | |
739 | | HIDDEN unsigned int |
740 | | jsimd_set_h2v2_merged_upsample(j_decompress_ptr cinfo) |
741 | 0 | { |
742 | 0 | init_simd((j_common_ptr)cinfo); |
743 | |
|
744 | 0 | if (BITS_IN_JSAMPLE != 8) |
745 | 0 | return JSIMD_NONE; |
746 | 0 | if (sizeof(JDIMENSION) != 4) |
747 | 0 | return JSIMD_NONE; |
748 | 0 | if (!cinfo->upsample) |
749 | 0 | return JSIMD_NONE; |
750 | | |
751 | 0 | #if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386 |
752 | 0 | if ((cinfo->master->simd_support & JSIMD_AVX2) && |
753 | 0 | IS_ALIGNED_AVX(jconst_merged_upsample_avx2)) { |
754 | 0 | SET_SIMD_EXTRGB_MERGED_UPSAMPLER(h2v2, avx2); |
755 | 0 | return JSIMD_AVX2; |
756 | 0 | } |
757 | 0 | if ((cinfo->master->simd_support & JSIMD_SSE2) && |
758 | 0 | IS_ALIGNED_SSE(jconst_merged_upsample_sse2)) { |
759 | 0 | SET_SIMD_EXTRGB_MERGED_UPSAMPLER(h2v2, sse2); |
760 | 0 | return JSIMD_SSE2; |
761 | 0 | } |
762 | | #if SIMD_ARCHITECTURE == I386 |
763 | | if (cinfo->master->simd_support & JSIMD_MMX) { |
764 | | SET_SIMD_EXTRGB_MERGED_UPSAMPLER(h2v2, mmx); |
765 | | return JSIMD_MMX; |
766 | | } |
767 | | #endif |
768 | | #elif SIMD_ARCHITECTURE == ARM64 || SIMD_ARCHITECTURE == ARM |
769 | | if (cinfo->master->simd_support & JSIMD_NEON) { |
770 | | SET_SIMD_EXTRGB_MERGED_UPSAMPLER(h2v2, neon); |
771 | | return JSIMD_NEON; |
772 | | } |
773 | | #elif SIMD_ARCHITECTURE == POWERPC |
774 | | if (cinfo->master->simd_support & JSIMD_ALTIVEC) { |
775 | | SET_SIMD_EXTRGB_MERGED_UPSAMPLER(h2v2, altivec); |
776 | | return JSIMD_ALTIVEC; |
777 | | } |
778 | | #elif SIMD_ARCHITECTURE == MIPS64 |
779 | | if (cinfo->master->simd_support & JSIMD_MMI) { |
780 | | SET_SIMD_EXTRGB_MERGED_UPSAMPLER(h2v2, mmi); |
781 | | return JSIMD_MMI; |
782 | | } |
783 | | #endif |
784 | | |
785 | 0 | return JSIMD_NONE; |
786 | 0 | } |
787 | | |
788 | | |
789 | | HIDDEN void |
790 | | jsimd_h2v2_merged_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf, |
791 | | JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf) |
792 | 0 | { |
793 | 0 | cinfo->upsample->merged_upsample_simd(cinfo->output_width, input_buf, |
794 | 0 | in_row_group_ctr, output_buf); |
795 | 0 | } |
796 | | |
797 | | |
798 | | HIDDEN unsigned int |
799 | | jsimd_set_convsamp(j_compress_ptr cinfo, convsamp_method_ptr *method) |
800 | 0 | { |
801 | 0 | init_simd((j_common_ptr)cinfo); |
802 | |
|
803 | 0 | if (BITS_IN_JSAMPLE != 8) |
804 | 0 | return JSIMD_NONE; |
805 | 0 | if (sizeof(JDIMENSION) != 4) |
806 | 0 | return JSIMD_NONE; |
807 | 0 | if (sizeof(DCTELEM) != 2) |
808 | 0 | return JSIMD_NONE; |
809 | | |
810 | 0 | #if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386 |
811 | 0 | if (cinfo->master->simd_support & JSIMD_AVX2) { |
812 | 0 | *method = jsimd_convsamp_avx2; |
813 | 0 | return JSIMD_AVX2; |
814 | 0 | } |
815 | 0 | if (cinfo->master->simd_support & JSIMD_SSE2) { |
816 | 0 | *method = jsimd_convsamp_sse2; |
817 | 0 | return JSIMD_SSE2; |
818 | 0 | } |
819 | | #if SIMD_ARCHITECTURE == I386 |
820 | | if (cinfo->master->simd_support & JSIMD_MMX) { |
821 | | *method = jsimd_convsamp_mmx; |
822 | | return JSIMD_MMX; |
823 | | } |
824 | | #endif |
825 | | #elif SIMD_ARCHITECTURE == ARM64 || SIMD_ARCHITECTURE == ARM |
826 | | if (cinfo->master->simd_support & JSIMD_NEON) { |
827 | | *method = jsimd_convsamp_neon; |
828 | | return JSIMD_NEON; |
829 | | } |
830 | | #elif SIMD_ARCHITECTURE == POWERPC |
831 | | if (cinfo->master->simd_support & JSIMD_ALTIVEC) { |
832 | | *method = jsimd_convsamp_altivec; |
833 | | return JSIMD_ALTIVEC; |
834 | | } |
835 | | #endif |
836 | | |
837 | 0 | return JSIMD_NONE; |
838 | 0 | } |
839 | | |
840 | | |
841 | | HIDDEN unsigned int |
842 | | jsimd_set_convsamp_float(j_compress_ptr cinfo, |
843 | | float_convsamp_method_ptr *method) |
844 | 0 | { |
845 | 0 | init_simd((j_common_ptr)cinfo); |
846 | |
|
847 | 0 | if (BITS_IN_JSAMPLE != 8) |
848 | 0 | return JSIMD_NONE; |
849 | 0 | if (sizeof(JDIMENSION) != 4) |
850 | 0 | return JSIMD_NONE; |
851 | 0 | if (sizeof(FAST_FLOAT) != 4) |
852 | 0 | return JSIMD_NONE; |
853 | | |
854 | 0 | #if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386 |
855 | 0 | if (cinfo->master->simd_support & JSIMD_SSE2) { |
856 | 0 | *method = jsimd_convsamp_float_sse2; |
857 | 0 | return JSIMD_SSE2; |
858 | 0 | } |
859 | | #if SIMD_ARCHITECTURE == I386 |
860 | | if (cinfo->master->simd_support & JSIMD_SSE) { |
861 | | *method = jsimd_convsamp_float_sse; |
862 | | return JSIMD_SSE; |
863 | | } |
864 | | if (cinfo->master->simd_support & JSIMD_3DNOW) { |
865 | | *method = jsimd_convsamp_float_3dnow; |
866 | | return JSIMD_3DNOW; |
867 | | } |
868 | | #endif |
869 | 0 | #endif |
870 | | |
871 | 0 | return JSIMD_NONE; |
872 | 0 | } |
873 | | |
874 | | |
875 | | HIDDEN unsigned int |
876 | | jsimd_set_fdct_islow(j_compress_ptr cinfo, forward_DCT_method_ptr *method) |
877 | 0 | { |
878 | 0 | init_simd((j_common_ptr)cinfo); |
879 | |
|
880 | 0 | if (sizeof(DCTELEM) != 2) |
881 | 0 | return JSIMD_NONE; |
882 | | |
883 | 0 | #if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386 |
884 | 0 | if ((cinfo->master->simd_support & JSIMD_AVX2) && |
885 | 0 | IS_ALIGNED_AVX(jconst_fdct_islow_avx2)) { |
886 | 0 | *method = jsimd_fdct_islow_avx2; |
887 | 0 | return JSIMD_AVX2; |
888 | 0 | } |
889 | 0 | if ((cinfo->master->simd_support & JSIMD_SSE2) && |
890 | 0 | IS_ALIGNED_SSE(jconst_fdct_islow_sse2)) { |
891 | 0 | *method = jsimd_fdct_islow_sse2; |
892 | 0 | return JSIMD_SSE2; |
893 | 0 | } |
894 | | #if SIMD_ARCHITECTURE == I386 |
895 | | if (cinfo->master->simd_support & JSIMD_MMX) { |
896 | | *method = jsimd_fdct_islow_mmx; |
897 | | return JSIMD_MMX; |
898 | | } |
899 | | #endif |
900 | | #elif SIMD_ARCHITECTURE == ARM64 || SIMD_ARCHITECTURE == ARM |
901 | | if (cinfo->master->simd_support & JSIMD_NEON) { |
902 | | *method = jsimd_fdct_islow_neon; |
903 | | return JSIMD_NEON; |
904 | | } |
905 | | #elif SIMD_ARCHITECTURE == POWERPC |
906 | | if (cinfo->master->simd_support & JSIMD_ALTIVEC) { |
907 | | *method = jsimd_fdct_islow_altivec; |
908 | | return JSIMD_ALTIVEC; |
909 | | } |
910 | | #elif SIMD_ARCHITECTURE == MIPS64 |
911 | | if (cinfo->master->simd_support & JSIMD_MMI) { |
912 | | *method = jsimd_fdct_islow_mmi; |
913 | | return JSIMD_MMI; |
914 | | } |
915 | | #endif |
916 | | |
917 | 0 | return JSIMD_NONE; |
918 | 0 | } |
919 | | |
920 | | |
921 | | HIDDEN unsigned int |
922 | | jsimd_set_fdct_ifast(j_compress_ptr cinfo, forward_DCT_method_ptr *method) |
923 | 0 | { |
924 | 0 | init_simd((j_common_ptr)cinfo); |
925 | |
|
926 | 0 | if (sizeof(DCTELEM) != 2) |
927 | 0 | return JSIMD_NONE; |
928 | | |
929 | 0 | #if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386 |
930 | 0 | if ((cinfo->master->simd_support & JSIMD_SSE2) && |
931 | 0 | IS_ALIGNED_SSE(jconst_fdct_ifast_sse2)) { |
932 | 0 | *method = jsimd_fdct_ifast_sse2; |
933 | 0 | return JSIMD_SSE2; |
934 | 0 | } |
935 | | #if SIMD_ARCHITECTURE == I386 |
936 | | if (cinfo->master->simd_support & JSIMD_MMX) { |
937 | | *method = jsimd_fdct_ifast_mmx; |
938 | | return JSIMD_MMX; |
939 | | } |
940 | | #endif |
941 | | #elif SIMD_ARCHITECTURE == ARM64 || SIMD_ARCHITECTURE == ARM |
942 | | if (cinfo->master->simd_support & JSIMD_NEON) { |
943 | | *method = jsimd_fdct_ifast_neon; |
944 | | return JSIMD_NEON; |
945 | | } |
946 | | #elif SIMD_ARCHITECTURE == POWERPC |
947 | | if (cinfo->master->simd_support & JSIMD_ALTIVEC) { |
948 | | *method = jsimd_fdct_ifast_altivec; |
949 | | return JSIMD_ALTIVEC; |
950 | | } |
951 | | #elif SIMD_ARCHITECTURE == MIPS64 |
952 | | if (cinfo->master->simd_support & JSIMD_MMI) { |
953 | | *method = jsimd_fdct_ifast_mmi; |
954 | | return JSIMD_MMI; |
955 | | } |
956 | | #endif |
957 | | |
958 | 0 | return JSIMD_NONE; |
959 | 0 | } |
960 | | |
961 | | |
962 | | HIDDEN unsigned int |
963 | | jsimd_set_fdct_float(j_compress_ptr cinfo, float_DCT_method_ptr *method) |
964 | 0 | { |
965 | 0 | #if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386 |
966 | 0 | init_simd((j_common_ptr)cinfo); |
967 | |
|
968 | 0 | if (sizeof(FAST_FLOAT) != 4) |
969 | 0 | return JSIMD_NONE; |
970 | | |
971 | 0 | if ((cinfo->master->simd_support & JSIMD_SSE) && |
972 | 0 | IS_ALIGNED_SSE(jconst_fdct_float_sse)) { |
973 | 0 | *method = jsimd_fdct_float_sse; |
974 | 0 | return JSIMD_SSE; |
975 | 0 | } |
976 | | #if SIMD_ARCHITECTURE == I386 |
977 | | if (cinfo->master->simd_support & JSIMD_3DNOW) { |
978 | | *method = jsimd_fdct_float_3dnow; |
979 | | return JSIMD_3DNOW; |
980 | | } |
981 | | #endif |
982 | 0 | #endif |
983 | | |
984 | 0 | return JSIMD_NONE; |
985 | 0 | } |
986 | | |
987 | | |
988 | | HIDDEN unsigned int |
989 | | jsimd_set_quantize(j_compress_ptr cinfo, quantize_method_ptr *method) |
990 | 0 | { |
991 | 0 | init_simd((j_common_ptr)cinfo); |
992 | |
|
993 | 0 | if (sizeof(JCOEF) != 2) |
994 | 0 | return JSIMD_NONE; |
995 | 0 | if (sizeof(DCTELEM) != 2) |
996 | 0 | return JSIMD_NONE; |
997 | | |
998 | 0 | #if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386 |
999 | 0 | if (cinfo->master->simd_support & JSIMD_AVX2) { |
1000 | 0 | *method = jsimd_quantize_avx2; |
1001 | 0 | return JSIMD_AVX2; |
1002 | 0 | } |
1003 | 0 | if (cinfo->master->simd_support & JSIMD_SSE2) { |
1004 | 0 | *method = jsimd_quantize_sse2; |
1005 | 0 | return JSIMD_SSE2; |
1006 | 0 | } |
1007 | | #if SIMD_ARCHITECTURE == I386 |
1008 | | if (cinfo->master->simd_support & JSIMD_MMX) { |
1009 | | *method = jsimd_quantize_mmx; |
1010 | | return JSIMD_MMX; |
1011 | | } |
1012 | | #endif |
1013 | | #elif SIMD_ARCHITECTURE == ARM64 || SIMD_ARCHITECTURE == ARM |
1014 | | if (cinfo->master->simd_support & JSIMD_NEON) { |
1015 | | *method = jsimd_quantize_neon; |
1016 | | return JSIMD_NEON; |
1017 | | } |
1018 | | #elif SIMD_ARCHITECTURE == POWERPC |
1019 | | if (cinfo->master->simd_support & JSIMD_ALTIVEC) { |
1020 | | *method = jsimd_quantize_altivec; |
1021 | | return JSIMD_ALTIVEC; |
1022 | | } |
1023 | | #elif SIMD_ARCHITECTURE == MIPS64 |
1024 | | if (cinfo->master->simd_support & JSIMD_MMI) { |
1025 | | *method = jsimd_quantize_mmi; |
1026 | | return JSIMD_MMI; |
1027 | | } |
1028 | | #endif |
1029 | | |
1030 | 0 | return JSIMD_NONE; |
1031 | 0 | } |
1032 | | |
1033 | | |
1034 | | HIDDEN unsigned int |
1035 | | jsimd_set_quantize_float(j_compress_ptr cinfo, |
1036 | | float_quantize_method_ptr *method) |
1037 | 0 | { |
1038 | 0 | init_simd((j_common_ptr)cinfo); |
1039 | |
|
1040 | 0 | if (sizeof(JCOEF) != 2) |
1041 | 0 | return JSIMD_NONE; |
1042 | 0 | if (sizeof(FAST_FLOAT) != 4) |
1043 | 0 | return JSIMD_NONE; |
1044 | | |
1045 | 0 | #if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386 |
1046 | 0 | if (cinfo->master->simd_support & JSIMD_SSE2) { |
1047 | 0 | *method = jsimd_quantize_float_sse2; |
1048 | 0 | return JSIMD_SSE2; |
1049 | 0 | } |
1050 | | #if SIMD_ARCHITECTURE == I386 |
1051 | | if (cinfo->master->simd_support & JSIMD_SSE) { |
1052 | | *method = jsimd_quantize_float_sse; |
1053 | | return JSIMD_SSE; |
1054 | | } |
1055 | | if (cinfo->master->simd_support & JSIMD_3DNOW) { |
1056 | | *method = jsimd_quantize_float_3dnow; |
1057 | | return JSIMD_3DNOW; |
1058 | | } |
1059 | | #endif |
1060 | 0 | #endif |
1061 | | |
1062 | 0 | return JSIMD_NONE; |
1063 | 0 | } |
1064 | | |
1065 | | |
1066 | | HIDDEN unsigned int |
1067 | | jsimd_set_idct_islow(j_decompress_ptr cinfo) |
1068 | 0 | { |
1069 | 0 | init_simd((j_common_ptr)cinfo); |
1070 | |
|
1071 | 0 | if (sizeof(JCOEF) != 2) |
1072 | 0 | return JSIMD_NONE; |
1073 | 0 | if (BITS_IN_JSAMPLE != 8) |
1074 | 0 | return JSIMD_NONE; |
1075 | 0 | if (sizeof(JDIMENSION) != 4) |
1076 | 0 | return JSIMD_NONE; |
1077 | 0 | if (sizeof(ISLOW_MULT_TYPE) != 2) |
1078 | 0 | return JSIMD_NONE; |
1079 | 0 | if (!cinfo->idct) |
1080 | 0 | return JSIMD_NONE; |
1081 | | |
1082 | 0 | #if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386 |
1083 | 0 | if ((cinfo->master->simd_support & JSIMD_AVX2) && |
1084 | 0 | IS_ALIGNED_AVX(jconst_idct_islow_avx2)) { |
1085 | 0 | cinfo->idct->idct_simd = jsimd_idct_islow_avx2; |
1086 | 0 | return JSIMD_AVX2; |
1087 | 0 | } |
1088 | 0 | if ((cinfo->master->simd_support & JSIMD_SSE2) && |
1089 | 0 | IS_ALIGNED_SSE(jconst_idct_islow_sse2)) { |
1090 | 0 | cinfo->idct->idct_simd = jsimd_idct_islow_sse2; |
1091 | 0 | return JSIMD_SSE2; |
1092 | 0 | } |
1093 | | #if SIMD_ARCHITECTURE == I386 |
1094 | | if (cinfo->master->simd_support & JSIMD_MMX) { |
1095 | | cinfo->idct->idct_simd = jsimd_idct_islow_mmx; |
1096 | | return JSIMD_MMX; |
1097 | | } |
1098 | | #endif |
1099 | | #elif SIMD_ARCHITECTURE == ARM64 || SIMD_ARCHITECTURE == ARM |
1100 | | if (cinfo->master->simd_support & JSIMD_NEON) { |
1101 | | cinfo->idct->idct_simd = jsimd_idct_islow_neon; |
1102 | | return JSIMD_NEON; |
1103 | | } |
1104 | | #elif SIMD_ARCHITECTURE == POWERPC |
1105 | | if (cinfo->master->simd_support & JSIMD_ALTIVEC) { |
1106 | | cinfo->idct->idct_simd = jsimd_idct_islow_altivec; |
1107 | | return JSIMD_ALTIVEC; |
1108 | | } |
1109 | | #elif SIMD_ARCHITECTURE == MIPS64 |
1110 | | if (cinfo->master->simd_support & JSIMD_MMI) { |
1111 | | cinfo->idct->idct_simd = jsimd_idct_islow_mmi; |
1112 | | return JSIMD_MMI; |
1113 | | } |
1114 | | #endif |
1115 | | |
1116 | 0 | return JSIMD_NONE; |
1117 | 0 | } |
1118 | | |
1119 | | |
1120 | | HIDDEN void |
1121 | | jsimd_idct_islow(j_decompress_ptr cinfo, jpeg_component_info *compptr, |
1122 | | JCOEFPTR coef_block, JSAMPARRAY output_buf, |
1123 | | JDIMENSION output_col) |
1124 | 0 | { |
1125 | 0 | cinfo->idct->idct_simd(compptr->dct_table, coef_block, output_buf, |
1126 | 0 | output_col); |
1127 | 0 | } |
1128 | | |
1129 | | |
1130 | | HIDDEN unsigned int |
1131 | | jsimd_set_idct_ifast(j_decompress_ptr cinfo) |
1132 | 0 | { |
1133 | 0 | init_simd((j_common_ptr)cinfo); |
1134 | |
|
1135 | 0 | if (sizeof(JCOEF) != 2) |
1136 | 0 | return JSIMD_NONE; |
1137 | 0 | if (BITS_IN_JSAMPLE != 8) |
1138 | 0 | return JSIMD_NONE; |
1139 | 0 | if (sizeof(JDIMENSION) != 4) |
1140 | 0 | return JSIMD_NONE; |
1141 | 0 | if (sizeof(IFAST_MULT_TYPE) != 2) |
1142 | 0 | return JSIMD_NONE; |
1143 | 0 | if (IFAST_SCALE_BITS != 2) |
1144 | 0 | return JSIMD_NONE; |
1145 | 0 | if (!cinfo->idct) |
1146 | 0 | return JSIMD_NONE; |
1147 | | |
1148 | 0 | #if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386 |
1149 | 0 | if ((cinfo->master->simd_support & JSIMD_SSE2) && |
1150 | 0 | IS_ALIGNED_SSE(jconst_idct_ifast_sse2)) { |
1151 | 0 | cinfo->idct->idct_simd = jsimd_idct_ifast_sse2; |
1152 | 0 | return JSIMD_SSE2; |
1153 | 0 | } |
1154 | | #if SIMD_ARCHITECTURE == I386 |
1155 | | if (cinfo->master->simd_support & JSIMD_MMX) { |
1156 | | cinfo->idct->idct_simd = jsimd_idct_ifast_mmx; |
1157 | | return JSIMD_MMX; |
1158 | | } |
1159 | | #endif |
1160 | | #elif SIMD_ARCHITECTURE == ARM64 || SIMD_ARCHITECTURE == ARM |
1161 | | if (cinfo->master->simd_support & JSIMD_NEON) { |
1162 | | cinfo->idct->idct_simd = jsimd_idct_ifast_neon; |
1163 | | return JSIMD_NEON; |
1164 | | } |
1165 | | #elif SIMD_ARCHITECTURE == POWERPC |
1166 | | if (cinfo->master->simd_support & JSIMD_ALTIVEC) { |
1167 | | cinfo->idct->idct_simd = jsimd_idct_ifast_altivec; |
1168 | | return JSIMD_ALTIVEC; |
1169 | | } |
1170 | | #elif SIMD_ARCHITECTURE == MIPS64 |
1171 | | if (cinfo->master->simd_support & JSIMD_MMI) { |
1172 | | cinfo->idct->idct_simd = jsimd_idct_ifast_mmi; |
1173 | | return JSIMD_MMI; |
1174 | | } |
1175 | | #endif |
1176 | | |
1177 | 0 | return JSIMD_NONE; |
1178 | 0 | } |
1179 | | |
1180 | | |
1181 | | HIDDEN void |
1182 | | jsimd_idct_ifast(j_decompress_ptr cinfo, jpeg_component_info *compptr, |
1183 | | JCOEFPTR coef_block, JSAMPARRAY output_buf, |
1184 | | JDIMENSION output_col) |
1185 | 0 | { |
1186 | 0 | cinfo->idct->idct_simd(compptr->dct_table, coef_block, output_buf, |
1187 | 0 | output_col); |
1188 | 0 | } |
1189 | | |
1190 | | |
1191 | | HIDDEN unsigned int |
1192 | | jsimd_set_idct_float(j_decompress_ptr cinfo) |
1193 | 0 | { |
1194 | 0 | #if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386 |
1195 | 0 | init_simd((j_common_ptr)cinfo); |
1196 | |
|
1197 | 0 | if (sizeof(JCOEF) != 2) |
1198 | 0 | return JSIMD_NONE; |
1199 | 0 | if (BITS_IN_JSAMPLE != 8) |
1200 | 0 | return JSIMD_NONE; |
1201 | 0 | if (sizeof(JDIMENSION) != 4) |
1202 | 0 | return JSIMD_NONE; |
1203 | 0 | if (sizeof(FAST_FLOAT) != 4) |
1204 | 0 | return JSIMD_NONE; |
1205 | 0 | if (sizeof(FLOAT_MULT_TYPE) != 4) |
1206 | 0 | return JSIMD_NONE; |
1207 | 0 | if (!cinfo->idct) |
1208 | 0 | return JSIMD_NONE; |
1209 | | |
1210 | 0 | if ((cinfo->master->simd_support & JSIMD_SSE2) && |
1211 | 0 | IS_ALIGNED_SSE(jconst_idct_float_sse2)) { |
1212 | 0 | cinfo->idct->idct_simd = jsimd_idct_float_sse2; |
1213 | 0 | return JSIMD_SSE2; |
1214 | 0 | } |
1215 | | #if SIMD_ARCHITECTURE == I386 |
1216 | | if ((cinfo->master->simd_support & JSIMD_SSE) && |
1217 | | IS_ALIGNED_SSE(jconst_idct_float_sse)) { |
1218 | | cinfo->idct->idct_simd = jsimd_idct_float_sse; |
1219 | | return JSIMD_SSE; |
1220 | | } |
1221 | | if (cinfo->master->simd_support & JSIMD_3DNOW) { |
1222 | | cinfo->idct->idct_simd = jsimd_idct_float_3dnow; |
1223 | | return JSIMD_3DNOW; |
1224 | | } |
1225 | | #endif |
1226 | 0 | #endif |
1227 | | |
1228 | 0 | return JSIMD_NONE; |
1229 | 0 | } |
1230 | | |
1231 | | |
1232 | | HIDDEN void |
1233 | | jsimd_idct_float(j_decompress_ptr cinfo, jpeg_component_info *compptr, |
1234 | | JCOEFPTR coef_block, JSAMPARRAY output_buf, |
1235 | | JDIMENSION output_col) |
1236 | 0 | { |
1237 | 0 | cinfo->idct->idct_simd(compptr->dct_table, coef_block, output_buf, |
1238 | 0 | output_col); |
1239 | 0 | } |
1240 | | |
1241 | | |
1242 | | HIDDEN unsigned int |
1243 | | jsimd_set_idct_2x2(j_decompress_ptr cinfo) |
1244 | 0 | { |
1245 | 0 | init_simd((j_common_ptr)cinfo); |
1246 | |
|
1247 | 0 | if (sizeof(JCOEF) != 2) |
1248 | 0 | return JSIMD_NONE; |
1249 | 0 | if (BITS_IN_JSAMPLE != 8) |
1250 | 0 | return JSIMD_NONE; |
1251 | 0 | if (sizeof(JDIMENSION) != 4) |
1252 | 0 | return JSIMD_NONE; |
1253 | 0 | if (sizeof(ISLOW_MULT_TYPE) != 2) |
1254 | 0 | return JSIMD_NONE; |
1255 | 0 | if (!cinfo->idct) |
1256 | 0 | return JSIMD_NONE; |
1257 | | |
1258 | 0 | #if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386 |
1259 | 0 | if ((cinfo->master->simd_support & JSIMD_SSE2) && |
1260 | 0 | IS_ALIGNED_SSE(jconst_idct_red_sse2)) { |
1261 | 0 | cinfo->idct->idct_2x2_simd = jsimd_idct_2x2_sse2; |
1262 | 0 | return JSIMD_SSE2; |
1263 | 0 | } |
1264 | | #if SIMD_ARCHITECTURE == I386 |
1265 | | if (cinfo->master->simd_support & JSIMD_MMX) { |
1266 | | cinfo->idct->idct_2x2_simd = jsimd_idct_2x2_mmx; |
1267 | | return JSIMD_MMX; |
1268 | | } |
1269 | | #endif |
1270 | | #elif SIMD_ARCHITECTURE == ARM64 || SIMD_ARCHITECTURE == ARM |
1271 | | if (cinfo->master->simd_support & JSIMD_NEON) { |
1272 | | cinfo->idct->idct_2x2_simd = jsimd_idct_2x2_neon; |
1273 | | return JSIMD_NEON; |
1274 | | } |
1275 | | #endif |
1276 | | |
1277 | 0 | return JSIMD_NONE; |
1278 | 0 | } |
1279 | | |
1280 | | |
1281 | | HIDDEN void |
1282 | | jsimd_idct_2x2(j_decompress_ptr cinfo, jpeg_component_info *compptr, |
1283 | | JCOEFPTR coef_block, JSAMPARRAY output_buf, |
1284 | | JDIMENSION output_col) |
1285 | 0 | { |
1286 | 0 | cinfo->idct->idct_2x2_simd(compptr->dct_table, coef_block, output_buf, |
1287 | 0 | output_col); |
1288 | 0 | } |
1289 | | |
1290 | | |
1291 | | HIDDEN unsigned int |
1292 | | jsimd_set_idct_4x4(j_decompress_ptr cinfo) |
1293 | 0 | { |
1294 | 0 | init_simd((j_common_ptr)cinfo); |
1295 | |
|
1296 | 0 | if (sizeof(JCOEF) != 2) |
1297 | 0 | return JSIMD_NONE; |
1298 | 0 | if (BITS_IN_JSAMPLE != 8) |
1299 | 0 | return JSIMD_NONE; |
1300 | 0 | if (sizeof(JDIMENSION) != 4) |
1301 | 0 | return JSIMD_NONE; |
1302 | 0 | if (sizeof(ISLOW_MULT_TYPE) != 2) |
1303 | 0 | return JSIMD_NONE; |
1304 | 0 | if (!cinfo->idct) |
1305 | 0 | return JSIMD_NONE; |
1306 | | |
1307 | 0 | #if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386 |
1308 | 0 | if ((cinfo->master->simd_support & JSIMD_SSE2) && |
1309 | 0 | IS_ALIGNED_SSE(jconst_idct_red_sse2)) { |
1310 | 0 | cinfo->idct->idct_4x4_simd = jsimd_idct_4x4_sse2; |
1311 | 0 | return JSIMD_SSE2; |
1312 | 0 | } |
1313 | | #if SIMD_ARCHITECTURE == I386 |
1314 | | if (cinfo->master->simd_support & JSIMD_MMX) { |
1315 | | cinfo->idct->idct_4x4_simd = jsimd_idct_4x4_mmx; |
1316 | | return JSIMD_MMX; |
1317 | | } |
1318 | | #endif |
1319 | | #elif SIMD_ARCHITECTURE == ARM64 || SIMD_ARCHITECTURE == ARM |
1320 | | if (cinfo->master->simd_support & JSIMD_NEON) { |
1321 | | cinfo->idct->idct_4x4_simd = jsimd_idct_4x4_neon; |
1322 | | return JSIMD_NEON; |
1323 | | } |
1324 | | #endif |
1325 | | |
1326 | 0 | return JSIMD_NONE; |
1327 | 0 | } |
1328 | | |
1329 | | |
1330 | | HIDDEN void |
1331 | | jsimd_idct_4x4(j_decompress_ptr cinfo, jpeg_component_info *compptr, |
1332 | | JCOEFPTR coef_block, JSAMPARRAY output_buf, |
1333 | | JDIMENSION output_col) |
1334 | 0 | { |
1335 | 0 | cinfo->idct->idct_4x4_simd(compptr->dct_table, coef_block, output_buf, |
1336 | 0 | output_col); |
1337 | 0 | } |
1338 | | |
1339 | | |
1340 | | HIDDEN unsigned int |
1341 | | jsimd_set_huff_encode_one_block(j_compress_ptr cinfo) |
1342 | 0 | { |
1343 | 0 | init_simd((j_common_ptr)cinfo); |
1344 | |
|
1345 | 0 | if (sizeof(JCOEF) != 2) |
1346 | 0 | return JSIMD_NONE; |
1347 | 0 | if (!cinfo->entropy) |
1348 | 0 | return JSIMD_NONE; |
1349 | | |
1350 | 0 | #if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386 |
1351 | 0 | if ((cinfo->master->simd_support & JSIMD_SSE2) && |
1352 | 0 | cinfo->master->simd_huffman && |
1353 | 0 | IS_ALIGNED_SSE(jconst_huff_encode_one_block)) { |
1354 | 0 | cinfo->entropy->huff_encode_one_block_simd = |
1355 | 0 | jsimd_huff_encode_one_block_sse2; |
1356 | 0 | return JSIMD_SSE2; |
1357 | 0 | } |
1358 | | #elif SIMD_ARCHITECTURE == ARM64 || SIMD_ARCHITECTURE == ARM |
1359 | | if ((cinfo->master->simd_support & JSIMD_NEON) && |
1360 | | cinfo->master->simd_huffman) { |
1361 | | cinfo->entropy->huff_encode_one_block_simd = |
1362 | | jsimd_huff_encode_one_block_neon; |
1363 | | return JSIMD_NEON; |
1364 | | } |
1365 | | #endif |
1366 | | |
1367 | 0 | return JSIMD_NONE; |
1368 | 0 | } |
1369 | | |
1370 | | |
1371 | | HIDDEN unsigned int |
1372 | | jsimd_set_encode_mcu_AC_first_prepare(j_compress_ptr cinfo, |
1373 | | void (**method) (const JCOEF *, const int *, int, int, UJCOEF *, size_t *)) |
1374 | 0 | { |
1375 | 0 | init_simd((j_common_ptr)cinfo); |
1376 | |
|
1377 | 0 | if (sizeof(JCOEF) != 2) |
1378 | 0 | return JSIMD_NONE; |
1379 | | |
1380 | 0 | #if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386 |
1381 | 0 | if ((cinfo->master->simd_support & JSIMD_SSE2) && |
1382 | 0 | cinfo->master->simd_huffman) { |
1383 | 0 | *method = jsimd_encode_mcu_AC_first_prepare_sse2; |
1384 | 0 | return JSIMD_SSE2; |
1385 | 0 | } |
1386 | | #elif SIMD_ARCHITECTURE == ARM64 || SIMD_ARCHITECTURE == ARM |
1387 | | if ((cinfo->master->simd_support & JSIMD_NEON) && |
1388 | | cinfo->master->simd_huffman) { |
1389 | | *method = jsimd_encode_mcu_AC_first_prepare_neon; |
1390 | | return JSIMD_NEON; |
1391 | | } |
1392 | | #endif |
1393 | | |
1394 | 0 | return JSIMD_NONE; |
1395 | 0 | } |
1396 | | |
1397 | | |
1398 | | HIDDEN unsigned int |
1399 | | jsimd_set_encode_mcu_AC_refine_prepare(j_compress_ptr cinfo, |
1400 | | int (**method) (const JCOEF *, const int *, int, int, UJCOEF *, size_t *)) |
1401 | 0 | { |
1402 | 0 | init_simd((j_common_ptr)cinfo); |
1403 | |
|
1404 | 0 | if (sizeof(JCOEF) != 2) |
1405 | 0 | return JSIMD_NONE; |
1406 | | |
1407 | 0 | #if SIMD_ARCHITECTURE == X86_64 || SIMD_ARCHITECTURE == I386 |
1408 | 0 | if ((cinfo->master->simd_support & JSIMD_SSE2) && |
1409 | 0 | cinfo->master->simd_huffman) { |
1410 | 0 | *method = jsimd_encode_mcu_AC_refine_prepare_sse2; |
1411 | 0 | return JSIMD_SSE2; |
1412 | 0 | } |
1413 | | #elif SIMD_ARCHITECTURE == ARM64 || SIMD_ARCHITECTURE == ARM |
1414 | | if ((cinfo->master->simd_support & JSIMD_NEON) && |
1415 | | cinfo->master->simd_huffman) { |
1416 | | *method = jsimd_encode_mcu_AC_refine_prepare_neon; |
1417 | | return JSIMD_NEON; |
1418 | | } |
1419 | | #endif |
1420 | | |
1421 | 0 | return JSIMD_NONE; |
1422 | 0 | } |