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

Side by Side Diff: simd/jsimd_mips.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_i386.c ('k') | simd/jsimd_mips_dspr2.S » ('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_mips.c
3 *
4 * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
5 * Copyright 2009-2011, 2014 D. R. Commander
6 * Copyright (C) 2013-2014, MIPS Technologies, Inc., California
7 * Copyright 2015 Matthieu Darbois
8 *
9 * Based on the x86 SIMD extension for IJG JPEG library,
10 * Copyright (C) 1999-2006, MIYASAKA Masaru.
11 * For conditions of distribution and use, see copyright notice in jsimdext.inc
12 *
13 * This file contains the interface between the "normal" portions
14 * of the library and the SIMD implementations when running on a
15 * MIPS architecture.
16 */
17
18 #define JPEG_INTERNALS
19 #include "../jinclude.h"
20 #include "../jpeglib.h"
21 #include "../jsimd.h"
22 #include "../jdct.h"
23 #include "../jsimddct.h"
24 #include "jsimd.h"
25
26 #include <stdio.h>
27 #include <string.h>
28 #include <ctype.h>
29
30 static unsigned int simd_support = ~0;
31
32 #if defined(__linux__)
33
34 LOCAL(int)
35 parse_proc_cpuinfo(const char* search_string)
36 {
37 const char* file_name = "/proc/cpuinfo";
38 char cpuinfo_line[256];
39 FILE* f = NULL;
40 simd_support = 0;
41
42 if ((f = fopen(file_name, "r")) != NULL) {
43 while (fgets(cpuinfo_line, sizeof(cpuinfo_line), f) != NULL) {
44 if (strstr(cpuinfo_line, search_string) != NULL) {
45 fclose(f);
46 simd_support |= JSIMD_MIPS_DSPR2;
47 return 1;
48 }
49 }
50 fclose(f);
51 }
52 /* Did not find string in the proc file, or not Linux ELF. */
53 return 0;
54 }
55
56 #endif
57
58 /*
59 * Check what SIMD accelerations are supported.
60 *
61 * FIXME: This code is racy under a multi-threaded environment.
62 */
63 LOCAL(void)
64 init_simd (void)
65 {
66 if (simd_support != ~0U)
67 return;
68
69 simd_support = 0;
70
71 #if defined(__MIPSEL__) && defined(__mips_dsp) && (__mips_dsp_rev >= 2)
72 simd_support |= JSIMD_MIPS_DSPR2;
73 #elif defined(__linux__)
74 /* We still have a chance to use MIPS DSPR2 regardless of globally used
75 * -mdspr2 options passed to gcc by performing runtime detection via
76 * /proc/cpuinfo parsing on linux */
77 if (!parse_proc_cpuinfo("MIPS 74K"))
78 return;
79 #endif
80 }
81
82 static const int mips_idct_ifast_coefs[4] = {
83 0x45404540, // FIX( 1.082392200 / 2) = 17734 = 0x4546
84 0x5A805A80, // FIX( 1.414213562 / 2) = 23170 = 0x5A82
85 0x76407640, // FIX( 1.847759065 / 2) = 30274 = 0x7642
86 0xAC60AC60 // FIX(-2.613125930 / 4) = -21407 = 0xAC61
87 };
88
89 /* The following struct is borrowed from jdsample.c */
90 typedef void (*upsample1_ptr) (j_decompress_ptr cinfo,
91 jpeg_component_info *compptr,
92 JSAMPARRAY input_data,
93 JSAMPARRAY *output_data_ptr);
94
95 typedef struct {
96 struct jpeg_upsampler pub;
97 JSAMPARRAY color_buf[MAX_COMPONENTS];
98 upsample1_ptr methods[MAX_COMPONENTS];
99 int next_row_out;
100 JDIMENSION rows_to_go;
101 int rowgroup_height[MAX_COMPONENTS];
102 UINT8 h_expand[MAX_COMPONENTS];
103 UINT8 v_expand[MAX_COMPONENTS];
104 } my_upsampler;
105
106 typedef my_upsampler *my_upsample_ptr;
107
108 GLOBAL(int)
109 jsimd_can_rgb_ycc (void)
110 {
111 init_simd();
112
113 /* The code is optimised for these values only */
114 if (BITS_IN_JSAMPLE != 8)
115 return 0;
116 if (sizeof(JDIMENSION) != 4)
117 return 0;
118 if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4))
119 return 0;
120
121 if (simd_support & JSIMD_MIPS_DSPR2)
122 return 1;
123
124 return 0;
125 }
126
127 GLOBAL(int)
128 jsimd_can_rgb_gray (void)
129 {
130 init_simd();
131
132 /* The code is optimised for these values only */
133 if (BITS_IN_JSAMPLE != 8)
134 return 0;
135 if (sizeof(JDIMENSION) != 4)
136 return 0;
137 if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4))
138 return 0;
139
140 if (simd_support & JSIMD_MIPS_DSPR2)
141 return 1;
142
143 return 0;
144 }
145
146 GLOBAL(int)
147 jsimd_can_ycc_rgb (void)
148 {
149 init_simd();
150
151 /* The code is optimised for these values only */
152 if (BITS_IN_JSAMPLE != 8)
153 return 0;
154 if (sizeof(JDIMENSION) != 4)
155 return 0;
156 if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4))
157 return 0;
158
159 if (simd_support & JSIMD_MIPS_DSPR2)
160 return 1;
161
162 return 0;
163 }
164
165 GLOBAL(int)
166 jsimd_can_ycc_rgb565 (void)
167 {
168 return 0;
169 }
170
171 GLOBAL(int)
172 jsimd_c_can_null_convert (void)
173 {
174 init_simd();
175
176 /* The code is optimised for these values only */
177 if (BITS_IN_JSAMPLE != 8)
178 return 0;
179 if (sizeof(JDIMENSION) != 4)
180 return 0;
181
182 if (simd_support & JSIMD_MIPS_DSPR2)
183 return 1;
184
185 return 0;
186 }
187
188 GLOBAL(void)
189 jsimd_rgb_ycc_convert (j_compress_ptr cinfo,
190 JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
191 JDIMENSION output_row, int num_rows)
192 {
193 void (*mipsdspr2fct)(JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JDIMENSION, int);
194
195 switch(cinfo->in_color_space) {
196 case JCS_EXT_RGB:
197 mipsdspr2fct=jsimd_extrgb_ycc_convert_mips_dspr2;
198 break;
199 case JCS_EXT_RGBX:
200 case JCS_EXT_RGBA:
201 mipsdspr2fct=jsimd_extrgbx_ycc_convert_mips_dspr2;
202 break;
203 case JCS_EXT_BGR:
204 mipsdspr2fct=jsimd_extbgr_ycc_convert_mips_dspr2;
205 break;
206 case JCS_EXT_BGRX:
207 case JCS_EXT_BGRA:
208 mipsdspr2fct=jsimd_extbgrx_ycc_convert_mips_dspr2;
209 break;
210 case JCS_EXT_XBGR:
211 case JCS_EXT_ABGR:
212 mipsdspr2fct=jsimd_extxbgr_ycc_convert_mips_dspr2;
213
214 break;
215 case JCS_EXT_XRGB:
216 case JCS_EXT_ARGB:
217 mipsdspr2fct=jsimd_extxrgb_ycc_convert_mips_dspr2;
218 break;
219 default:
220 mipsdspr2fct=jsimd_extrgb_ycc_convert_mips_dspr2;
221 break;
222 }
223
224 if (simd_support & JSIMD_MIPS_DSPR2)
225 mipsdspr2fct(cinfo->image_width, input_buf, output_buf, output_row,
226 num_rows);
227 }
228
229 GLOBAL(void)
230 jsimd_rgb_gray_convert (j_compress_ptr cinfo,
231 JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
232 JDIMENSION output_row, int num_rows)
233 {
234 void (*mipsdspr2fct)(JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JDIMENSION, int);
235
236 switch(cinfo->in_color_space) {
237 case JCS_EXT_RGB:
238 mipsdspr2fct=jsimd_extrgb_gray_convert_mips_dspr2;
239 break;
240 case JCS_EXT_RGBX:
241 case JCS_EXT_RGBA:
242 mipsdspr2fct=jsimd_extrgbx_gray_convert_mips_dspr2;
243 break;
244 case JCS_EXT_BGR:
245 mipsdspr2fct=jsimd_extbgr_gray_convert_mips_dspr2;
246 break;
247 case JCS_EXT_BGRX:
248 case JCS_EXT_BGRA:
249 mipsdspr2fct=jsimd_extbgrx_gray_convert_mips_dspr2;
250 break;
251 case JCS_EXT_XBGR:
252 case JCS_EXT_ABGR:
253 mipsdspr2fct=jsimd_extxbgr_gray_convert_mips_dspr2;
254 break;
255 case JCS_EXT_XRGB:
256 case JCS_EXT_ARGB:
257 mipsdspr2fct=jsimd_extxrgb_gray_convert_mips_dspr2;
258 break;
259 default:
260 mipsdspr2fct=jsimd_extrgb_gray_convert_mips_dspr2;
261 break;
262 }
263
264 if (simd_support & JSIMD_MIPS_DSPR2)
265 mipsdspr2fct(cinfo->image_width, input_buf, output_buf, output_row,
266 num_rows);
267 }
268
269 GLOBAL(void)
270 jsimd_ycc_rgb_convert (j_decompress_ptr cinfo,
271 JSAMPIMAGE input_buf, JDIMENSION input_row,
272 JSAMPARRAY output_buf, int num_rows)
273 {
274 void (*mipsdspr2fct)(JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY, int);
275
276 switch(cinfo->out_color_space) {
277 case JCS_EXT_RGB:
278 mipsdspr2fct=jsimd_ycc_extrgb_convert_mips_dspr2;
279 break;
280 case JCS_EXT_RGBX:
281 case JCS_EXT_RGBA:
282 mipsdspr2fct=jsimd_ycc_extrgbx_convert_mips_dspr2;
283 break;
284 case JCS_EXT_BGR:
285 mipsdspr2fct=jsimd_ycc_extbgr_convert_mips_dspr2;
286 break;
287 case JCS_EXT_BGRX:
288 case JCS_EXT_BGRA:
289 mipsdspr2fct=jsimd_ycc_extbgrx_convert_mips_dspr2;
290 break;
291 case JCS_EXT_XBGR:
292 case JCS_EXT_ABGR:
293 mipsdspr2fct=jsimd_ycc_extxbgr_convert_mips_dspr2;
294 break;
295 case JCS_EXT_XRGB:
296 case JCS_EXT_ARGB:
297 mipsdspr2fct=jsimd_ycc_extxrgb_convert_mips_dspr2;
298 break;
299 default:
300 mipsdspr2fct=jsimd_ycc_extrgb_convert_mips_dspr2;
301 break;
302 }
303
304 if (simd_support & JSIMD_MIPS_DSPR2)
305 mipsdspr2fct(cinfo->output_width, input_buf, input_row, output_buf,
306 num_rows);
307 }
308
309 GLOBAL(void)
310 jsimd_ycc_rgb565_convert (j_decompress_ptr cinfo,
311 JSAMPIMAGE input_buf, JDIMENSION input_row,
312 JSAMPARRAY output_buf, int num_rows)
313 {
314 }
315
316 GLOBAL(void)
317 jsimd_c_null_convert (j_compress_ptr cinfo,
318 JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
319 JDIMENSION output_row, int num_rows)
320 {
321 if (simd_support & JSIMD_MIPS_DSPR2)
322 jsimd_c_null_convert_mips_dspr2(cinfo->image_width, input_buf,
323 output_buf, output_row, num_rows,
324 cinfo->num_components);
325 }
326
327 GLOBAL(int)
328 jsimd_can_h2v2_downsample (void)
329 {
330 init_simd();
331
332 /* The code is optimised for these values only */
333 if (BITS_IN_JSAMPLE != 8)
334 return 0;
335 if (sizeof(JDIMENSION) != 4)
336 return 0;
337
338 if (simd_support & JSIMD_MIPS_DSPR2)
339 return 1;
340
341 return 0;
342 }
343
344 GLOBAL(int)
345 jsimd_can_h2v2_smooth_downsample (void)
346 {
347 init_simd();
348
349 /* The code is optimised for these values only */
350 if (BITS_IN_JSAMPLE != 8)
351 return 0;
352 if (sizeof(JDIMENSION) != 4)
353 return 0;
354 if(DCTSIZE != 8)
355 return 0;
356
357 if (simd_support & JSIMD_MIPS_DSPR2)
358 return 1;
359
360 return 0;
361 }
362
363 GLOBAL(int)
364 jsimd_can_h2v1_downsample (void)
365 {
366 init_simd();
367
368 /* The code is optimised for these values only */
369 if (BITS_IN_JSAMPLE != 8)
370 return 0;
371 if (sizeof(JDIMENSION) != 4)
372 return 0;
373
374 if (simd_support & JSIMD_MIPS_DSPR2)
375 return 1;
376
377 return 0;
378 }
379
380 GLOBAL(void)
381 jsimd_h2v2_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
382 JSAMPARRAY input_data, JSAMPARRAY output_data)
383 {
384 if (simd_support & JSIMD_MIPS_DSPR2)
385 jsimd_h2v2_downsample_mips_dspr2(cinfo->image_width,
386 cinfo->max_v_samp_factor,
387 compptr->v_samp_factor,
388 compptr->width_in_blocks, input_data,
389 output_data);
390 }
391
392 GLOBAL(void)
393 jsimd_h2v2_smooth_downsample (j_compress_ptr cinfo,
394 jpeg_component_info *compptr,
395 JSAMPARRAY input_data, JSAMPARRAY output_data)
396 {
397 jsimd_h2v2_smooth_downsample_mips_dspr2(input_data, output_data,
398 compptr->v_samp_factor,
399 cinfo->max_v_samp_factor,
400 cinfo->smoothing_factor,
401 compptr->width_in_blocks,
402 cinfo->image_width);
403 }
404
405 GLOBAL(void)
406 jsimd_h2v1_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
407 JSAMPARRAY input_data, JSAMPARRAY output_data)
408 {
409 if (simd_support & JSIMD_MIPS_DSPR2)
410 jsimd_h2v1_downsample_mips_dspr2(cinfo->image_width,
411 cinfo->max_v_samp_factor,
412 compptr->v_samp_factor,
413 compptr->width_in_blocks,
414 input_data, output_data);
415 }
416
417 GLOBAL(int)
418 jsimd_can_h2v2_upsample (void)
419 {
420 init_simd();
421
422 /* The code is optimised for these values only */
423 if (BITS_IN_JSAMPLE != 8)
424 return 0;
425 if (sizeof(JDIMENSION) != 4)
426 return 0;
427
428 if (simd_support & JSIMD_MIPS_DSPR2)
429 return 1;
430
431 return 0;
432 }
433
434 GLOBAL(int)
435 jsimd_can_h2v1_upsample (void)
436 {
437 init_simd();
438
439 /* The code is optimised for these values only */
440 if (BITS_IN_JSAMPLE != 8)
441 return 0;
442 if (sizeof(JDIMENSION) != 4)
443 return 0;
444
445 if (simd_support & JSIMD_MIPS_DSPR2)
446 return 1;
447
448 return 0;
449 }
450
451 GLOBAL(int)
452 jsimd_can_int_upsample (void)
453 {
454 init_simd();
455
456 /* The code is optimised for these values only */
457 if (BITS_IN_JSAMPLE != 8)
458 return 0;
459 if (sizeof(JDIMENSION) != 4)
460 return 0;
461
462 if (simd_support & JSIMD_MIPS_DSPR2)
463 return 1;
464
465 return 0;
466 }
467
468 GLOBAL(void)
469 jsimd_h2v2_upsample (j_decompress_ptr cinfo,
470 jpeg_component_info *compptr,
471 JSAMPARRAY input_data,
472 JSAMPARRAY *output_data_ptr)
473 {
474 if (simd_support & JSIMD_MIPS_DSPR2)
475 jsimd_h2v2_upsample_mips_dspr2(cinfo->max_v_samp_factor,
476 cinfo->output_width, input_data,
477 output_data_ptr);
478 }
479
480 GLOBAL(void)
481 jsimd_h2v1_upsample (j_decompress_ptr cinfo,
482 jpeg_component_info *compptr,
483 JSAMPARRAY input_data,
484 JSAMPARRAY *output_data_ptr)
485 {
486 if (simd_support & JSIMD_MIPS_DSPR2)
487 jsimd_h2v1_upsample_mips_dspr2(cinfo->max_v_samp_factor,
488 cinfo->output_width, input_data,
489 output_data_ptr);
490 }
491
492 GLOBAL(void)
493 jsimd_int_upsample (j_decompress_ptr cinfo, jpeg_component_info *compptr,
494 JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr)
495 {
496 my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
497
498 jsimd_int_upsample_mips_dspr2(upsample->h_expand[compptr->component_index],
499 upsample->v_expand[compptr->component_index],
500 input_data, output_data_ptr,
501 cinfo->output_width,
502 cinfo->max_v_samp_factor);
503 }
504
505 GLOBAL(int)
506 jsimd_can_h2v2_fancy_upsample (void)
507 {
508 init_simd();
509
510 /* The code is optimised for these values only */
511 if (BITS_IN_JSAMPLE != 8)
512 return 0;
513 if (sizeof(JDIMENSION) != 4)
514 return 0;
515
516 if (simd_support & JSIMD_MIPS_DSPR2)
517 return 1;
518
519 return 0;
520 }
521
522 GLOBAL(int)
523 jsimd_can_h2v1_fancy_upsample (void)
524 {
525 init_simd();
526
527 /* The code is optimised for these values only */
528 if (BITS_IN_JSAMPLE != 8)
529 return 0;
530 if (sizeof(JDIMENSION) != 4)
531 return 0;
532
533 if (simd_support & JSIMD_MIPS_DSPR2)
534 return 1;
535
536 return 0;
537 }
538
539 GLOBAL(void)
540 jsimd_h2v2_fancy_upsample (j_decompress_ptr cinfo,
541 jpeg_component_info *compptr,
542 JSAMPARRAY input_data,
543 JSAMPARRAY *output_data_ptr)
544 {
545 if (simd_support & JSIMD_MIPS_DSPR2)
546 jsimd_h2v2_fancy_upsample_mips_dspr2(cinfo->max_v_samp_factor,
547 compptr->downsampled_width,
548 input_data, output_data_ptr);
549 }
550
551 GLOBAL(void)
552 jsimd_h2v1_fancy_upsample (j_decompress_ptr cinfo,
553 jpeg_component_info *compptr,
554 JSAMPARRAY input_data,
555 JSAMPARRAY *output_data_ptr)
556 {
557 if (simd_support & JSIMD_MIPS_DSPR2)
558 jsimd_h2v1_fancy_upsample_mips_dspr2(cinfo->max_v_samp_factor,
559 compptr->downsampled_width,
560 input_data, output_data_ptr);
561 }
562
563 GLOBAL(int)
564 jsimd_can_h2v2_merged_upsample (void)
565 {
566 init_simd();
567
568 if (BITS_IN_JSAMPLE != 8)
569 return 0;
570 if (sizeof(JDIMENSION) != 4)
571 return 0;
572
573 if (simd_support & JSIMD_MIPS_DSPR2)
574 return 1;
575
576 return 0;
577 }
578
579 GLOBAL(int)
580 jsimd_can_h2v1_merged_upsample (void)
581 {
582 init_simd();
583
584 if (BITS_IN_JSAMPLE != 8)
585 return 0;
586 if (sizeof(JDIMENSION) != 4)
587 return 0;
588
589 if (simd_support & JSIMD_MIPS_DSPR2)
590 return 1;
591
592 return 0;
593 }
594
595 GLOBAL(void)
596 jsimd_h2v2_merged_upsample (j_decompress_ptr cinfo,
597 JSAMPIMAGE input_buf,
598 JDIMENSION in_row_group_ctr,
599 JSAMPARRAY output_buf)
600 {
601 void (*mipsdspr2fct)(JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY,
602 JSAMPLE *);
603
604 switch(cinfo->out_color_space) {
605 case JCS_EXT_RGB:
606 mipsdspr2fct=jsimd_h2v2_extrgb_merged_upsample_mips_dspr2;
607 break;
608 case JCS_EXT_RGBX:
609 case JCS_EXT_RGBA:
610 mipsdspr2fct=jsimd_h2v2_extrgbx_merged_upsample_mips_dspr2;
611 break;
612 case JCS_EXT_BGR:
613 mipsdspr2fct=jsimd_h2v2_extbgr_merged_upsample_mips_dspr2;
614 break;
615 case JCS_EXT_BGRX:
616 case JCS_EXT_BGRA:
617 mipsdspr2fct=jsimd_h2v2_extbgrx_merged_upsample_mips_dspr2;
618 break;
619 case JCS_EXT_XBGR:
620 case JCS_EXT_ABGR:
621 mipsdspr2fct=jsimd_h2v2_extxbgr_merged_upsample_mips_dspr2;
622 break;
623 case JCS_EXT_XRGB:
624 case JCS_EXT_ARGB:
625 mipsdspr2fct=jsimd_h2v2_extxrgb_merged_upsample_mips_dspr2;
626 break;
627 default:
628 mipsdspr2fct=jsimd_h2v2_extrgb_merged_upsample_mips_dspr2;
629 break;
630 }
631
632 mipsdspr2fct(cinfo->output_width, input_buf, in_row_group_ctr, output_buf,
633 cinfo->sample_range_limit);
634 }
635
636 GLOBAL(void)
637 jsimd_h2v1_merged_upsample (j_decompress_ptr cinfo,
638 JSAMPIMAGE input_buf,
639 JDIMENSION in_row_group_ctr,
640 JSAMPARRAY output_buf)
641 {
642 void (*mipsdspr2fct)(JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY,
643 JSAMPLE *);
644
645 switch(cinfo->out_color_space) {
646 case JCS_EXT_RGB:
647 mipsdspr2fct=jsimd_h2v1_extrgb_merged_upsample_mips_dspr2;
648 break;
649 case JCS_EXT_RGBX:
650 case JCS_EXT_RGBA:
651 mipsdspr2fct=jsimd_h2v1_extrgbx_merged_upsample_mips_dspr2;
652 break;
653 case JCS_EXT_BGR:
654 mipsdspr2fct=jsimd_h2v1_extbgr_merged_upsample_mips_dspr2;
655 break;
656 case JCS_EXT_BGRX:
657 case JCS_EXT_BGRA:
658 mipsdspr2fct=jsimd_h2v1_extbgrx_merged_upsample_mips_dspr2;
659 break;
660 case JCS_EXT_XBGR:
661 case JCS_EXT_ABGR:
662 mipsdspr2fct=jsimd_h2v1_extxbgr_merged_upsample_mips_dspr2;
663 break;
664 case JCS_EXT_XRGB:
665 case JCS_EXT_ARGB:
666 mipsdspr2fct=jsimd_h2v1_extxrgb_merged_upsample_mips_dspr2;
667 break;
668 default:
669 mipsdspr2fct=jsimd_h2v1_extrgb_merged_upsample_mips_dspr2;
670 break;
671 }
672
673 mipsdspr2fct(cinfo->output_width, input_buf, in_row_group_ctr, output_buf,
674 cinfo->sample_range_limit);
675 }
676
677 GLOBAL(int)
678 jsimd_can_convsamp (void)
679 {
680 init_simd();
681
682 /* The code is optimised for these values only */
683 if (DCTSIZE != 8)
684 return 0;
685 if (BITS_IN_JSAMPLE != 8)
686 return 0;
687 if (sizeof(JDIMENSION) != 4)
688 return 0;
689 if (sizeof(DCTELEM) != 2)
690 return 0;
691
692 if (simd_support & JSIMD_MIPS_DSPR2)
693 return 1;
694
695 return 0;
696 }
697
698 GLOBAL(int)
699 jsimd_can_convsamp_float (void)
700 {
701 init_simd();
702
703 /* The code is optimised for these values only */
704 if (DCTSIZE != 8)
705 return 0;
706 if (sizeof(JCOEF) != 2)
707 return 0;
708 if (BITS_IN_JSAMPLE != 8)
709 return 0;
710 if (sizeof(JDIMENSION) != 4)
711 return 0;
712 if (sizeof(ISLOW_MULT_TYPE) != 2)
713 return 0;
714
715 if (simd_support & JSIMD_MIPS_DSPR2)
716 return 1;
717
718 return 0;
719 }
720
721 GLOBAL(void)
722 jsimd_convsamp (JSAMPARRAY sample_data, JDIMENSION start_col,
723 DCTELEM *workspace)
724 {
725 if (simd_support & JSIMD_MIPS_DSPR2)
726 jsimd_convsamp_mips_dspr2(sample_data, start_col, workspace);
727 }
728
729 GLOBAL(void)
730 jsimd_convsamp_float (JSAMPARRAY sample_data, JDIMENSION start_col,
731 FAST_FLOAT *workspace)
732 {
733 if ((simd_support & JSIMD_MIPS_DSPR2))
734 jsimd_convsamp_float_mips_dspr2(sample_data, start_col, workspace);
735 }
736
737 GLOBAL(int)
738 jsimd_can_fdct_islow (void)
739 {
740 init_simd();
741
742 /* The code is optimised for these values only */
743 if (DCTSIZE != 8)
744 return 0;
745 if (sizeof(DCTELEM) != 2)
746 return 0;
747
748 if (simd_support & JSIMD_MIPS_DSPR2)
749 return 1;
750
751 return 0;
752 }
753
754 GLOBAL(int)
755 jsimd_can_fdct_ifast (void)
756 {
757 init_simd();
758
759 /* The code is optimised for these values only */
760 if (DCTSIZE != 8)
761 return 0;
762 if (sizeof(DCTELEM) != 2)
763 return 0;
764
765 if (simd_support & JSIMD_MIPS_DSPR2)
766 return 1;
767
768 return 0;
769 }
770
771 GLOBAL(int)
772 jsimd_can_fdct_float (void)
773 {
774 init_simd();
775
776 return 0;
777 }
778
779 GLOBAL(void)
780 jsimd_fdct_islow (DCTELEM *data)
781 {
782 if (simd_support & JSIMD_MIPS_DSPR2)
783 jsimd_fdct_islow_mips_dspr2(data);
784 }
785
786 GLOBAL(void)
787 jsimd_fdct_ifast (DCTELEM *data)
788 {
789 if (simd_support & JSIMD_MIPS_DSPR2)
790 jsimd_fdct_ifast_mips_dspr2(data);
791 }
792
793 GLOBAL(void)
794 jsimd_fdct_float (FAST_FLOAT *data)
795 {
796 }
797
798 GLOBAL(int)
799 jsimd_can_quantize (void)
800 {
801 init_simd();
802
803 /* The code is optimised for these values only */
804 if (DCTSIZE != 8)
805 return 0;
806 if (sizeof(JCOEF) != 2)
807 return 0;
808 if (sizeof(DCTELEM) != 2)
809 return 0;
810
811 if (simd_support & JSIMD_MIPS_DSPR2)
812 return 1;
813
814 return 0;
815 }
816
817 GLOBAL(int)
818 jsimd_can_quantize_float (void)
819 {
820 init_simd();
821
822 /* The code is optimised for these values only */
823 if (DCTSIZE != 8)
824 return 0;
825 if (sizeof(JCOEF) != 2)
826 return 0;
827 if (BITS_IN_JSAMPLE != 8)
828 return 0;
829 if (sizeof(JDIMENSION) != 4)
830 return 0;
831 if (sizeof(ISLOW_MULT_TYPE) != 2)
832 return 0;
833
834 if (simd_support & JSIMD_MIPS_DSPR2)
835 return 1;
836
837 return 0;
838 }
839
840 GLOBAL(void)
841 jsimd_quantize (JCOEFPTR coef_block, DCTELEM *divisors,
842 DCTELEM *workspace)
843 {
844 if (simd_support & JSIMD_MIPS_DSPR2)
845 jsimd_quantize_mips_dspr2(coef_block, divisors, workspace);
846 }
847
848 GLOBAL(void)
849 jsimd_quantize_float (JCOEFPTR coef_block, FAST_FLOAT *divisors,
850 FAST_FLOAT *workspace)
851 {
852 if (simd_support & JSIMD_MIPS_DSPR2)
853 jsimd_quantize_float_mips_dspr2(coef_block, divisors, workspace);
854 }
855
856 GLOBAL(int)
857 jsimd_can_idct_2x2 (void)
858 {
859 init_simd();
860
861 /* The code is optimised for these values only */
862 if (DCTSIZE != 8)
863 return 0;
864 if (sizeof(JCOEF) != 2)
865 return 0;
866 if (BITS_IN_JSAMPLE != 8)
867 return 0;
868 if (sizeof(JDIMENSION) != 4)
869 return 0;
870 if (sizeof(ISLOW_MULT_TYPE) != 2)
871 return 0;
872
873 if (simd_support & JSIMD_MIPS_DSPR2)
874 return 1;
875
876 return 0;
877 }
878
879 GLOBAL(int)
880 jsimd_can_idct_4x4 (void)
881 {
882 init_simd();
883
884 /* The code is optimised for these values only */
885 if (DCTSIZE != 8)
886 return 0;
887 if (sizeof(JCOEF) != 2)
888 return 0;
889 if (BITS_IN_JSAMPLE != 8)
890 return 0;
891 if (sizeof(JDIMENSION) != 4)
892 return 0;
893 if (sizeof(ISLOW_MULT_TYPE) != 2)
894 return 0;
895
896 if (simd_support & JSIMD_MIPS_DSPR2)
897 return 1;
898
899 return 0;
900 }
901
902 GLOBAL(int)
903 jsimd_can_idct_6x6 (void)
904 {
905 init_simd();
906
907 /* The code is optimised for these values only */
908 if (DCTSIZE != 8)
909 return 0;
910 if (sizeof(JCOEF) != 2)
911 return 0;
912 if (BITS_IN_JSAMPLE != 8)
913 return 0;
914 if (sizeof(JDIMENSION) != 4)
915 return 0;
916 if (sizeof(ISLOW_MULT_TYPE) != 2)
917 return 0;
918
919 if (simd_support & JSIMD_MIPS_DSPR2)
920 return 1;
921
922 return 0;
923 }
924
925 GLOBAL(int)
926 jsimd_can_idct_12x12 (void)
927 {
928 init_simd();
929
930 if (BITS_IN_JSAMPLE != 8)
931 return 0;
932 if (DCTSIZE != 8)
933 return 0;
934 if (sizeof(JCOEF) != 2)
935 return 0;
936 if (sizeof(JDIMENSION) != 4)
937 return 0;
938 if (sizeof(ISLOW_MULT_TYPE) != 2)
939 return 0;
940
941 if (simd_support & JSIMD_MIPS_DSPR2)
942 return 1;
943
944 return 0;
945 }
946
947 GLOBAL(void)
948 jsimd_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
949 JCOEFPTR coef_block, JSAMPARRAY output_buf,
950 JDIMENSION output_col)
951 {
952 if (simd_support & JSIMD_MIPS_DSPR2)
953 jsimd_idct_2x2_mips_dspr2(compptr->dct_table, coef_block, output_buf,
954 output_col);
955 }
956
957 GLOBAL(void)
958 jsimd_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
959 JCOEFPTR coef_block, JSAMPARRAY output_buf,
960 JDIMENSION output_col)
961 {
962 if (simd_support & JSIMD_MIPS_DSPR2) {
963 int workspace[DCTSIZE*4]; /* buffers data between passes */
964 jsimd_idct_4x4_mips_dspr2(compptr->dct_table, coef_block, output_buf,
965 output_col, workspace);
966 }
967 }
968
969 GLOBAL(void)
970 jsimd_idct_6x6 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
971 JCOEFPTR coef_block, JSAMPARRAY output_buf,
972 JDIMENSION output_col)
973 {
974 if (simd_support & JSIMD_MIPS_DSPR2)
975 jsimd_idct_6x6_mips_dspr2(compptr->dct_table, coef_block, output_buf,
976 output_col);
977 }
978
979 GLOBAL(void)
980 jsimd_idct_12x12 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
981 JCOEFPTR coef_block,
982 JSAMPARRAY output_buf, JDIMENSION output_col)
983 {
984 if (simd_support & JSIMD_MIPS_DSPR2) {
985 int workspace[96];
986 int output[12] = {
987 (int)(output_buf[0] + output_col),
988 (int)(output_buf[1] + output_col),
989 (int)(output_buf[2] + output_col),
990 (int)(output_buf[3] + output_col),
991 (int)(output_buf[4] + output_col),
992 (int)(output_buf[5] + output_col),
993 (int)(output_buf[6] + output_col),
994 (int)(output_buf[7] + output_col),
995 (int)(output_buf[8] + output_col),
996 (int)(output_buf[9] + output_col),
997 (int)(output_buf[10] + output_col),
998 (int)(output_buf[11] + output_col),
999 };
1000 jsimd_idct_12x12_pass1_mips_dspr2(coef_block, compptr->dct_table,
1001 workspace);
1002 jsimd_idct_12x12_pass2_mips_dspr2(workspace, output);
1003 }
1004 }
1005
1006 GLOBAL(int)
1007 jsimd_can_idct_islow (void)
1008 {
1009 init_simd();
1010
1011 /* The code is optimised for these values only */
1012 if (DCTSIZE != 8)
1013 return 0;
1014 if (sizeof(JCOEF) != 2)
1015 return 0;
1016 if (BITS_IN_JSAMPLE != 8)
1017 return 0;
1018 if (sizeof(JDIMENSION) != 4)
1019 return 0;
1020 if (sizeof(ISLOW_MULT_TYPE) != 2)
1021 return 0;
1022
1023 if (simd_support & JSIMD_MIPS_DSPR2)
1024 return 1;
1025
1026 return 0;
1027 }
1028
1029 GLOBAL(int)
1030 jsimd_can_idct_ifast (void)
1031 {
1032 init_simd();
1033
1034 /* The code is optimised for these values only */
1035 if (DCTSIZE != 8)
1036 return 0;
1037 if (sizeof(JCOEF) != 2)
1038 return 0;
1039 if (BITS_IN_JSAMPLE != 8)
1040 return 0;
1041 if (sizeof(JDIMENSION) != 4)
1042 return 0;
1043 if (sizeof(IFAST_MULT_TYPE) != 2)
1044 return 0;
1045 if (IFAST_SCALE_BITS != 2)
1046 return 0;
1047
1048 if (simd_support & JSIMD_MIPS_DSPR2)
1049 return 1;
1050
1051 return 0;
1052 }
1053
1054 GLOBAL(int)
1055 jsimd_can_idct_float (void)
1056 {
1057 init_simd();
1058
1059 return 0;
1060 }
1061
1062 GLOBAL(void)
1063 jsimd_idct_islow (j_decompress_ptr cinfo, jpeg_component_info *compptr,
1064 JCOEFPTR coef_block, JSAMPARRAY output_buf,
1065 JDIMENSION output_col)
1066 {
1067 if (simd_support & JSIMD_MIPS_DSPR2) {
1068 int output[8] = {
1069 (int)(output_buf[0] + output_col),
1070 (int)(output_buf[1] + output_col),
1071 (int)(output_buf[2] + output_col),
1072 (int)(output_buf[3] + output_col),
1073 (int)(output_buf[4] + output_col),
1074 (int)(output_buf[5] + output_col),
1075 (int)(output_buf[6] + output_col),
1076 (int)(output_buf[7] + output_col),
1077 };
1078
1079 jsimd_idct_islow_mips_dspr2(coef_block, compptr->dct_table,
1080 output, IDCT_range_limit(cinfo));
1081 }
1082 }
1083
1084 GLOBAL(void)
1085 jsimd_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info *compptr,
1086 JCOEFPTR coef_block, JSAMPARRAY output_buf,
1087 JDIMENSION output_col)
1088 {
1089 if (simd_support & JSIMD_MIPS_DSPR2) {
1090 JCOEFPTR inptr;
1091 IFAST_MULT_TYPE *quantptr;
1092 DCTELEM workspace[DCTSIZE2]; /* buffers data between passes */
1093
1094 /* Pass 1: process columns from input, store into work array. */
1095
1096 inptr = coef_block;
1097 quantptr = (IFAST_MULT_TYPE *) compptr->dct_table;
1098
1099 jsimd_idct_ifast_cols_mips_dspr2(inptr, quantptr,
1100 workspace, mips_idct_ifast_coefs);
1101
1102 /* Pass 2: process rows from work array, store into output array. */
1103 /* Note that we must descale the results by a factor of 8 == 2**3, */
1104 /* and also undo the PASS1_BITS scaling. */
1105
1106 jsimd_idct_ifast_rows_mips_dspr2(workspace, output_buf,
1107 output_col, mips_idct_ifast_coefs);
1108 }
1109 }
1110
1111 GLOBAL(void)
1112 jsimd_idct_float (j_decompress_ptr cinfo, jpeg_component_info *compptr,
1113 JCOEFPTR coef_block, JSAMPARRAY output_buf,
1114 JDIMENSION output_col)
1115 {
1116 }
1117
1118 GLOBAL(int)
1119 jsimd_can_huff_encode_one_block (void)
1120 {
1121 return 0;
1122 }
1123
1124 GLOBAL(JOCTET*)
1125 jsimd_huff_encode_one_block (void *state, JOCTET *buffer, JCOEFPTR block,
1126 int last_dc_val, c_derived_tbl *dctbl,
1127 c_derived_tbl *actbl)
1128 {
1129 return NULL;
1130 }
OLDNEW
« no previous file with comments | « simd/jsimd_i386.c ('k') | simd/jsimd_mips_dspr2.S » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698