blob: 6c60b5b07632ce3bd9585a8a70ee8f656e0a56e1 [file] [log] [blame]
Pierre Ossman9ad52342009-03-09 13:15:56 +00001/*
2 * jsimd.c
3 *
4 * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
5 *
6 * Based on the x86 SIMD extension for IJG JPEG library,
7 * Copyright (C) 1999-2006, MIYASAKA Masaru.
8 *
9 * This file contains the interface between the "normal" portions
10 * of the library and the SIMD implementations.
11 */
12
13#define JPEG_INTERNALS
14#include "jinclude.h"
15#include "jpeglib.h"
Pierre Ossman82c7f312009-03-09 13:21:27 +000016#include "jsimd.h"
Pierre Ossman9ad52342009-03-09 13:15:56 +000017#include "jdct.h"
Pierre Ossman82c7f312009-03-09 13:21:27 +000018#include "jsimddct.h"
19#include "simd/jsimd.h"
Pierre Ossman9ad52342009-03-09 13:15:56 +000020
Pierre Ossman0d37c572009-03-09 13:31:56 +000021/*
22 * In the PIC cases, we have no guarantee that constants will keep
23 * their alignment. This macro allows us to verify it at runtime.
24 */
25#ifdef WITH_SIMD
26#define IS_ALIGNED(ptr, order) (((unsigned)ptr & ((1 << order) - 1)) == 0)
27#else
28#define IS_ALIGNED(ptr, order) (0)
29#endif
30
31#define IS_ALIGNED_SSE(ptr) (IS_ALIGNED(ptr, 4)) /* 16 byte alignment */
32
Pierre Ossman9ad52342009-03-09 13:15:56 +000033static unsigned int simd_support = ~0;
34
35/*
36 * Check what SIMD accelerations are supported.
37 *
38 * FIXME: This code is racy under a multi-threaded environment.
39 */
40LOCAL(void)
41init_simd (void)
42{
43 if (simd_support != ~0)
44 return;
45
Pierre Ossman82c7f312009-03-09 13:21:27 +000046#ifdef WITH_SIMD
47 simd_support = jpeg_simd_cpu_support();
48#else
Pierre Ossman9ad52342009-03-09 13:15:56 +000049 simd_support = JSIMD_NONE;
Pierre Ossman82c7f312009-03-09 13:21:27 +000050#endif
Pierre Ossman9ad52342009-03-09 13:15:56 +000051}
52
53GLOBAL(int)
54jsimd_can_rgb_ycc (void)
55{
56 init_simd();
57
Pierre Ossman3e0e2de2009-03-09 13:25:30 +000058 /* The code is optimised for these values only */
59 if (BITS_IN_JSAMPLE != 8)
60 return 0;
61 if (sizeof(JDIMENSION) != 4)
62 return 0;
63 if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4))
64 return 0;
65
66 if (simd_support & JSIMD_MMX)
67 return 1;
68
Pierre Ossman9ad52342009-03-09 13:15:56 +000069 return 0;
70}
71
72GLOBAL(int)
73jsimd_can_ycc_rgb (void)
74{
75 init_simd();
76
Pierre Ossman3e0e2de2009-03-09 13:25:30 +000077 /* The code is optimised for these values only */
78 if (BITS_IN_JSAMPLE != 8)
79 return 0;
80 if (sizeof(JDIMENSION) != 4)
81 return 0;
82 if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4))
83 return 0;
84
85 if (simd_support & JSIMD_MMX)
86 return 1;
87
Pierre Ossman9ad52342009-03-09 13:15:56 +000088 return 0;
89}
90
91GLOBAL(void)
92jsimd_rgb_ycc_convert (j_compress_ptr cinfo,
93 JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
94 JDIMENSION output_row, int num_rows)
95{
Pierre Ossman3e0e2de2009-03-09 13:25:30 +000096#ifdef WITH_SIMD
97 if (simd_support & JSIMD_MMX)
98 jsimd_rgb_ycc_convert_mmx(cinfo->image_width, input_buf,
99 output_buf, output_row, num_rows);
100#endif
Pierre Ossman9ad52342009-03-09 13:15:56 +0000101}
102
103GLOBAL(void)
104jsimd_ycc_rgb_convert (j_decompress_ptr cinfo,
105 JSAMPIMAGE input_buf, JDIMENSION input_row,
106 JSAMPARRAY output_buf, int num_rows)
107{
Pierre Ossman3e0e2de2009-03-09 13:25:30 +0000108#ifdef WITH_SIMD
109 if (simd_support & JSIMD_MMX)
110 jsimd_ycc_rgb_convert_mmx(cinfo->output_width, input_buf,
111 input_row, output_buf, num_rows);
112#endif
Pierre Ossman9ad52342009-03-09 13:15:56 +0000113}
114
115GLOBAL(int)
116jsimd_can_h2v2_downsample (void)
117{
118 init_simd();
119
Pierre Ossman3e0e2de2009-03-09 13:25:30 +0000120 /* The code is optimised for these values only */
121 if (BITS_IN_JSAMPLE != 8)
122 return 0;
123 if (sizeof(JDIMENSION) != 4)
124 return 0;
125
126 if (simd_support & JSIMD_MMX)
127 return 1;
128
Pierre Ossman9ad52342009-03-09 13:15:56 +0000129 return 0;
130}
131
132GLOBAL(int)
133jsimd_can_h2v1_downsample (void)
134{
135 init_simd();
136
Pierre Ossman3e0e2de2009-03-09 13:25:30 +0000137 /* The code is optimised for these values only */
138 if (BITS_IN_JSAMPLE != 8)
139 return 0;
140 if (sizeof(JDIMENSION) != 4)
141 return 0;
142
143 if (simd_support & JSIMD_MMX)
144 return 1;
145
Pierre Ossman9ad52342009-03-09 13:15:56 +0000146 return 0;
147}
148
149GLOBAL(void)
150jsimd_h2v2_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr,
151 JSAMPARRAY input_data, JSAMPARRAY output_data)
152{
Pierre Ossman3e0e2de2009-03-09 13:25:30 +0000153#ifdef WITH_SIMD
154 if (simd_support & JSIMD_MMX)
155 jsimd_h2v2_downsample_mmx(cinfo->image_width, cinfo->max_v_samp_factor,
156 compptr->v_samp_factor, compptr->width_in_blocks,
157 input_data, output_data);
158#endif
Pierre Ossman9ad52342009-03-09 13:15:56 +0000159}
160
161GLOBAL(void)
162jsimd_h2v1_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr,
163 JSAMPARRAY input_data, JSAMPARRAY output_data)
164{
Pierre Ossman3e0e2de2009-03-09 13:25:30 +0000165#ifdef WITH_SIMD
166 if (simd_support & JSIMD_MMX)
167 jsimd_h2v1_downsample_mmx(cinfo->image_width, cinfo->max_v_samp_factor,
168 compptr->v_samp_factor, compptr->width_in_blocks,
169 input_data, output_data);
170#endif
Pierre Ossman9ad52342009-03-09 13:15:56 +0000171}
172
173GLOBAL(int)
174jsimd_can_h2v2_upsample (void)
175{
176 init_simd();
177
Pierre Ossman3e0e2de2009-03-09 13:25:30 +0000178 /* The code is optimised for these values only */
179 if (BITS_IN_JSAMPLE != 8)
180 return 0;
181 if (sizeof(JDIMENSION) != 4)
182 return 0;
183
184 if (simd_support & JSIMD_MMX)
185 return 1;
186
Pierre Ossman9ad52342009-03-09 13:15:56 +0000187 return 0;
188}
189
190GLOBAL(int)
191jsimd_can_h2v1_upsample (void)
192{
193 init_simd();
194
Pierre Ossman3e0e2de2009-03-09 13:25:30 +0000195 /* The code is optimised for these values only */
196 if (BITS_IN_JSAMPLE != 8)
197 return 0;
198 if (sizeof(JDIMENSION) != 4)
199 return 0;
200
201 if (simd_support & JSIMD_MMX)
202 return 1;
203
Pierre Ossman9ad52342009-03-09 13:15:56 +0000204 return 0;
205}
206
207GLOBAL(void)
208jsimd_h2v2_upsample (j_decompress_ptr cinfo,
209 jpeg_component_info * compptr,
210 JSAMPARRAY input_data,
211 JSAMPARRAY * output_data_ptr)
212{
Pierre Ossman3e0e2de2009-03-09 13:25:30 +0000213#ifdef WITH_SIMD
214 if (simd_support & JSIMD_MMX)
215 jsimd_h2v2_upsample_mmx(cinfo->max_v_samp_factor,
216 cinfo->output_width, input_data, output_data_ptr);
217#endif
Pierre Ossman9ad52342009-03-09 13:15:56 +0000218}
219
220GLOBAL(void)
221jsimd_h2v1_upsample (j_decompress_ptr cinfo,
222 jpeg_component_info * compptr,
223 JSAMPARRAY input_data,
224 JSAMPARRAY * output_data_ptr)
225{
Pierre Ossman3e0e2de2009-03-09 13:25:30 +0000226#ifdef WITH_SIMD
227 if (simd_support & JSIMD_MMX)
228 jsimd_h2v1_upsample_mmx(cinfo->max_v_samp_factor,
229 cinfo->output_width, input_data, output_data_ptr);
230#endif
Pierre Ossman9ad52342009-03-09 13:15:56 +0000231}
232
233GLOBAL(int)
234jsimd_can_h2v2_fancy_upsample (void)
235{
236 init_simd();
237
Pierre Ossman3e0e2de2009-03-09 13:25:30 +0000238 /* The code is optimised for these values only */
239 if (BITS_IN_JSAMPLE != 8)
240 return 0;
241 if (sizeof(JDIMENSION) != 4)
242 return 0;
243
244 if (simd_support & JSIMD_MMX)
245 return 1;
246
Pierre Ossman9ad52342009-03-09 13:15:56 +0000247 return 0;
248}
249
250GLOBAL(int)
251jsimd_can_h2v1_fancy_upsample (void)
252{
253 init_simd();
254
Pierre Ossman3e0e2de2009-03-09 13:25:30 +0000255 /* The code is optimised for these values only */
256 if (BITS_IN_JSAMPLE != 8)
257 return 0;
258 if (sizeof(JDIMENSION) != 4)
259 return 0;
260
261 if (simd_support & JSIMD_MMX)
262 return 1;
263
Pierre Ossman9ad52342009-03-09 13:15:56 +0000264 return 0;
265}
266
267GLOBAL(void)
268jsimd_h2v2_fancy_upsample (j_decompress_ptr cinfo,
269 jpeg_component_info * compptr,
270 JSAMPARRAY input_data,
271 JSAMPARRAY * output_data_ptr)
272{
Pierre Ossman3e0e2de2009-03-09 13:25:30 +0000273#ifdef WITH_SIMD
274 if (simd_support & JSIMD_MMX)
275 jsimd_h2v2_fancy_upsample_mmx(cinfo->max_v_samp_factor,
276 compptr->downsampled_width, input_data, output_data_ptr);
277#endif
Pierre Ossman9ad52342009-03-09 13:15:56 +0000278}
279
280GLOBAL(void)
281jsimd_h2v1_fancy_upsample (j_decompress_ptr cinfo,
282 jpeg_component_info * compptr,
283 JSAMPARRAY input_data,
284 JSAMPARRAY * output_data_ptr)
285{
Pierre Ossman3e0e2de2009-03-09 13:25:30 +0000286#ifdef WITH_SIMD
287 if (simd_support & JSIMD_MMX)
288 jsimd_h2v1_fancy_upsample_mmx(cinfo->max_v_samp_factor,
289 compptr->downsampled_width, input_data, output_data_ptr);
290#endif
Pierre Ossman9ad52342009-03-09 13:15:56 +0000291}
292
293GLOBAL(int)
294jsimd_can_h2v2_merged_upsample (void)
295{
296 init_simd();
297
Pierre Ossman3e0e2de2009-03-09 13:25:30 +0000298 /* The code is optimised for these values only */
299 if (BITS_IN_JSAMPLE != 8)
300 return 0;
301 if (sizeof(JDIMENSION) != 4)
302 return 0;
303
304 if (simd_support & JSIMD_MMX)
305 return 1;
306
Pierre Ossman9ad52342009-03-09 13:15:56 +0000307 return 0;
308}
309
310GLOBAL(int)
311jsimd_can_h2v1_merged_upsample (void)
312{
313 init_simd();
314
Pierre Ossman3e0e2de2009-03-09 13:25:30 +0000315 /* The code is optimised for these values only */
316 if (BITS_IN_JSAMPLE != 8)
317 return 0;
318 if (sizeof(JDIMENSION) != 4)
319 return 0;
320
321 if (simd_support & JSIMD_MMX)
322 return 1;
323
Pierre Ossman9ad52342009-03-09 13:15:56 +0000324 return 0;
325}
326
327GLOBAL(void)
328jsimd_h2v2_merged_upsample (j_decompress_ptr cinfo,
329 JSAMPIMAGE input_buf,
330 JDIMENSION in_row_group_ctr,
331 JSAMPARRAY output_buf)
332{
Pierre Ossman3e0e2de2009-03-09 13:25:30 +0000333#ifdef WITH_SIMD
334 if (simd_support & JSIMD_MMX)
335 jsimd_h2v2_merged_upsample_mmx(cinfo->output_width, input_buf,
336 in_row_group_ctr, output_buf);
337#endif
Pierre Ossman9ad52342009-03-09 13:15:56 +0000338}
339
340GLOBAL(void)
341jsimd_h2v1_merged_upsample (j_decompress_ptr cinfo,
342 JSAMPIMAGE input_buf,
343 JDIMENSION in_row_group_ctr,
344 JSAMPARRAY output_buf)
345{
Pierre Ossman3e0e2de2009-03-09 13:25:30 +0000346#ifdef WITH_SIMD
347 if (simd_support & JSIMD_MMX)
348 jsimd_h2v1_merged_upsample_mmx(cinfo->output_width, input_buf,
349 in_row_group_ctr, output_buf);
350#endif
Pierre Ossman9ad52342009-03-09 13:15:56 +0000351}
352
353GLOBAL(int)
354jsimd_can_convsamp (void)
355{
356 init_simd();
357
Pierre Ossman3e0e2de2009-03-09 13:25:30 +0000358 /* The code is optimised for these values only */
359 if (DCTSIZE != 8)
360 return 0;
361 if (BITS_IN_JSAMPLE != 8)
362 return 0;
363 if (sizeof(JDIMENSION) != 4)
364 return 0;
365 if (sizeof(DCTELEM) != 2)
366 return 0;
367
368 if (simd_support & JSIMD_MMX)
369 return 1;
370
Pierre Ossman9ad52342009-03-09 13:15:56 +0000371 return 0;
372}
373
374GLOBAL(int)
375jsimd_can_convsamp_float (void)
376{
377 init_simd();
378
Pierre Ossman2c2e54b2009-03-09 13:28:10 +0000379 /* The code is optimised for these values only */
380 if (DCTSIZE != 8)
381 return 0;
382 if (BITS_IN_JSAMPLE != 8)
383 return 0;
384 if (sizeof(JDIMENSION) != 4)
385 return 0;
386 if (sizeof(FAST_FLOAT) != 4)
387 return 0;
388
Pierre Ossman0d37c572009-03-09 13:31:56 +0000389 if (simd_support & JSIMD_SSE)
390 return 1;
Pierre Ossman2c2e54b2009-03-09 13:28:10 +0000391 if (simd_support & JSIMD_3DNOW)
392 return 1;
393
Pierre Ossman9ad52342009-03-09 13:15:56 +0000394 return 0;
395}
396
397GLOBAL(void)
398jsimd_convsamp (JSAMPARRAY sample_data, JDIMENSION start_col,
399 DCTELEM * workspace)
400{
Pierre Ossman3e0e2de2009-03-09 13:25:30 +0000401#ifdef WITH_SIMD
402 if (simd_support & JSIMD_MMX)
403 jsimd_convsamp_mmx(sample_data, start_col, workspace);
404#endif
Pierre Ossman9ad52342009-03-09 13:15:56 +0000405}
406
407GLOBAL(void)
408jsimd_convsamp_float (JSAMPARRAY sample_data, JDIMENSION start_col,
409 FAST_FLOAT * workspace)
410{
Pierre Ossman2c2e54b2009-03-09 13:28:10 +0000411#ifdef WITH_SIMD
Pierre Ossman0d37c572009-03-09 13:31:56 +0000412 if (simd_support & JSIMD_SSE)
413 jsimd_convsamp_float_sse(sample_data, start_col, workspace);
414 else if (simd_support & JSIMD_3DNOW)
Pierre Ossman2c2e54b2009-03-09 13:28:10 +0000415 jsimd_convsamp_float_3dnow(sample_data, start_col, workspace);
416#endif
Pierre Ossman9ad52342009-03-09 13:15:56 +0000417}
418
419GLOBAL(int)
420jsimd_can_fdct_islow (void)
421{
422 init_simd();
423
Pierre Ossman3e0e2de2009-03-09 13:25:30 +0000424 /* The code is optimised for these values only */
425 if (DCTSIZE != 8)
426 return 0;
427 if (sizeof(DCTELEM) != 2)
428 return 0;
429
430 if (simd_support & JSIMD_MMX)
431 return 1;
432
Pierre Ossman9ad52342009-03-09 13:15:56 +0000433 return 0;
434}
435
436GLOBAL(int)
437jsimd_can_fdct_ifast (void)
438{
439 init_simd();
440
Pierre Ossman3e0e2de2009-03-09 13:25:30 +0000441 /* The code is optimised for these values only */
442 if (DCTSIZE != 8)
443 return 0;
444 if (sizeof(DCTELEM) != 2)
445 return 0;
446
447 if (simd_support & JSIMD_MMX)
448 return 1;
449
Pierre Ossman9ad52342009-03-09 13:15:56 +0000450 return 0;
451}
452
453GLOBAL(int)
454jsimd_can_fdct_float (void)
455{
456 init_simd();
457
Pierre Ossman2c2e54b2009-03-09 13:28:10 +0000458 /* The code is optimised for these values only */
459 if (DCTSIZE != 8)
460 return 0;
461 if (sizeof(FAST_FLOAT) != 4)
462 return 0;
463
Pierre Ossman0d37c572009-03-09 13:31:56 +0000464 if ((simd_support & JSIMD_SSE) && IS_ALIGNED_SSE(jconst_fdct_float_sse))
465 return 1;
Pierre Ossman2c2e54b2009-03-09 13:28:10 +0000466 if (simd_support & JSIMD_3DNOW)
467 return 1;
468
Pierre Ossman9ad52342009-03-09 13:15:56 +0000469 return 0;
470}
471
472GLOBAL(void)
473jsimd_fdct_islow (DCTELEM * data)
474{
Pierre Ossman3e0e2de2009-03-09 13:25:30 +0000475#ifdef WITH_SIMD
476 if (simd_support & JSIMD_MMX)
477 jsimd_fdct_islow_mmx(data);
478#endif
Pierre Ossman9ad52342009-03-09 13:15:56 +0000479}
480
481GLOBAL(void)
482jsimd_fdct_ifast (DCTELEM * data)
483{
Pierre Ossman3e0e2de2009-03-09 13:25:30 +0000484#ifdef WITH_SIMD
485 if (simd_support & JSIMD_MMX)
486 jsimd_fdct_ifast_mmx(data);
487#endif
Pierre Ossman9ad52342009-03-09 13:15:56 +0000488}
489
490GLOBAL(void)
491jsimd_fdct_float (FAST_FLOAT * data)
492{
Pierre Ossman2c2e54b2009-03-09 13:28:10 +0000493#ifdef WITH_SIMD
Pierre Ossman0d37c572009-03-09 13:31:56 +0000494 if ((simd_support & JSIMD_SSE) && IS_ALIGNED_SSE(jconst_fdct_float_sse))
495 jsimd_fdct_float_sse(data);
496 else if (simd_support & JSIMD_3DNOW)
Pierre Ossman2c2e54b2009-03-09 13:28:10 +0000497 jsimd_fdct_float_3dnow(data);
498#endif
Pierre Ossman9ad52342009-03-09 13:15:56 +0000499}
500
501GLOBAL(int)
502jsimd_can_quantize (void)
503{
504 init_simd();
505
Pierre Ossman3e0e2de2009-03-09 13:25:30 +0000506 /* The code is optimised for these values only */
507 if (DCTSIZE != 8)
508 return 0;
509 if (sizeof(JCOEF) != 2)
510 return 0;
511 if (sizeof(DCTELEM) != 2)
512 return 0;
513
514 if (simd_support & JSIMD_MMX)
515 return 1;
516
Pierre Ossman9ad52342009-03-09 13:15:56 +0000517 return 0;
518}
519
520GLOBAL(int)
521jsimd_can_quantize_float (void)
522{
523 init_simd();
524
Pierre Ossman2c2e54b2009-03-09 13:28:10 +0000525 /* The code is optimised for these values only */
526 if (DCTSIZE != 8)
527 return 0;
528 if (sizeof(JCOEF) != 2)
529 return 0;
530 if (sizeof(FAST_FLOAT) != 4)
531 return 0;
532
Pierre Ossman0d37c572009-03-09 13:31:56 +0000533 if (simd_support & JSIMD_SSE)
534 return 1;
Pierre Ossman2c2e54b2009-03-09 13:28:10 +0000535 if (simd_support & JSIMD_3DNOW)
536 return 1;
537
Pierre Ossman9ad52342009-03-09 13:15:56 +0000538 return 0;
539}
540
541GLOBAL(void)
542jsimd_quantize (JCOEFPTR coef_block, DCTELEM * divisors,
543 DCTELEM * workspace)
544{
Pierre Ossman3e0e2de2009-03-09 13:25:30 +0000545#ifdef WITH_SIMD
546 if (simd_support & JSIMD_MMX)
547 jsimd_quantize_mmx(coef_block, divisors, workspace);
548#endif
Pierre Ossman9ad52342009-03-09 13:15:56 +0000549}
550
551GLOBAL(void)
552jsimd_quantize_float (JCOEFPTR coef_block, FAST_FLOAT * divisors,
553 FAST_FLOAT * workspace)
554{
Pierre Ossman2c2e54b2009-03-09 13:28:10 +0000555#ifdef WITH_SIMD
Pierre Ossman0d37c572009-03-09 13:31:56 +0000556 if (simd_support & JSIMD_SSE)
557 jsimd_quantize_float_sse(coef_block, divisors, workspace);
558 else if (simd_support & JSIMD_3DNOW)
Pierre Ossman2c2e54b2009-03-09 13:28:10 +0000559 jsimd_quantize_float_3dnow(coef_block, divisors, workspace);
560#endif
Pierre Ossman9ad52342009-03-09 13:15:56 +0000561}
562
563GLOBAL(int)
564jsimd_can_idct_2x2 (void)
565{
566 init_simd();
567
Pierre Ossman3e0e2de2009-03-09 13:25:30 +0000568 /* The code is optimised for these values only */
569 if (DCTSIZE != 8)
570 return 0;
571 if (sizeof(JCOEF) != 2)
572 return 0;
573 if (BITS_IN_JSAMPLE != 8)
574 return 0;
575 if (sizeof(JDIMENSION) != 4)
576 return 0;
577 if (sizeof(ISLOW_MULT_TYPE) != 2)
578 return 0;
579
580 if (simd_support & JSIMD_MMX)
581 return 1;
582
Pierre Ossman9ad52342009-03-09 13:15:56 +0000583 return 0;
584}
585
586GLOBAL(int)
587jsimd_can_idct_4x4 (void)
588{
589 init_simd();
590
Pierre Ossman3e0e2de2009-03-09 13:25:30 +0000591 /* The code is optimised for these values only */
592 if (DCTSIZE != 8)
593 return 0;
594 if (sizeof(JCOEF) != 2)
595 return 0;
596 if (BITS_IN_JSAMPLE != 8)
597 return 0;
598 if (sizeof(JDIMENSION) != 4)
599 return 0;
600 if (sizeof(ISLOW_MULT_TYPE) != 2)
601 return 0;
602
603 if (simd_support & JSIMD_MMX)
604 return 1;
605
Pierre Ossman9ad52342009-03-09 13:15:56 +0000606 return 0;
607}
608
609GLOBAL(void)
610jsimd_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
611 JCOEFPTR coef_block, JSAMPARRAY output_buf,
612 JDIMENSION output_col)
613{
Pierre Ossman3e0e2de2009-03-09 13:25:30 +0000614#if WITH_SIMD
615 if (simd_support & JSIMD_MMX)
616 jsimd_idct_2x2_mmx(compptr->dct_table, coef_block, output_buf, output_col);
617#endif
Pierre Ossman9ad52342009-03-09 13:15:56 +0000618}
619
620GLOBAL(void)
621jsimd_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
622 JCOEFPTR coef_block, JSAMPARRAY output_buf,
623 JDIMENSION output_col)
624{
Pierre Ossman3e0e2de2009-03-09 13:25:30 +0000625#if WITH_SIMD
626 if (simd_support & JSIMD_MMX)
627 jsimd_idct_4x4_mmx(compptr->dct_table, coef_block, output_buf, output_col);
628#endif
Pierre Ossman9ad52342009-03-09 13:15:56 +0000629}
630
631GLOBAL(int)
632jsimd_can_idct_islow (void)
633{
634 init_simd();
635
Pierre Ossman3e0e2de2009-03-09 13:25:30 +0000636 /* The code is optimised for these values only */
637 if (DCTSIZE != 8)
638 return 0;
639 if (sizeof(JCOEF) != 2)
640 return 0;
641 if (BITS_IN_JSAMPLE != 8)
642 return 0;
643 if (sizeof(JDIMENSION) != 4)
644 return 0;
645 if (sizeof(ISLOW_MULT_TYPE) != 2)
646 return 0;
647
648 if (simd_support & JSIMD_MMX)
649 return 1;
650
Pierre Ossman9ad52342009-03-09 13:15:56 +0000651 return 0;
652}
653
654GLOBAL(int)
655jsimd_can_idct_ifast (void)
656{
657 init_simd();
658
Pierre Ossman3e0e2de2009-03-09 13:25:30 +0000659 /* The code is optimised for these values only */
660 if (DCTSIZE != 8)
661 return 0;
662 if (sizeof(JCOEF) != 2)
663 return 0;
664 if (BITS_IN_JSAMPLE != 8)
665 return 0;
666 if (sizeof(JDIMENSION) != 4)
667 return 0;
668 if (sizeof(IFAST_MULT_TYPE) != 2)
669 return 0;
670 if (IFAST_SCALE_BITS != 2)
671 return 0;
672
673 if (simd_support & JSIMD_MMX)
674 return 1;
675
Pierre Ossman9ad52342009-03-09 13:15:56 +0000676 return 0;
677}
678
679GLOBAL(int)
680jsimd_can_idct_float (void)
681{
682 init_simd();
683
Pierre Ossman2c2e54b2009-03-09 13:28:10 +0000684 if (DCTSIZE != 8)
685 return 0;
686 if (sizeof(JCOEF) != 2)
687 return 0;
688 if (BITS_IN_JSAMPLE != 8)
689 return 0;
690 if (sizeof(JDIMENSION) != 4)
691 return 0;
692 if (sizeof(FAST_FLOAT) != 4)
693 return 0;
694 if (sizeof(FLOAT_MULT_TYPE) != 4)
695 return 0;
696
Pierre Ossman0d37c572009-03-09 13:31:56 +0000697 if ((simd_support & JSIMD_SSE) && IS_ALIGNED_SSE(jconst_idct_float_sse))
698 return 1;
Pierre Ossman2c2e54b2009-03-09 13:28:10 +0000699 if (simd_support & JSIMD_3DNOW)
700 return 1;
701
Pierre Ossman9ad52342009-03-09 13:15:56 +0000702 return 0;
703}
704
705GLOBAL(void)
706jsimd_idct_islow (j_decompress_ptr cinfo, jpeg_component_info * compptr,
707 JCOEFPTR coef_block, JSAMPARRAY output_buf,
708 JDIMENSION output_col)
709{
Pierre Ossman3e0e2de2009-03-09 13:25:30 +0000710#if WITH_SIMD
711 if (simd_support & JSIMD_MMX)
712 jsimd_idct_islow_mmx(compptr->dct_table, coef_block, output_buf, output_col);
713#endif
Pierre Ossman9ad52342009-03-09 13:15:56 +0000714}
715
716GLOBAL(void)
717jsimd_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr,
718 JCOEFPTR coef_block, JSAMPARRAY output_buf,
719 JDIMENSION output_col)
720{
Pierre Ossman3e0e2de2009-03-09 13:25:30 +0000721#if WITH_SIMD
722 if (simd_support & JSIMD_MMX)
723 jsimd_idct_ifast_mmx(compptr->dct_table, coef_block, output_buf, output_col);
724#endif
Pierre Ossman9ad52342009-03-09 13:15:56 +0000725}
726
727GLOBAL(void)
728jsimd_idct_float (j_decompress_ptr cinfo, jpeg_component_info * compptr,
729 JCOEFPTR coef_block, JSAMPARRAY output_buf,
730 JDIMENSION output_col)
731{
Pierre Ossman2c2e54b2009-03-09 13:28:10 +0000732#if WITH_SIMD
Pierre Ossman0d37c572009-03-09 13:31:56 +0000733 if ((simd_support & JSIMD_SSE) && IS_ALIGNED_SSE(jconst_idct_float_sse))
734 jsimd_idct_float_sse(compptr->dct_table, coef_block,
735 output_buf, output_col);
736 else if (simd_support & JSIMD_3DNOW)
Pierre Ossman2c2e54b2009-03-09 13:28:10 +0000737 jsimd_idct_float_3dnow(compptr->dct_table, coef_block,
738 output_buf, output_col);
739#endif
Pierre Ossman9ad52342009-03-09 13:15:56 +0000740}
741