OLD | NEW |
1 /* | 1 /* |
2 * jsimd_arm.c | 2 * jsimd_arm.c |
3 * | 3 * |
4 * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB | 4 * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB |
5 * Copyright 2009-2011 D. R. Commander | 5 * Copyright 2009-2011 D. R. Commander |
6 * | 6 * |
7 * Based on the x86 SIMD extension for IJG JPEG library, | 7 * Based on the x86 SIMD extension for IJG JPEG library, |
8 * Copyright (C) 1999-2006, MIYASAKA Masaru. | 8 * Copyright (C) 1999-2006, MIYASAKA Masaru. |
9 * For conditions of distribution and use, see copyright notice in jsimdext.inc | 9 * For conditions of distribution and use, see copyright notice in jsimdext.inc |
10 * | 10 * |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 env = getenv("JSIMD_FORCE_NO_SIMD"); | 129 env = getenv("JSIMD_FORCE_NO_SIMD"); |
130 if ((env != NULL) && (strcmp(env, "1") == 0)) | 130 if ((env != NULL) && (strcmp(env, "1") == 0)) |
131 simd_support = 0; | 131 simd_support = 0; |
132 } | 132 } |
133 | 133 |
134 GLOBAL(int) | 134 GLOBAL(int) |
135 jsimd_can_rgb_ycc (void) | 135 jsimd_can_rgb_ycc (void) |
136 { | 136 { |
137 init_simd(); | 137 init_simd(); |
138 | 138 |
| 139 /* The code is optimised for these values only */ |
| 140 if (BITS_IN_JSAMPLE != 8) |
| 141 return 0; |
| 142 if (sizeof(JDIMENSION) != 4) |
| 143 return 0; |
| 144 if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4)) |
| 145 return 0; |
| 146 |
| 147 if (simd_support & JSIMD_ARM_NEON) |
| 148 return 1; |
| 149 |
139 return 0; | 150 return 0; |
140 } | 151 } |
141 | 152 |
142 GLOBAL(int) | 153 GLOBAL(int) |
143 jsimd_can_rgb_gray (void) | 154 jsimd_can_rgb_gray (void) |
144 { | 155 { |
145 init_simd(); | 156 init_simd(); |
146 | 157 |
147 return 0; | 158 return 0; |
148 } | 159 } |
(...skipping 14 matching lines...) Expand all Loading... |
163 return 1; | 174 return 1; |
164 | 175 |
165 return 0; | 176 return 0; |
166 } | 177 } |
167 | 178 |
168 GLOBAL(void) | 179 GLOBAL(void) |
169 jsimd_rgb_ycc_convert (j_compress_ptr cinfo, | 180 jsimd_rgb_ycc_convert (j_compress_ptr cinfo, |
170 JSAMPARRAY input_buf, JSAMPIMAGE output_buf, | 181 JSAMPARRAY input_buf, JSAMPIMAGE output_buf, |
171 JDIMENSION output_row, int num_rows) | 182 JDIMENSION output_row, int num_rows) |
172 { | 183 { |
| 184 void (*neonfct)(JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JDIMENSION, int); |
| 185 |
| 186 switch(cinfo->in_color_space) |
| 187 { |
| 188 case JCS_EXT_RGB: |
| 189 neonfct=jsimd_extrgb_ycc_convert_neon; |
| 190 break; |
| 191 case JCS_EXT_RGBX: |
| 192 neonfct=jsimd_extrgbx_ycc_convert_neon; |
| 193 break; |
| 194 case JCS_EXT_BGR: |
| 195 neonfct=jsimd_extbgr_ycc_convert_neon; |
| 196 break; |
| 197 case JCS_EXT_BGRX: |
| 198 neonfct=jsimd_extbgrx_ycc_convert_neon; |
| 199 break; |
| 200 case JCS_EXT_XBGR: |
| 201 neonfct=jsimd_extxbgr_ycc_convert_neon; |
| 202 break; |
| 203 case JCS_EXT_XRGB: |
| 204 neonfct=jsimd_extxrgb_ycc_convert_neon; |
| 205 break; |
| 206 default: |
| 207 neonfct=jsimd_extrgb_ycc_convert_neon; |
| 208 break; |
| 209 } |
| 210 |
| 211 if (simd_support & JSIMD_ARM_NEON) |
| 212 neonfct(cinfo->image_width, input_buf, |
| 213 output_buf, output_row, num_rows); |
173 } | 214 } |
174 | 215 |
175 GLOBAL(void) | 216 GLOBAL(void) |
176 jsimd_rgb_gray_convert (j_compress_ptr cinfo, | 217 jsimd_rgb_gray_convert (j_compress_ptr cinfo, |
177 JSAMPARRAY input_buf, JSAMPIMAGE output_buf, | 218 JSAMPARRAY input_buf, JSAMPIMAGE output_buf, |
178 JDIMENSION output_row, int num_rows) | 219 JDIMENSION output_row, int num_rows) |
179 { | 220 { |
180 } | 221 } |
181 | 222 |
182 GLOBAL(void) | 223 GLOBAL(void) |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 JDIMENSION in_row_group_ctr, | 379 JDIMENSION in_row_group_ctr, |
339 JSAMPARRAY output_buf) | 380 JSAMPARRAY output_buf) |
340 { | 381 { |
341 } | 382 } |
342 | 383 |
343 GLOBAL(int) | 384 GLOBAL(int) |
344 jsimd_can_convsamp (void) | 385 jsimd_can_convsamp (void) |
345 { | 386 { |
346 init_simd(); | 387 init_simd(); |
347 | 388 |
| 389 /* The code is optimised for these values only */ |
| 390 if (DCTSIZE != 8) |
| 391 return 0; |
| 392 if (BITS_IN_JSAMPLE != 8) |
| 393 return 0; |
| 394 if (sizeof(JDIMENSION) != 4) |
| 395 return 0; |
| 396 if (sizeof(DCTELEM) != 2) |
| 397 return 0; |
| 398 |
| 399 if (simd_support & JSIMD_ARM_NEON) |
| 400 return 1; |
| 401 |
348 return 0; | 402 return 0; |
349 } | 403 } |
350 | 404 |
351 GLOBAL(int) | 405 GLOBAL(int) |
352 jsimd_can_convsamp_float (void) | 406 jsimd_can_convsamp_float (void) |
353 { | 407 { |
354 init_simd(); | 408 init_simd(); |
355 | 409 |
356 return 0; | 410 return 0; |
357 } | 411 } |
358 | 412 |
359 GLOBAL(void) | 413 GLOBAL(void) |
360 jsimd_convsamp (JSAMPARRAY sample_data, JDIMENSION start_col, | 414 jsimd_convsamp (JSAMPARRAY sample_data, JDIMENSION start_col, |
361 DCTELEM * workspace) | 415 DCTELEM * workspace) |
362 { | 416 { |
| 417 if (simd_support & JSIMD_ARM_NEON) |
| 418 jsimd_convsamp_neon(sample_data, start_col, workspace); |
363 } | 419 } |
364 | 420 |
365 GLOBAL(void) | 421 GLOBAL(void) |
366 jsimd_convsamp_float (JSAMPARRAY sample_data, JDIMENSION start_col, | 422 jsimd_convsamp_float (JSAMPARRAY sample_data, JDIMENSION start_col, |
367 FAST_FLOAT * workspace) | 423 FAST_FLOAT * workspace) |
368 { | 424 { |
369 } | 425 } |
370 | 426 |
371 GLOBAL(int) | 427 GLOBAL(int) |
372 jsimd_can_fdct_islow (void) | 428 jsimd_can_fdct_islow (void) |
373 { | 429 { |
374 init_simd(); | 430 init_simd(); |
375 | 431 |
376 return 0; | 432 return 0; |
377 } | 433 } |
378 | 434 |
379 GLOBAL(int) | 435 GLOBAL(int) |
380 jsimd_can_fdct_ifast (void) | 436 jsimd_can_fdct_ifast (void) |
381 { | 437 { |
382 init_simd(); | 438 init_simd(); |
383 | 439 |
| 440 /* The code is optimised for these values only */ |
| 441 if (DCTSIZE != 8) |
| 442 return 0; |
| 443 if (sizeof(DCTELEM) != 2) |
| 444 return 0; |
| 445 |
| 446 if (simd_support & JSIMD_ARM_NEON) |
| 447 return 1; |
| 448 |
384 return 0; | 449 return 0; |
385 } | 450 } |
386 | 451 |
387 GLOBAL(int) | 452 GLOBAL(int) |
388 jsimd_can_fdct_float (void) | 453 jsimd_can_fdct_float (void) |
389 { | 454 { |
390 init_simd(); | 455 init_simd(); |
391 | 456 |
392 return 0; | 457 return 0; |
393 } | 458 } |
394 | 459 |
395 GLOBAL(void) | 460 GLOBAL(void) |
396 jsimd_fdct_islow (DCTELEM * data) | 461 jsimd_fdct_islow (DCTELEM * data) |
397 { | 462 { |
398 } | 463 } |
399 | 464 |
400 GLOBAL(void) | 465 GLOBAL(void) |
401 jsimd_fdct_ifast (DCTELEM * data) | 466 jsimd_fdct_ifast (DCTELEM * data) |
402 { | 467 { |
| 468 if (simd_support & JSIMD_ARM_NEON) |
| 469 jsimd_fdct_ifast_neon(data); |
403 } | 470 } |
404 | 471 |
405 GLOBAL(void) | 472 GLOBAL(void) |
406 jsimd_fdct_float (FAST_FLOAT * data) | 473 jsimd_fdct_float (FAST_FLOAT * data) |
407 { | 474 { |
408 } | 475 } |
409 | 476 |
410 GLOBAL(int) | 477 GLOBAL(int) |
411 jsimd_can_quantize (void) | 478 jsimd_can_quantize (void) |
412 { | 479 { |
413 init_simd(); | 480 init_simd(); |
414 | 481 |
| 482 /* The code is optimised for these values only */ |
| 483 if (DCTSIZE != 8) |
| 484 return 0; |
| 485 if (sizeof(JCOEF) != 2) |
| 486 return 0; |
| 487 if (sizeof(DCTELEM) != 2) |
| 488 return 0; |
| 489 |
| 490 if (simd_support & JSIMD_ARM_NEON) |
| 491 return 1; |
| 492 |
415 return 0; | 493 return 0; |
416 } | 494 } |
417 | 495 |
418 GLOBAL(int) | 496 GLOBAL(int) |
419 jsimd_can_quantize_float (void) | 497 jsimd_can_quantize_float (void) |
420 { | 498 { |
421 init_simd(); | 499 init_simd(); |
422 | 500 |
423 return 0; | 501 return 0; |
424 } | 502 } |
425 | 503 |
426 GLOBAL(void) | 504 GLOBAL(void) |
427 jsimd_quantize (JCOEFPTR coef_block, DCTELEM * divisors, | 505 jsimd_quantize (JCOEFPTR coef_block, DCTELEM * divisors, |
428 DCTELEM * workspace) | 506 DCTELEM * workspace) |
429 { | 507 { |
| 508 if (simd_support & JSIMD_ARM_NEON) |
| 509 jsimd_quantize_neon(coef_block, divisors, workspace); |
430 } | 510 } |
431 | 511 |
432 GLOBAL(void) | 512 GLOBAL(void) |
433 jsimd_quantize_float (JCOEFPTR coef_block, FAST_FLOAT * divisors, | 513 jsimd_quantize_float (JCOEFPTR coef_block, FAST_FLOAT * divisors, |
434 FAST_FLOAT * workspace) | 514 FAST_FLOAT * workspace) |
435 { | 515 { |
436 } | 516 } |
437 | 517 |
438 GLOBAL(int) | 518 GLOBAL(int) |
439 jsimd_can_idct_2x2 (void) | 519 jsimd_can_idct_2x2 (void) |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 { | 577 { |
498 if ((simd_support & JSIMD_ARM_NEON)) | 578 if ((simd_support & JSIMD_ARM_NEON)) |
499 jsimd_idct_4x4_neon(compptr->dct_table, coef_block, output_buf, output_col); | 579 jsimd_idct_4x4_neon(compptr->dct_table, coef_block, output_buf, output_col); |
500 } | 580 } |
501 | 581 |
502 GLOBAL(int) | 582 GLOBAL(int) |
503 jsimd_can_idct_islow (void) | 583 jsimd_can_idct_islow (void) |
504 { | 584 { |
505 init_simd(); | 585 init_simd(); |
506 | 586 |
| 587 /* The code is optimised for these values only */ |
| 588 if (DCTSIZE != 8) |
| 589 return 0; |
| 590 if (sizeof(JCOEF) != 2) |
| 591 return 0; |
| 592 if (BITS_IN_JSAMPLE != 8) |
| 593 return 0; |
| 594 if (sizeof(JDIMENSION) != 4) |
| 595 return 0; |
| 596 if (sizeof(ISLOW_MULT_TYPE) != 2) |
| 597 return 0; |
| 598 |
| 599 if (simd_support & JSIMD_ARM_NEON) |
| 600 return 1; |
| 601 |
507 return 0; | 602 return 0; |
508 } | 603 } |
509 | 604 |
510 GLOBAL(int) | 605 GLOBAL(int) |
511 jsimd_can_idct_ifast (void) | 606 jsimd_can_idct_ifast (void) |
512 { | 607 { |
513 init_simd(); | 608 init_simd(); |
514 | 609 |
515 /* The code is optimised for these values only */ | 610 /* The code is optimised for these values only */ |
516 if (DCTSIZE != 8) | 611 if (DCTSIZE != 8) |
(...skipping 21 matching lines...) Expand all Loading... |
538 init_simd(); | 633 init_simd(); |
539 | 634 |
540 return 0; | 635 return 0; |
541 } | 636 } |
542 | 637 |
543 GLOBAL(void) | 638 GLOBAL(void) |
544 jsimd_idct_islow (j_decompress_ptr cinfo, jpeg_component_info * compptr, | 639 jsimd_idct_islow (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
545 JCOEFPTR coef_block, JSAMPARRAY output_buf, | 640 JCOEFPTR coef_block, JSAMPARRAY output_buf, |
546 JDIMENSION output_col) | 641 JDIMENSION output_col) |
547 { | 642 { |
| 643 if ((simd_support & JSIMD_ARM_NEON)) |
| 644 jsimd_idct_islow_neon(compptr->dct_table, coef_block, output_buf, output_col
); |
548 } | 645 } |
549 | 646 |
550 GLOBAL(void) | 647 GLOBAL(void) |
551 jsimd_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr, | 648 jsimd_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
552 JCOEFPTR coef_block, JSAMPARRAY output_buf, | 649 JCOEFPTR coef_block, JSAMPARRAY output_buf, |
553 JDIMENSION output_col) | 650 JDIMENSION output_col) |
554 { | 651 { |
555 if ((simd_support & JSIMD_ARM_NEON)) | 652 if ((simd_support & JSIMD_ARM_NEON)) |
556 jsimd_idct_ifast_neon(compptr->dct_table, coef_block, output_buf, output_col
); | 653 jsimd_idct_ifast_neon(compptr->dct_table, coef_block, output_buf, output_col
); |
557 } | 654 } |
558 | 655 |
559 GLOBAL(void) | 656 GLOBAL(void) |
560 jsimd_idct_float (j_decompress_ptr cinfo, jpeg_component_info * compptr, | 657 jsimd_idct_float (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
561 JCOEFPTR coef_block, JSAMPARRAY output_buf, | 658 JCOEFPTR coef_block, JSAMPARRAY output_buf, |
562 JDIMENSION output_col) | 659 JDIMENSION output_col) |
563 { | 660 { |
564 } | 661 } |
565 | 662 |
OLD | NEW |