Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(157)

Side by Side Diff: simd/jsimd_powerpc.c

Issue 1953443002: Update to libjpeg_turbo 1.4.90 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/libjpeg_turbo.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « simd/jsimd_mips_dspr2_asm.h ('k') | simd/jsimd_x86_64.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * jsimd_powerpc.c
3 *
4 * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
5 * Copyright 2009-2011, 2014-2015 D. R. Commander
6 * Copyright 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 * PowerPC 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 static unsigned int simd_support = ~0;
26
27 LOCAL(void)
28 init_simd (void)
29 {
30 char *env = NULL;
31
32 if (simd_support != ~0U)
33 return;
34
35 simd_support = JSIMD_ALTIVEC;
36
37 /* Force different settings through environment variables */
38 env = getenv("JSIMD_FORCENONE");
39 if ((env != NULL) && (strcmp(env, "1") == 0))
40 simd_support = 0;
41 }
42
43 GLOBAL(int)
44 jsimd_can_rgb_ycc (void)
45 {
46 init_simd();
47
48 /* The code is optimised for these values only */
49 if (BITS_IN_JSAMPLE != 8)
50 return 0;
51 if (sizeof(JDIMENSION) != 4)
52 return 0;
53 if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4))
54 return 0;
55
56 if (simd_support & JSIMD_ALTIVEC)
57 return 1;
58
59 return 0;
60 }
61
62 GLOBAL(int)
63 jsimd_can_rgb_gray (void)
64 {
65 init_simd();
66
67 /* The code is optimised for these values only */
68 if (BITS_IN_JSAMPLE != 8)
69 return 0;
70 if (sizeof(JDIMENSION) != 4)
71 return 0;
72 if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4))
73 return 0;
74
75 if (simd_support & JSIMD_ALTIVEC)
76 return 1;
77
78 return 0;
79 }
80
81 GLOBAL(int)
82 jsimd_can_ycc_rgb (void)
83 {
84 init_simd();
85
86 /* The code is optimised for these values only */
87 if (BITS_IN_JSAMPLE != 8)
88 return 0;
89 if (sizeof(JDIMENSION) != 4)
90 return 0;
91 if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4))
92 return 0;
93
94 if (simd_support & JSIMD_ALTIVEC)
95 return 1;
96
97 return 0;
98 }
99
100 GLOBAL(int)
101 jsimd_can_ycc_rgb565 (void)
102 {
103 return 0;
104 }
105
106 GLOBAL(void)
107 jsimd_rgb_ycc_convert (j_compress_ptr cinfo,
108 JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
109 JDIMENSION output_row, int num_rows)
110 {
111 void (*altivecfct)(JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JDIMENSION, int);
112
113 switch(cinfo->in_color_space) {
114 case JCS_EXT_RGB:
115 altivecfct=jsimd_extrgb_ycc_convert_altivec;
116 break;
117 case JCS_EXT_RGBX:
118 case JCS_EXT_RGBA:
119 altivecfct=jsimd_extrgbx_ycc_convert_altivec;
120 break;
121 case JCS_EXT_BGR:
122 altivecfct=jsimd_extbgr_ycc_convert_altivec;
123 break;
124 case JCS_EXT_BGRX:
125 case JCS_EXT_BGRA:
126 altivecfct=jsimd_extbgrx_ycc_convert_altivec;
127 break;
128 case JCS_EXT_XBGR:
129 case JCS_EXT_ABGR:
130 altivecfct=jsimd_extxbgr_ycc_convert_altivec;
131 break;
132 case JCS_EXT_XRGB:
133 case JCS_EXT_ARGB:
134 altivecfct=jsimd_extxrgb_ycc_convert_altivec;
135 break;
136 default:
137 altivecfct=jsimd_rgb_ycc_convert_altivec;
138 break;
139 }
140
141 altivecfct(cinfo->image_width, input_buf, output_buf, output_row, num_rows);
142 }
143
144 GLOBAL(void)
145 jsimd_rgb_gray_convert (j_compress_ptr cinfo,
146 JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
147 JDIMENSION output_row, int num_rows)
148 {
149 void (*altivecfct)(JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JDIMENSION, int);
150
151 switch(cinfo->in_color_space) {
152 case JCS_EXT_RGB:
153 altivecfct=jsimd_extrgb_gray_convert_altivec;
154 break;
155 case JCS_EXT_RGBX:
156 case JCS_EXT_RGBA:
157 altivecfct=jsimd_extrgbx_gray_convert_altivec;
158 break;
159 case JCS_EXT_BGR:
160 altivecfct=jsimd_extbgr_gray_convert_altivec;
161 break;
162 case JCS_EXT_BGRX:
163 case JCS_EXT_BGRA:
164 altivecfct=jsimd_extbgrx_gray_convert_altivec;
165 break;
166 case JCS_EXT_XBGR:
167 case JCS_EXT_ABGR:
168 altivecfct=jsimd_extxbgr_gray_convert_altivec;
169 break;
170 case JCS_EXT_XRGB:
171 case JCS_EXT_ARGB:
172 altivecfct=jsimd_extxrgb_gray_convert_altivec;
173 break;
174 default:
175 altivecfct=jsimd_rgb_gray_convert_altivec;
176 break;
177 }
178
179 altivecfct(cinfo->image_width, input_buf, output_buf, output_row, num_rows);
180 }
181
182 GLOBAL(void)
183 jsimd_ycc_rgb_convert (j_decompress_ptr cinfo,
184 JSAMPIMAGE input_buf, JDIMENSION input_row,
185 JSAMPARRAY output_buf, int num_rows)
186 {
187 void (*altivecfct)(JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY, int);
188
189 switch(cinfo->out_color_space) {
190 case JCS_EXT_RGB:
191 altivecfct=jsimd_ycc_extrgb_convert_altivec;
192 break;
193 case JCS_EXT_RGBX:
194 case JCS_EXT_RGBA:
195 altivecfct=jsimd_ycc_extrgbx_convert_altivec;
196 break;
197 case JCS_EXT_BGR:
198 altivecfct=jsimd_ycc_extbgr_convert_altivec;
199 break;
200 case JCS_EXT_BGRX:
201 case JCS_EXT_BGRA:
202 altivecfct=jsimd_ycc_extbgrx_convert_altivec;
203 break;
204 case JCS_EXT_XBGR:
205 case JCS_EXT_ABGR:
206 altivecfct=jsimd_ycc_extxbgr_convert_altivec;
207 break;
208 case JCS_EXT_XRGB:
209 case JCS_EXT_ARGB:
210 altivecfct=jsimd_ycc_extxrgb_convert_altivec;
211 break;
212 default:
213 altivecfct=jsimd_ycc_rgb_convert_altivec;
214 break;
215 }
216
217 altivecfct(cinfo->output_width, input_buf, input_row, output_buf, num_rows);
218 }
219
220 GLOBAL(void)
221 jsimd_ycc_rgb565_convert (j_decompress_ptr cinfo,
222 JSAMPIMAGE input_buf, JDIMENSION input_row,
223 JSAMPARRAY output_buf, int num_rows)
224 {
225 }
226
227 GLOBAL(int)
228 jsimd_can_h2v2_downsample (void)
229 {
230 init_simd();
231
232 /* The code is optimised for these values only */
233 if (BITS_IN_JSAMPLE != 8)
234 return 0;
235 if (sizeof(JDIMENSION) != 4)
236 return 0;
237
238 if (simd_support & JSIMD_ALTIVEC)
239 return 1;
240
241 return 0;
242 }
243
244 GLOBAL(int)
245 jsimd_can_h2v1_downsample (void)
246 {
247 init_simd();
248
249 /* The code is optimised for these values only */
250 if (BITS_IN_JSAMPLE != 8)
251 return 0;
252 if (sizeof(JDIMENSION) != 4)
253 return 0;
254
255 if (simd_support & JSIMD_ALTIVEC)
256 return 1;
257
258 return 0;
259 }
260
261 GLOBAL(void)
262 jsimd_h2v2_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
263 JSAMPARRAY input_data, JSAMPARRAY output_data)
264 {
265 jsimd_h2v2_downsample_altivec(cinfo->image_width, cinfo->max_v_samp_factor,
266 compptr->v_samp_factor,
267 compptr->width_in_blocks,
268 input_data, output_data);
269 }
270
271 GLOBAL(void)
272 jsimd_h2v1_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
273 JSAMPARRAY input_data, JSAMPARRAY output_data)
274 {
275 jsimd_h2v1_downsample_altivec(cinfo->image_width, cinfo->max_v_samp_factor,
276 compptr->v_samp_factor,
277 compptr->width_in_blocks,
278 input_data, output_data);
279 }
280
281 GLOBAL(int)
282 jsimd_can_h2v2_upsample (void)
283 {
284 init_simd();
285
286 /* The code is optimised for these values only */
287 if (BITS_IN_JSAMPLE != 8)
288 return 0;
289 if (sizeof(JDIMENSION) != 4)
290 return 0;
291
292 if (simd_support & JSIMD_ALTIVEC)
293 return 1;
294
295 return 0;
296 }
297
298 GLOBAL(int)
299 jsimd_can_h2v1_upsample (void)
300 {
301 init_simd();
302
303 /* The code is optimised for these values only */
304 if (BITS_IN_JSAMPLE != 8)
305 return 0;
306 if (sizeof(JDIMENSION) != 4)
307 return 0;
308
309 if (simd_support & JSIMD_ALTIVEC)
310 return 1;
311
312 return 0;
313 }
314
315 GLOBAL(void)
316 jsimd_h2v2_upsample (j_decompress_ptr cinfo,
317 jpeg_component_info *compptr,
318 JSAMPARRAY input_data,
319 JSAMPARRAY *output_data_ptr)
320 {
321 jsimd_h2v2_upsample_altivec(cinfo->max_v_samp_factor, cinfo->output_width,
322 input_data, output_data_ptr);
323 }
324
325 GLOBAL(void)
326 jsimd_h2v1_upsample (j_decompress_ptr cinfo,
327 jpeg_component_info *compptr,
328 JSAMPARRAY input_data,
329 JSAMPARRAY *output_data_ptr)
330 {
331 jsimd_h2v1_upsample_altivec(cinfo->max_v_samp_factor, cinfo->output_width,
332 input_data, output_data_ptr);
333 }
334
335 GLOBAL(int)
336 jsimd_can_h2v2_fancy_upsample (void)
337 {
338 init_simd();
339
340 /* The code is optimised for these values only */
341 if (BITS_IN_JSAMPLE != 8)
342 return 0;
343 if (sizeof(JDIMENSION) != 4)
344 return 0;
345
346 if (simd_support & JSIMD_ALTIVEC)
347 return 1;
348
349 return 0;
350 }
351
352 GLOBAL(int)
353 jsimd_can_h2v1_fancy_upsample (void)
354 {
355 init_simd();
356
357 /* The code is optimised for these values only */
358 if (BITS_IN_JSAMPLE != 8)
359 return 0;
360 if (sizeof(JDIMENSION) != 4)
361 return 0;
362
363 if (simd_support & JSIMD_ALTIVEC)
364 return 1;
365
366 return 0;
367 }
368
369 GLOBAL(void)
370 jsimd_h2v2_fancy_upsample (j_decompress_ptr cinfo,
371 jpeg_component_info *compptr,
372 JSAMPARRAY input_data,
373 JSAMPARRAY *output_data_ptr)
374 {
375 jsimd_h2v2_fancy_upsample_altivec(cinfo->max_v_samp_factor,
376 compptr->downsampled_width, input_data,
377 output_data_ptr);
378 }
379
380 GLOBAL(void)
381 jsimd_h2v1_fancy_upsample (j_decompress_ptr cinfo,
382 jpeg_component_info *compptr,
383 JSAMPARRAY input_data,
384 JSAMPARRAY *output_data_ptr)
385 {
386 jsimd_h2v1_fancy_upsample_altivec(cinfo->max_v_samp_factor,
387 compptr->downsampled_width, input_data,
388 output_data_ptr);
389 }
390
391 GLOBAL(int)
392 jsimd_can_h2v2_merged_upsample (void)
393 {
394 init_simd();
395
396 /* The code is optimised for these values only */
397 if (BITS_IN_JSAMPLE != 8)
398 return 0;
399 if (sizeof(JDIMENSION) != 4)
400 return 0;
401
402 if (simd_support & JSIMD_ALTIVEC)
403 return 1;
404
405 return 0;
406 }
407
408 GLOBAL(int)
409 jsimd_can_h2v1_merged_upsample (void)
410 {
411 init_simd();
412
413 /* The code is optimised for these values only */
414 if (BITS_IN_JSAMPLE != 8)
415 return 0;
416 if (sizeof(JDIMENSION) != 4)
417 return 0;
418
419 if (simd_support & JSIMD_ALTIVEC)
420 return 1;
421
422 return 0;
423 }
424
425 GLOBAL(void)
426 jsimd_h2v2_merged_upsample (j_decompress_ptr cinfo,
427 JSAMPIMAGE input_buf,
428 JDIMENSION in_row_group_ctr,
429 JSAMPARRAY output_buf)
430 {
431 void (*altivecfct)(JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY);
432
433 switch(cinfo->out_color_space) {
434 case JCS_EXT_RGB:
435 altivecfct=jsimd_h2v2_extrgb_merged_upsample_altivec;
436 break;
437 case JCS_EXT_RGBX:
438 case JCS_EXT_RGBA:
439 altivecfct=jsimd_h2v2_extrgbx_merged_upsample_altivec;
440 break;
441 case JCS_EXT_BGR:
442 altivecfct=jsimd_h2v2_extbgr_merged_upsample_altivec;
443 break;
444 case JCS_EXT_BGRX:
445 case JCS_EXT_BGRA:
446 altivecfct=jsimd_h2v2_extbgrx_merged_upsample_altivec;
447 break;
448 case JCS_EXT_XBGR:
449 case JCS_EXT_ABGR:
450 altivecfct=jsimd_h2v2_extxbgr_merged_upsample_altivec;
451 break;
452 case JCS_EXT_XRGB:
453 case JCS_EXT_ARGB:
454 altivecfct=jsimd_h2v2_extxrgb_merged_upsample_altivec;
455 break;
456 default:
457 altivecfct=jsimd_h2v2_merged_upsample_altivec;
458 break;
459 }
460
461 altivecfct(cinfo->output_width, input_buf, in_row_group_ctr, output_buf);
462 }
463
464 GLOBAL(void)
465 jsimd_h2v1_merged_upsample (j_decompress_ptr cinfo,
466 JSAMPIMAGE input_buf,
467 JDIMENSION in_row_group_ctr,
468 JSAMPARRAY output_buf)
469 {
470 void (*altivecfct)(JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY);
471
472 switch(cinfo->out_color_space) {
473 case JCS_EXT_RGB:
474 altivecfct=jsimd_h2v1_extrgb_merged_upsample_altivec;
475 break;
476 case JCS_EXT_RGBX:
477 case JCS_EXT_RGBA:
478 altivecfct=jsimd_h2v1_extrgbx_merged_upsample_altivec;
479 break;
480 case JCS_EXT_BGR:
481 altivecfct=jsimd_h2v1_extbgr_merged_upsample_altivec;
482 break;
483 case JCS_EXT_BGRX:
484 case JCS_EXT_BGRA:
485 altivecfct=jsimd_h2v1_extbgrx_merged_upsample_altivec;
486 break;
487 case JCS_EXT_XBGR:
488 case JCS_EXT_ABGR:
489 altivecfct=jsimd_h2v1_extxbgr_merged_upsample_altivec;
490 break;
491 case JCS_EXT_XRGB:
492 case JCS_EXT_ARGB:
493 altivecfct=jsimd_h2v1_extxrgb_merged_upsample_altivec;
494 break;
495 default:
496 altivecfct=jsimd_h2v1_merged_upsample_altivec;
497 break;
498 }
499
500 altivecfct(cinfo->output_width, input_buf, in_row_group_ctr, output_buf);
501 }
502
503 GLOBAL(int)
504 jsimd_can_convsamp (void)
505 {
506 init_simd();
507
508 /* The code is optimised for these values only */
509 if (DCTSIZE != 8)
510 return 0;
511 if (BITS_IN_JSAMPLE != 8)
512 return 0;
513 if (sizeof(JDIMENSION) != 4)
514 return 0;
515 if (sizeof(DCTELEM) != 2)
516 return 0;
517
518 if (simd_support & JSIMD_ALTIVEC)
519 return 1;
520
521 return 0;
522 }
523
524 GLOBAL(int)
525 jsimd_can_convsamp_float (void)
526 {
527 return 0;
528 }
529
530 GLOBAL(void)
531 jsimd_convsamp (JSAMPARRAY sample_data, JDIMENSION start_col,
532 DCTELEM *workspace)
533 {
534 jsimd_convsamp_altivec(sample_data, start_col, workspace);
535 }
536
537 GLOBAL(void)
538 jsimd_convsamp_float (JSAMPARRAY sample_data, JDIMENSION start_col,
539 FAST_FLOAT *workspace)
540 {
541 }
542
543 GLOBAL(int)
544 jsimd_can_fdct_islow (void)
545 {
546 init_simd();
547
548 /* The code is optimised for these values only */
549 if (DCTSIZE != 8)
550 return 0;
551 if (sizeof(DCTELEM) != 2)
552 return 0;
553
554 if (simd_support & JSIMD_ALTIVEC)
555 return 1;
556
557 return 0;
558 }
559
560 GLOBAL(int)
561 jsimd_can_fdct_ifast (void)
562 {
563 init_simd();
564
565 /* The code is optimised for these values only */
566 if (DCTSIZE != 8)
567 return 0;
568 if (sizeof(DCTELEM) != 2)
569 return 0;
570
571 if (simd_support & JSIMD_ALTIVEC)
572 return 1;
573
574 return 0;
575 }
576
577 GLOBAL(int)
578 jsimd_can_fdct_float (void)
579 {
580 return 0;
581 }
582
583 GLOBAL(void)
584 jsimd_fdct_islow (DCTELEM *data)
585 {
586 jsimd_fdct_islow_altivec(data);
587 }
588
589 GLOBAL(void)
590 jsimd_fdct_ifast (DCTELEM *data)
591 {
592 jsimd_fdct_ifast_altivec(data);
593 }
594
595 GLOBAL(void)
596 jsimd_fdct_float (FAST_FLOAT *data)
597 {
598 }
599
600 GLOBAL(int)
601 jsimd_can_quantize (void)
602 {
603 init_simd();
604
605 /* The code is optimised for these values only */
606 if (DCTSIZE != 8)
607 return 0;
608 if (sizeof(JCOEF) != 2)
609 return 0;
610 if (sizeof(DCTELEM) != 2)
611 return 0;
612
613 if (simd_support & JSIMD_ALTIVEC)
614 return 1;
615
616 return 0;
617 }
618
619 GLOBAL(int)
620 jsimd_can_quantize_float (void)
621 {
622 return 0;
623 }
624
625 GLOBAL(void)
626 jsimd_quantize (JCOEFPTR coef_block, DCTELEM *divisors,
627 DCTELEM *workspace)
628 {
629 jsimd_quantize_altivec(coef_block, divisors, workspace);
630 }
631
632 GLOBAL(void)
633 jsimd_quantize_float (JCOEFPTR coef_block, FAST_FLOAT *divisors,
634 FAST_FLOAT *workspace)
635 {
636 }
637
638 GLOBAL(int)
639 jsimd_can_idct_2x2 (void)
640 {
641 return 0;
642 }
643
644 GLOBAL(int)
645 jsimd_can_idct_4x4 (void)
646 {
647 return 0;
648 }
649
650 GLOBAL(void)
651 jsimd_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
652 JCOEFPTR coef_block, JSAMPARRAY output_buf,
653 JDIMENSION output_col)
654 {
655 }
656
657 GLOBAL(void)
658 jsimd_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
659 JCOEFPTR coef_block, JSAMPARRAY output_buf,
660 JDIMENSION output_col)
661 {
662 }
663
664 GLOBAL(int)
665 jsimd_can_idct_islow (void)
666 {
667 init_simd();
668
669 /* The code is optimised for these values only */
670 if (DCTSIZE != 8)
671 return 0;
672 if (sizeof(JCOEF) != 2)
673 return 0;
674
675 if (simd_support & JSIMD_ALTIVEC)
676 return 1;
677
678 return 0;
679 }
680
681 GLOBAL(int)
682 jsimd_can_idct_ifast (void)
683 {
684 init_simd();
685
686 /* The code is optimised for these values only */
687 if (DCTSIZE != 8)
688 return 0;
689 if (sizeof(JCOEF) != 2)
690 return 0;
691
692 if (simd_support & JSIMD_ALTIVEC)
693 return 1;
694
695 return 0;
696 }
697
698 GLOBAL(int)
699 jsimd_can_idct_float (void)
700 {
701 return 0;
702 }
703
704 GLOBAL(void)
705 jsimd_idct_islow (j_decompress_ptr cinfo, jpeg_component_info *compptr,
706 JCOEFPTR coef_block, JSAMPARRAY output_buf,
707 JDIMENSION output_col)
708 {
709 jsimd_idct_islow_altivec(compptr->dct_table, coef_block, output_buf,
710 output_col);
711 }
712
713 GLOBAL(void)
714 jsimd_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info *compptr,
715 JCOEFPTR coef_block, JSAMPARRAY output_buf,
716 JDIMENSION output_col)
717 {
718 jsimd_idct_ifast_altivec(compptr->dct_table, coef_block, output_buf,
719 output_col);
720 }
721
722 GLOBAL(void)
723 jsimd_idct_float (j_decompress_ptr cinfo, jpeg_component_info *compptr,
724 JCOEFPTR coef_block, JSAMPARRAY output_buf,
725 JDIMENSION output_col)
726 {
727 }
728
729 GLOBAL(int)
730 jsimd_can_huff_encode_one_block (void)
731 {
732 return 0;
733 }
734
735 GLOBAL(JOCTET*)
736 jsimd_huff_encode_one_block (void *state, JOCTET *buffer, JCOEFPTR block,
737 int last_dc_val, c_derived_tbl *dctbl,
738 c_derived_tbl *actbl)
739 {
740 return NULL;
741 }
OLDNEW
« no previous file with comments | « simd/jsimd_mips_dspr2_asm.h ('k') | simd/jsimd_x86_64.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698