Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/media/libjpeg/simd/jsimd_x86_64.c
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * jsimd_x86_64.c
3
 *
4
 * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
5
 * Copyright (C) 2009-2011, 2014, 2016, D. R. Commander.
6
 * Copyright (C) 2015, Matthieu Darbois.
7
 *
8
 * Based on the x86 SIMD extension for IJG JPEG library,
9
 * Copyright (C) 1999-2006, MIYASAKA Masaru.
10
 * For conditions of distribution and use, see copyright notice in jsimdext.inc
11
 *
12
 * This file contains the interface between the "normal" portions
13
 * of the library and the SIMD implementations when running on a
14
 * 64-bit x86 architecture.
15
 */
16
17
#define JPEG_INTERNALS
18
#include "../jinclude.h"
19
#include "../jpeglib.h"
20
#include "../jsimd.h"
21
#include "../jdct.h"
22
#include "../jsimddct.h"
23
#include "jsimd.h"
24
25
/*
26
 * In the PIC cases, we have no guarantee that constants will keep
27
 * their alignment. This macro allows us to verify it at runtime.
28
 */
29
0
#define IS_ALIGNED(ptr, order) (((size_t)ptr & ((1 << order) - 1)) == 0)
30
31
0
#define IS_ALIGNED_SSE(ptr) (IS_ALIGNED(ptr, 4)) /* 16 byte alignment */
32
33
static unsigned int simd_support = ~0;
34
static unsigned int simd_huffman = 1;
35
36
/*
37
 * Check what SIMD accelerations are supported.
38
 *
39
 * FIXME: This code is racy under a multi-threaded environment.
40
 */
41
LOCAL(void)
42
init_simd (void)
43
{
44
  char *env = NULL;
45
46
  if (simd_support != ~0U)
47
    return;
48
49
  simd_support = JSIMD_SSE2 | JSIMD_SSE;
50
51
  /* Force different settings through environment variables */
52
  env = getenv("JSIMD_FORCENONE");
53
  if ((env != NULL) && (strcmp(env, "1") == 0))
54
    simd_support = 0;
55
  env = getenv("JSIMD_NOHUFFENC");
56
  if ((env != NULL) && (strcmp(env, "1") == 0))
57
    simd_huffman = 0;
58
}
59
60
GLOBAL(int)
61
jsimd_can_rgb_ycc (void)
62
0
{
63
0
  init_simd();
64
0
65
0
  /* The code is optimised for these values only */
66
0
  if (BITS_IN_JSAMPLE != 8)
67
0
    return 0;
68
0
  if (sizeof(JDIMENSION) != 4)
69
0
    return 0;
70
0
  if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4))
71
0
    return 0;
72
0
73
0
  if ((simd_support & JSIMD_SSE2) &&
74
0
      IS_ALIGNED_SSE(jconst_rgb_ycc_convert_sse2))
75
0
    return 1;
76
0
77
0
  return 0;
78
0
}
79
80
GLOBAL(int)
81
jsimd_can_rgb_gray (void)
82
0
{
83
0
  init_simd();
84
0
85
0
  /* The code is optimised for these values only */
86
0
  if (BITS_IN_JSAMPLE != 8)
87
0
    return 0;
88
0
  if (sizeof(JDIMENSION) != 4)
89
0
    return 0;
90
0
  if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4))
91
0
    return 0;
92
0
93
0
  if ((simd_support & JSIMD_SSE2) &&
94
0
      IS_ALIGNED_SSE(jconst_rgb_gray_convert_sse2))
95
0
    return 1;
96
0
97
0
  return 0;
98
0
}
99
100
GLOBAL(int)
101
jsimd_can_ycc_rgb (void)
102
0
{
103
0
  init_simd();
104
0
105
0
  /* The code is optimised for these values only */
106
0
  if (BITS_IN_JSAMPLE != 8)
107
0
    return 0;
108
0
  if (sizeof(JDIMENSION) != 4)
109
0
    return 0;
110
0
  if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4))
111
0
    return 0;
112
0
113
0
  if ((simd_support & JSIMD_SSE2) &&
114
0
      IS_ALIGNED_SSE(jconst_ycc_rgb_convert_sse2))
115
0
    return 1;
116
0
117
0
  return 0;
118
0
}
119
120
GLOBAL(int)
121
jsimd_can_ycc_rgb565 (void)
122
0
{
123
0
  return 0;
124
0
}
125
126
GLOBAL(void)
127
jsimd_rgb_ycc_convert (j_compress_ptr cinfo,
128
                       JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
129
                       JDIMENSION output_row, int num_rows)
130
0
{
131
0
  void (*sse2fct)(JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JDIMENSION, int);
132
0
133
0
  switch(cinfo->in_color_space) {
134
0
    case JCS_EXT_RGB:
135
0
      sse2fct=jsimd_extrgb_ycc_convert_sse2;
136
0
      break;
137
0
    case JCS_EXT_RGBX:
138
0
    case JCS_EXT_RGBA:
139
0
      sse2fct=jsimd_extrgbx_ycc_convert_sse2;
140
0
      break;
141
0
    case JCS_EXT_BGR:
142
0
      sse2fct=jsimd_extbgr_ycc_convert_sse2;
143
0
      break;
144
0
    case JCS_EXT_BGRX:
145
0
    case JCS_EXT_BGRA:
146
0
      sse2fct=jsimd_extbgrx_ycc_convert_sse2;
147
0
      break;
148
0
    case JCS_EXT_XBGR:
149
0
    case JCS_EXT_ABGR:
150
0
      sse2fct=jsimd_extxbgr_ycc_convert_sse2;
151
0
      break;
152
0
    case JCS_EXT_XRGB:
153
0
    case JCS_EXT_ARGB:
154
0
      sse2fct=jsimd_extxrgb_ycc_convert_sse2;
155
0
      break;
156
0
    default:
157
0
      sse2fct=jsimd_rgb_ycc_convert_sse2;
158
0
      break;
159
0
  }
160
0
161
0
  sse2fct(cinfo->image_width, input_buf, output_buf, output_row, num_rows);
162
0
}
163
164
GLOBAL(void)
165
jsimd_rgb_gray_convert (j_compress_ptr cinfo,
166
                        JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
167
                        JDIMENSION output_row, int num_rows)
168
0
{
169
0
  void (*sse2fct)(JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JDIMENSION, int);
170
0
171
0
  switch(cinfo->in_color_space) {
172
0
    case JCS_EXT_RGB:
173
0
      sse2fct=jsimd_extrgb_gray_convert_sse2;
174
0
      break;
175
0
    case JCS_EXT_RGBX:
176
0
    case JCS_EXT_RGBA:
177
0
      sse2fct=jsimd_extrgbx_gray_convert_sse2;
178
0
      break;
179
0
    case JCS_EXT_BGR:
180
0
      sse2fct=jsimd_extbgr_gray_convert_sse2;
181
0
      break;
182
0
    case JCS_EXT_BGRX:
183
0
    case JCS_EXT_BGRA:
184
0
      sse2fct=jsimd_extbgrx_gray_convert_sse2;
185
0
      break;
186
0
    case JCS_EXT_XBGR:
187
0
    case JCS_EXT_ABGR:
188
0
      sse2fct=jsimd_extxbgr_gray_convert_sse2;
189
0
      break;
190
0
    case JCS_EXT_XRGB:
191
0
    case JCS_EXT_ARGB:
192
0
      sse2fct=jsimd_extxrgb_gray_convert_sse2;
193
0
      break;
194
0
    default:
195
0
      sse2fct=jsimd_rgb_gray_convert_sse2;
196
0
      break;
197
0
  }
198
0
199
0
  sse2fct(cinfo->image_width, input_buf, output_buf, output_row, num_rows);
200
0
}
201
202
GLOBAL(void)
203
jsimd_ycc_rgb_convert (j_decompress_ptr cinfo,
204
                       JSAMPIMAGE input_buf, JDIMENSION input_row,
205
                       JSAMPARRAY output_buf, int num_rows)
206
0
{
207
0
  void (*sse2fct)(JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY, int);
208
0
209
0
  switch(cinfo->out_color_space) {
210
0
    case JCS_EXT_RGB:
211
0
      sse2fct=jsimd_ycc_extrgb_convert_sse2;
212
0
      break;
213
0
    case JCS_EXT_RGBX:
214
0
    case JCS_EXT_RGBA:
215
0
      sse2fct=jsimd_ycc_extrgbx_convert_sse2;
216
0
      break;
217
0
    case JCS_EXT_BGR:
218
0
      sse2fct=jsimd_ycc_extbgr_convert_sse2;
219
0
      break;
220
0
    case JCS_EXT_BGRX:
221
0
    case JCS_EXT_BGRA:
222
0
      sse2fct=jsimd_ycc_extbgrx_convert_sse2;
223
0
      break;
224
0
    case JCS_EXT_XBGR:
225
0
    case JCS_EXT_ABGR:
226
0
      sse2fct=jsimd_ycc_extxbgr_convert_sse2;
227
0
      break;
228
0
    case JCS_EXT_XRGB:
229
0
    case JCS_EXT_ARGB:
230
0
      sse2fct=jsimd_ycc_extxrgb_convert_sse2;
231
0
      break;
232
0
    default:
233
0
      sse2fct=jsimd_ycc_rgb_convert_sse2;
234
0
      break;
235
0
  }
236
0
237
0
  sse2fct(cinfo->output_width, input_buf, input_row, output_buf, num_rows);
238
0
}
239
240
GLOBAL(void)
241
jsimd_ycc_rgb565_convert (j_decompress_ptr cinfo,
242
                          JSAMPIMAGE input_buf, JDIMENSION input_row,
243
                          JSAMPARRAY output_buf, int num_rows)
244
0
{
245
0
}
246
247
GLOBAL(int)
248
jsimd_can_h2v2_downsample (void)
249
0
{
250
0
  init_simd();
251
0
252
0
  /* The code is optimised for these values only */
253
0
  if (BITS_IN_JSAMPLE != 8)
254
0
    return 0;
255
0
  if (sizeof(JDIMENSION) != 4)
256
0
    return 0;
257
0
258
0
  if (simd_support & JSIMD_SSE2)
259
0
    return 1;
260
0
261
0
  return 0;
262
0
}
263
264
GLOBAL(int)
265
jsimd_can_h2v1_downsample (void)
266
0
{
267
0
  init_simd();
268
0
269
0
  /* The code is optimised for these values only */
270
0
  if (BITS_IN_JSAMPLE != 8)
271
0
    return 0;
272
0
  if (sizeof(JDIMENSION) != 4)
273
0
    return 0;
274
0
275
0
  if (simd_support & JSIMD_SSE2)
276
0
    return 1;
277
0
278
0
  return 0;
279
0
}
280
281
GLOBAL(void)
282
jsimd_h2v2_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
283
                       JSAMPARRAY input_data, JSAMPARRAY output_data)
284
0
{
285
0
  jsimd_h2v2_downsample_sse2(cinfo->image_width, cinfo->max_v_samp_factor,
286
0
                             compptr->v_samp_factor, compptr->width_in_blocks,
287
0
                             input_data, output_data);
288
0
}
289
290
GLOBAL(void)
291
jsimd_h2v1_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
292
                       JSAMPARRAY input_data, JSAMPARRAY output_data)
293
0
{
294
0
  jsimd_h2v1_downsample_sse2(cinfo->image_width, cinfo->max_v_samp_factor,
295
0
                             compptr->v_samp_factor, compptr->width_in_blocks,
296
0
                             input_data, output_data);
297
0
}
298
299
GLOBAL(int)
300
jsimd_can_h2v2_upsample (void)
301
0
{
302
0
  init_simd();
303
0
304
0
  /* The code is optimised for these values only */
305
0
  if (BITS_IN_JSAMPLE != 8)
306
0
    return 0;
307
0
  if (sizeof(JDIMENSION) != 4)
308
0
    return 0;
309
0
310
0
  if (simd_support & JSIMD_SSE2)
311
0
    return 1;
312
0
313
0
  return 0;
314
0
}
315
316
GLOBAL(int)
317
jsimd_can_h2v1_upsample (void)
318
0
{
319
0
  init_simd();
320
0
321
0
  /* The code is optimised for these values only */
322
0
  if (BITS_IN_JSAMPLE != 8)
323
0
    return 0;
324
0
  if (sizeof(JDIMENSION) != 4)
325
0
    return 0;
326
0
327
0
  if (simd_support & JSIMD_SSE2)
328
0
    return 1;
329
0
330
0
  return 0;
331
0
}
332
333
GLOBAL(void)
334
jsimd_h2v2_upsample (j_decompress_ptr cinfo,
335
                     jpeg_component_info *compptr,
336
                     JSAMPARRAY input_data,
337
                     JSAMPARRAY *output_data_ptr)
338
0
{
339
0
  jsimd_h2v2_upsample_sse2(cinfo->max_v_samp_factor, cinfo->output_width,
340
0
                           input_data, output_data_ptr);
341
0
}
342
343
GLOBAL(void)
344
jsimd_h2v1_upsample (j_decompress_ptr cinfo,
345
                     jpeg_component_info *compptr,
346
                     JSAMPARRAY input_data,
347
                     JSAMPARRAY *output_data_ptr)
348
0
{
349
0
  jsimd_h2v1_upsample_sse2(cinfo->max_v_samp_factor, cinfo->output_width,
350
0
                           input_data, output_data_ptr);
351
0
}
352
353
GLOBAL(int)
354
jsimd_can_h2v2_fancy_upsample (void)
355
0
{
356
0
  init_simd();
357
0
358
0
  /* The code is optimised for these values only */
359
0
  if (BITS_IN_JSAMPLE != 8)
360
0
    return 0;
361
0
  if (sizeof(JDIMENSION) != 4)
362
0
    return 0;
363
0
364
0
  if ((simd_support & JSIMD_SSE2) &&
365
0
      IS_ALIGNED_SSE(jconst_fancy_upsample_sse2))
366
0
    return 1;
367
0
368
0
  return 0;
369
0
}
370
371
GLOBAL(int)
372
jsimd_can_h2v1_fancy_upsample (void)
373
0
{
374
0
  init_simd();
375
0
376
0
  /* The code is optimised for these values only */
377
0
  if (BITS_IN_JSAMPLE != 8)
378
0
    return 0;
379
0
  if (sizeof(JDIMENSION) != 4)
380
0
    return 0;
381
0
382
0
  if ((simd_support & JSIMD_SSE2) &&
383
0
      IS_ALIGNED_SSE(jconst_fancy_upsample_sse2))
384
0
    return 1;
385
0
386
0
  return 0;
387
0
}
388
389
GLOBAL(void)
390
jsimd_h2v2_fancy_upsample (j_decompress_ptr cinfo,
391
                           jpeg_component_info *compptr,
392
                           JSAMPARRAY input_data,
393
                           JSAMPARRAY *output_data_ptr)
394
0
{
395
0
  jsimd_h2v2_fancy_upsample_sse2(cinfo->max_v_samp_factor,
396
0
                                 compptr->downsampled_width, input_data,
397
0
                                 output_data_ptr);
398
0
}
399
400
GLOBAL(void)
401
jsimd_h2v1_fancy_upsample (j_decompress_ptr cinfo,
402
                           jpeg_component_info *compptr,
403
                           JSAMPARRAY input_data,
404
                           JSAMPARRAY *output_data_ptr)
405
0
{
406
0
  jsimd_h2v1_fancy_upsample_sse2(cinfo->max_v_samp_factor,
407
0
                                 compptr->downsampled_width, input_data,
408
0
                                 output_data_ptr);
409
0
}
410
411
GLOBAL(int)
412
jsimd_can_h2v2_merged_upsample (void)
413
0
{
414
0
  init_simd();
415
0
416
0
  /* The code is optimised for these values only */
417
0
  if (BITS_IN_JSAMPLE != 8)
418
0
    return 0;
419
0
  if (sizeof(JDIMENSION) != 4)
420
0
    return 0;
421
0
422
0
  if ((simd_support & JSIMD_SSE2) &&
423
0
      IS_ALIGNED_SSE(jconst_merged_upsample_sse2))
424
0
    return 1;
425
0
426
0
  return 0;
427
0
}
428
429
GLOBAL(int)
430
jsimd_can_h2v1_merged_upsample (void)
431
0
{
432
0
  init_simd();
433
0
434
0
  /* The code is optimised for these values only */
435
0
  if (BITS_IN_JSAMPLE != 8)
436
0
    return 0;
437
0
  if (sizeof(JDIMENSION) != 4)
438
0
    return 0;
439
0
440
0
  if ((simd_support & JSIMD_SSE2) &&
441
0
      IS_ALIGNED_SSE(jconst_merged_upsample_sse2))
442
0
    return 1;
443
0
444
0
  return 0;
445
0
}
446
447
GLOBAL(void)
448
jsimd_h2v2_merged_upsample (j_decompress_ptr cinfo,
449
                            JSAMPIMAGE input_buf,
450
                            JDIMENSION in_row_group_ctr,
451
                            JSAMPARRAY output_buf)
452
0
{
453
0
  void (*sse2fct)(JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY);
454
0
455
0
  switch(cinfo->out_color_space) {
456
0
    case JCS_EXT_RGB:
457
0
      sse2fct=jsimd_h2v2_extrgb_merged_upsample_sse2;
458
0
      break;
459
0
    case JCS_EXT_RGBX:
460
0
    case JCS_EXT_RGBA:
461
0
      sse2fct=jsimd_h2v2_extrgbx_merged_upsample_sse2;
462
0
      break;
463
0
    case JCS_EXT_BGR:
464
0
      sse2fct=jsimd_h2v2_extbgr_merged_upsample_sse2;
465
0
      break;
466
0
    case JCS_EXT_BGRX:
467
0
    case JCS_EXT_BGRA:
468
0
      sse2fct=jsimd_h2v2_extbgrx_merged_upsample_sse2;
469
0
      break;
470
0
    case JCS_EXT_XBGR:
471
0
    case JCS_EXT_ABGR:
472
0
      sse2fct=jsimd_h2v2_extxbgr_merged_upsample_sse2;
473
0
      break;
474
0
    case JCS_EXT_XRGB:
475
0
    case JCS_EXT_ARGB:
476
0
      sse2fct=jsimd_h2v2_extxrgb_merged_upsample_sse2;
477
0
      break;
478
0
    default:
479
0
      sse2fct=jsimd_h2v2_merged_upsample_sse2;
480
0
      break;
481
0
  }
482
0
483
0
  sse2fct(cinfo->output_width, input_buf, in_row_group_ctr, output_buf);
484
0
}
485
486
GLOBAL(void)
487
jsimd_h2v1_merged_upsample (j_decompress_ptr cinfo,
488
                            JSAMPIMAGE input_buf,
489
                            JDIMENSION in_row_group_ctr,
490
                            JSAMPARRAY output_buf)
491
0
{
492
0
  void (*sse2fct)(JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY);
493
0
494
0
  switch(cinfo->out_color_space) {
495
0
    case JCS_EXT_RGB:
496
0
      sse2fct=jsimd_h2v1_extrgb_merged_upsample_sse2;
497
0
      break;
498
0
    case JCS_EXT_RGBX:
499
0
    case JCS_EXT_RGBA:
500
0
      sse2fct=jsimd_h2v1_extrgbx_merged_upsample_sse2;
501
0
      break;
502
0
    case JCS_EXT_BGR:
503
0
      sse2fct=jsimd_h2v1_extbgr_merged_upsample_sse2;
504
0
      break;
505
0
    case JCS_EXT_BGRX:
506
0
    case JCS_EXT_BGRA:
507
0
      sse2fct=jsimd_h2v1_extbgrx_merged_upsample_sse2;
508
0
      break;
509
0
    case JCS_EXT_XBGR:
510
0
    case JCS_EXT_ABGR:
511
0
      sse2fct=jsimd_h2v1_extxbgr_merged_upsample_sse2;
512
0
      break;
513
0
    case JCS_EXT_XRGB:
514
0
    case JCS_EXT_ARGB:
515
0
      sse2fct=jsimd_h2v1_extxrgb_merged_upsample_sse2;
516
0
      break;
517
0
    default:
518
0
      sse2fct=jsimd_h2v1_merged_upsample_sse2;
519
0
      break;
520
0
  }
521
0
522
0
  sse2fct(cinfo->output_width, input_buf, in_row_group_ctr, output_buf);
523
0
}
524
525
GLOBAL(int)
526
jsimd_can_convsamp (void)
527
0
{
528
0
  init_simd();
529
0
530
0
  /* The code is optimised for these values only */
531
0
  if (DCTSIZE != 8)
532
0
    return 0;
533
0
  if (BITS_IN_JSAMPLE != 8)
534
0
    return 0;
535
0
  if (sizeof(JDIMENSION) != 4)
536
0
    return 0;
537
0
  if (sizeof(DCTELEM) != 2)
538
0
    return 0;
539
0
540
0
  if (simd_support & JSIMD_SSE2)
541
0
    return 1;
542
0
543
0
  return 0;
544
0
}
545
546
GLOBAL(int)
547
jsimd_can_convsamp_float (void)
548
0
{
549
0
  init_simd();
550
0
551
0
  /* The code is optimised for these values only */
552
0
  if (DCTSIZE != 8)
553
0
    return 0;
554
0
  if (BITS_IN_JSAMPLE != 8)
555
0
    return 0;
556
0
  if (sizeof(JDIMENSION) != 4)
557
0
    return 0;
558
0
  if (sizeof(FAST_FLOAT) != 4)
559
0
    return 0;
560
0
561
0
  if (simd_support & JSIMD_SSE2)
562
0
    return 1;
563
0
564
0
  return 0;
565
0
}
566
567
GLOBAL(void)
568
jsimd_convsamp (JSAMPARRAY sample_data, JDIMENSION start_col,
569
                DCTELEM *workspace)
570
0
{
571
0
  jsimd_convsamp_sse2(sample_data, start_col, workspace);
572
0
}
573
574
GLOBAL(void)
575
jsimd_convsamp_float (JSAMPARRAY sample_data, JDIMENSION start_col,
576
                      FAST_FLOAT *workspace)
577
0
{
578
0
  jsimd_convsamp_float_sse2(sample_data, start_col, workspace);
579
0
}
580
581
GLOBAL(int)
582
jsimd_can_fdct_islow (void)
583
0
{
584
0
  init_simd();
585
0
586
0
  /* The code is optimised for these values only */
587
0
  if (DCTSIZE != 8)
588
0
    return 0;
589
0
  if (sizeof(DCTELEM) != 2)
590
0
    return 0;
591
0
592
0
  if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_fdct_islow_sse2))
593
0
    return 1;
594
0
595
0
  return 0;
596
0
}
597
598
GLOBAL(int)
599
jsimd_can_fdct_ifast (void)
600
0
{
601
0
  init_simd();
602
0
603
0
  /* The code is optimised for these values only */
604
0
  if (DCTSIZE != 8)
605
0
    return 0;
606
0
  if (sizeof(DCTELEM) != 2)
607
0
    return 0;
608
0
609
0
  if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_fdct_ifast_sse2))
610
0
    return 1;
611
0
612
0
  return 0;
613
0
}
614
615
GLOBAL(int)
616
jsimd_can_fdct_float (void)
617
0
{
618
0
  init_simd();
619
0
620
0
  /* The code is optimised for these values only */
621
0
  if (DCTSIZE != 8)
622
0
    return 0;
623
0
  if (sizeof(FAST_FLOAT) != 4)
624
0
    return 0;
625
0
626
0
  if ((simd_support & JSIMD_SSE) && IS_ALIGNED_SSE(jconst_fdct_float_sse))
627
0
    return 1;
628
0
629
0
  return 0;
630
0
}
631
632
GLOBAL(void)
633
jsimd_fdct_islow (DCTELEM *data)
634
0
{
635
0
  jsimd_fdct_islow_sse2(data);
636
0
}
637
638
GLOBAL(void)
639
jsimd_fdct_ifast (DCTELEM *data)
640
0
{
641
0
  jsimd_fdct_ifast_sse2(data);
642
0
}
643
644
GLOBAL(void)
645
jsimd_fdct_float (FAST_FLOAT *data)
646
0
{
647
0
  jsimd_fdct_float_sse(data);
648
0
}
649
650
GLOBAL(int)
651
jsimd_can_quantize (void)
652
0
{
653
0
  init_simd();
654
0
655
0
  /* The code is optimised for these values only */
656
0
  if (DCTSIZE != 8)
657
0
    return 0;
658
0
  if (sizeof(JCOEF) != 2)
659
0
    return 0;
660
0
  if (sizeof(DCTELEM) != 2)
661
0
    return 0;
662
0
663
0
  if (simd_support & JSIMD_SSE2)
664
0
    return 1;
665
0
666
0
  return 0;
667
0
}
668
669
GLOBAL(int)
670
jsimd_can_quantize_float (void)
671
0
{
672
0
  init_simd();
673
0
674
0
  /* The code is optimised for these values only */
675
0
  if (DCTSIZE != 8)
676
0
    return 0;
677
0
  if (sizeof(JCOEF) != 2)
678
0
    return 0;
679
0
  if (sizeof(FAST_FLOAT) != 4)
680
0
    return 0;
681
0
682
0
  if (simd_support & JSIMD_SSE2)
683
0
    return 1;
684
0
685
0
  return 0;
686
0
}
687
688
GLOBAL(void)
689
jsimd_quantize (JCOEFPTR coef_block, DCTELEM *divisors,
690
                DCTELEM *workspace)
691
0
{
692
0
  jsimd_quantize_sse2(coef_block, divisors, workspace);
693
0
}
694
695
GLOBAL(void)
696
jsimd_quantize_float (JCOEFPTR coef_block, FAST_FLOAT *divisors,
697
                      FAST_FLOAT *workspace)
698
0
{
699
0
  jsimd_quantize_float_sse2(coef_block, divisors, workspace);
700
0
}
701
702
GLOBAL(int)
703
jsimd_can_idct_2x2 (void)
704
0
{
705
0
  init_simd();
706
0
707
0
  /* The code is optimised for these values only */
708
0
  if (DCTSIZE != 8)
709
0
    return 0;
710
0
  if (sizeof(JCOEF) != 2)
711
0
    return 0;
712
0
  if (BITS_IN_JSAMPLE != 8)
713
0
    return 0;
714
0
  if (sizeof(JDIMENSION) != 4)
715
0
    return 0;
716
0
  if (sizeof(ISLOW_MULT_TYPE) != 2)
717
0
    return 0;
718
0
719
0
  if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_red_sse2))
720
0
    return 1;
721
0
722
0
  return 0;
723
0
}
724
725
GLOBAL(int)
726
jsimd_can_idct_4x4 (void)
727
0
{
728
0
  init_simd();
729
0
730
0
  /* The code is optimised for these values only */
731
0
  if (DCTSIZE != 8)
732
0
    return 0;
733
0
  if (sizeof(JCOEF) != 2)
734
0
    return 0;
735
0
  if (BITS_IN_JSAMPLE != 8)
736
0
    return 0;
737
0
  if (sizeof(JDIMENSION) != 4)
738
0
    return 0;
739
0
  if (sizeof(ISLOW_MULT_TYPE) != 2)
740
0
    return 0;
741
0
742
0
  if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_red_sse2))
743
0
    return 1;
744
0
745
0
  return 0;
746
0
}
747
748
GLOBAL(void)
749
jsimd_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
750
                JCOEFPTR coef_block, JSAMPARRAY output_buf,
751
                JDIMENSION output_col)
752
0
{
753
0
  jsimd_idct_2x2_sse2(compptr->dct_table, coef_block, output_buf, output_col);
754
0
}
755
756
GLOBAL(void)
757
jsimd_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
758
                JCOEFPTR coef_block, JSAMPARRAY output_buf,
759
                JDIMENSION output_col)
760
0
{
761
0
  jsimd_idct_4x4_sse2(compptr->dct_table, coef_block, output_buf, output_col);
762
0
}
763
764
GLOBAL(int)
765
jsimd_can_idct_islow (void)
766
0
{
767
0
  init_simd();
768
0
769
0
  /* The code is optimised for these values only */
770
0
  if (DCTSIZE != 8)
771
0
    return 0;
772
0
  if (sizeof(JCOEF) != 2)
773
0
    return 0;
774
0
  if (BITS_IN_JSAMPLE != 8)
775
0
    return 0;
776
0
  if (sizeof(JDIMENSION) != 4)
777
0
    return 0;
778
0
  if (sizeof(ISLOW_MULT_TYPE) != 2)
779
0
    return 0;
780
0
781
0
  if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_islow_sse2))
782
0
    return 1;
783
0
784
0
  return 0;
785
0
}
786
787
GLOBAL(int)
788
jsimd_can_idct_ifast (void)
789
0
{
790
0
  init_simd();
791
0
792
0
  /* The code is optimised for these values only */
793
0
  if (DCTSIZE != 8)
794
0
    return 0;
795
0
  if (sizeof(JCOEF) != 2)
796
0
    return 0;
797
0
  if (BITS_IN_JSAMPLE != 8)
798
0
    return 0;
799
0
  if (sizeof(JDIMENSION) != 4)
800
0
    return 0;
801
0
  if (sizeof(IFAST_MULT_TYPE) != 2)
802
0
    return 0;
803
0
  if (IFAST_SCALE_BITS != 2)
804
0
    return 0;
805
0
806
0
  if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_ifast_sse2))
807
0
    return 1;
808
0
809
0
  return 0;
810
0
}
811
812
GLOBAL(int)
813
jsimd_can_idct_float (void)
814
0
{
815
0
  init_simd();
816
0
817
0
  if (DCTSIZE != 8)
818
0
    return 0;
819
0
  if (sizeof(JCOEF) != 2)
820
0
    return 0;
821
0
  if (BITS_IN_JSAMPLE != 8)
822
0
    return 0;
823
0
  if (sizeof(JDIMENSION) != 4)
824
0
    return 0;
825
0
  if (sizeof(FAST_FLOAT) != 4)
826
0
    return 0;
827
0
  if (sizeof(FLOAT_MULT_TYPE) != 4)
828
0
    return 0;
829
0
830
0
  if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_float_sse2))
831
0
    return 1;
832
0
833
0
  return 0;
834
0
}
835
836
GLOBAL(void)
837
jsimd_idct_islow (j_decompress_ptr cinfo, jpeg_component_info *compptr,
838
                  JCOEFPTR coef_block, JSAMPARRAY output_buf,
839
                  JDIMENSION output_col)
840
0
{
841
0
  jsimd_idct_islow_sse2(compptr->dct_table, coef_block, output_buf,
842
0
                        output_col);
843
0
}
844
845
GLOBAL(void)
846
jsimd_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info *compptr,
847
                  JCOEFPTR coef_block, JSAMPARRAY output_buf,
848
                  JDIMENSION output_col)
849
0
{
850
0
  jsimd_idct_ifast_sse2(compptr->dct_table, coef_block, output_buf,
851
0
                        output_col);
852
0
}
853
854
GLOBAL(void)
855
jsimd_idct_float (j_decompress_ptr cinfo, jpeg_component_info *compptr,
856
                  JCOEFPTR coef_block, JSAMPARRAY output_buf,
857
                  JDIMENSION output_col)
858
0
{
859
0
  jsimd_idct_float_sse2(compptr->dct_table, coef_block, output_buf,
860
0
                        output_col);
861
0
}
862
863
GLOBAL(int)
864
jsimd_can_huff_encode_one_block (void)
865
0
{
866
0
  init_simd();
867
0
868
0
  if (DCTSIZE != 8)
869
0
    return 0;
870
0
  if (sizeof(JCOEF) != 2)
871
0
    return 0;
872
0
873
0
  if ((simd_support & JSIMD_SSE2) && simd_huffman &&
874
0
      IS_ALIGNED_SSE(jconst_huff_encode_one_block))
875
0
    return 1;
876
0
877
0
  return 0;
878
0
}
879
880
GLOBAL(JOCTET*)
881
jsimd_huff_encode_one_block (void *state, JOCTET *buffer, JCOEFPTR block,
882
                             int last_dc_val, c_derived_tbl *dctbl,
883
                             c_derived_tbl *actbl)
884
0
{
885
0
  return jsimd_huff_encode_one_block_sse2(state, buffer, block, last_dc_val,
886
0
                                          dctbl, actbl);
887
0
}