jsimd.c (19897B)
1 /* 2 * jsimd_powerpc.c 3 * 4 * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB 5 * Copyright (C) 2009-2011, 2014-2016, 2018, 2022, D. R. Commander. 6 * Copyright (C) 2015-2016, 2018, 2022, 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 #ifdef __amigaos4__ 18 /* This must be defined first as it re-defines GLOBAL otherwise */ 19 #include <proto/exec.h> 20 #endif 21 22 #define JPEG_INTERNALS 23 #include "../../jinclude.h" 24 #include "../../jpeglib.h" 25 #include "../../jsimd.h" 26 #include "../../jdct.h" 27 #include "../../jsimddct.h" 28 #include "../jsimd.h" 29 30 #include <ctype.h> 31 32 #if defined(__APPLE__) 33 #include <sys/types.h> 34 #include <sys/sysctl.h> 35 #elif defined(__OpenBSD__) 36 #include <sys/param.h> 37 #include <sys/sysctl.h> 38 #include <machine/cpu.h> 39 #elif defined(__FreeBSD__) 40 #include <machine/cpu.h> 41 #include <sys/auxv.h> 42 #endif 43 44 static THREAD_LOCAL unsigned int simd_support = ~0; 45 46 #if !defined(__ALTIVEC__) && (defined(__linux__) || defined(ANDROID) || defined(__ANDROID__)) 47 48 #define SOMEWHAT_SANE_PROC_CPUINFO_SIZE_LIMIT (1024 * 1024) 49 50 LOCAL(int) 51 check_feature(char *buffer, char *feature) 52 { 53 char *p; 54 55 if (*feature == 0) 56 return 0; 57 if (strncmp(buffer, "cpu", 3) != 0) 58 return 0; 59 buffer += 3; 60 while (isspace(*buffer)) 61 buffer++; 62 63 /* Check if 'feature' is present in the buffer as a separate word */ 64 while ((p = strstr(buffer, feature))) { 65 if (p > buffer && !isspace(*(p - 1))) { 66 buffer++; 67 continue; 68 } 69 p += strlen(feature); 70 if (*p != 0 && !isspace(*p)) { 71 buffer++; 72 continue; 73 } 74 return 1; 75 } 76 return 0; 77 } 78 79 LOCAL(int) 80 parse_proc_cpuinfo(int bufsize) 81 { 82 char *buffer = (char *)malloc(bufsize); 83 FILE *fd; 84 85 simd_support = 0; 86 87 if (!buffer) 88 return 0; 89 90 fd = fopen("/proc/cpuinfo", "r"); 91 if (fd) { 92 while (fgets(buffer, bufsize, fd)) { 93 if (!strchr(buffer, '\n') && !feof(fd)) { 94 /* "impossible" happened - insufficient size of the buffer! */ 95 fclose(fd); 96 free(buffer); 97 return 0; 98 } 99 if (check_feature(buffer, "altivec")) 100 simd_support |= JSIMD_ALTIVEC; 101 } 102 fclose(fd); 103 } 104 free(buffer); 105 return 1; 106 } 107 108 #endif 109 110 /* 111 * Check what SIMD accelerations are supported. 112 */ 113 LOCAL(void) 114 init_simd(void) 115 { 116 #ifndef NO_GETENV 117 char *env = NULL; 118 #endif 119 #if !defined(__ALTIVEC__) && (defined(__linux__) || defined(ANDROID) || defined(__ANDROID__)) 120 int bufsize = 1024; /* an initial guess for the line buffer size limit */ 121 #elif defined(__amigaos4__) 122 uint32 altivec = 0; 123 #elif defined(__APPLE__) 124 int mib[2] = { CTL_HW, HW_VECTORUNIT }; 125 int altivec; 126 size_t len = sizeof(altivec); 127 #elif defined(__OpenBSD__) 128 int mib[2] = { CTL_MACHDEP, CPU_ALTIVEC }; 129 int altivec; 130 size_t len = sizeof(altivec); 131 #elif defined(__FreeBSD__) 132 unsigned long cpufeatures = 0; 133 #endif 134 135 if (simd_support != ~0U) 136 return; 137 138 simd_support = 0; 139 140 #if defined(__ALTIVEC__) 141 simd_support |= JSIMD_ALTIVEC; 142 #elif defined(__linux__) || defined(ANDROID) || defined(__ANDROID__) 143 while (!parse_proc_cpuinfo(bufsize)) { 144 bufsize *= 2; 145 if (bufsize > SOMEWHAT_SANE_PROC_CPUINFO_SIZE_LIMIT) 146 break; 147 } 148 #elif defined(__amigaos4__) 149 IExec->GetCPUInfoTags(GCIT_VectorUnit, &altivec, TAG_DONE); 150 if (altivec == VECTORTYPE_ALTIVEC) 151 simd_support |= JSIMD_ALTIVEC; 152 #elif defined(__APPLE__) || defined(__OpenBSD__) 153 if (sysctl(mib, 2, &altivec, &len, NULL, 0) == 0 && altivec != 0) 154 simd_support |= JSIMD_ALTIVEC; 155 #elif defined(__FreeBSD__) 156 elf_aux_info(AT_HWCAP, &cpufeatures, sizeof(cpufeatures)); 157 if (cpufeatures & PPC_FEATURE_HAS_ALTIVEC) 158 simd_support |= JSIMD_ALTIVEC; 159 #endif 160 161 #ifndef NO_GETENV 162 /* Force different settings through environment variables */ 163 env = getenv("JSIMD_FORCEALTIVEC"); 164 if ((env != NULL) && (strcmp(env, "1") == 0)) 165 simd_support = JSIMD_ALTIVEC; 166 env = getenv("JSIMD_FORCENONE"); 167 if ((env != NULL) && (strcmp(env, "1") == 0)) 168 simd_support = 0; 169 #endif 170 } 171 172 GLOBAL(int) 173 jsimd_can_rgb_ycc(void) 174 { 175 init_simd(); 176 177 /* The code is optimised for these values only */ 178 if (BITS_IN_JSAMPLE != 8) 179 return 0; 180 if (sizeof(JDIMENSION) != 4) 181 return 0; 182 if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4)) 183 return 0; 184 185 if (simd_support & JSIMD_ALTIVEC) 186 return 1; 187 188 return 0; 189 } 190 191 GLOBAL(int) 192 jsimd_can_rgb_gray(void) 193 { 194 init_simd(); 195 196 /* The code is optimised for these values only */ 197 if (BITS_IN_JSAMPLE != 8) 198 return 0; 199 if (sizeof(JDIMENSION) != 4) 200 return 0; 201 if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4)) 202 return 0; 203 204 if (simd_support & JSIMD_ALTIVEC) 205 return 1; 206 207 return 0; 208 } 209 210 GLOBAL(int) 211 jsimd_can_ycc_rgb(void) 212 { 213 init_simd(); 214 215 /* The code is optimised for these values only */ 216 if (BITS_IN_JSAMPLE != 8) 217 return 0; 218 if (sizeof(JDIMENSION) != 4) 219 return 0; 220 if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4)) 221 return 0; 222 223 if (simd_support & JSIMD_ALTIVEC) 224 return 1; 225 226 return 0; 227 } 228 229 GLOBAL(int) 230 jsimd_can_ycc_rgb565(void) 231 { 232 return 0; 233 } 234 235 GLOBAL(void) 236 jsimd_rgb_ycc_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf, 237 JSAMPIMAGE output_buf, JDIMENSION output_row, 238 int num_rows) 239 { 240 void (*altivecfct) (JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JDIMENSION, int); 241 242 switch (cinfo->in_color_space) { 243 case JCS_EXT_RGB: 244 altivecfct = jsimd_extrgb_ycc_convert_altivec; 245 break; 246 case JCS_EXT_RGBX: 247 case JCS_EXT_RGBA: 248 altivecfct = jsimd_extrgbx_ycc_convert_altivec; 249 break; 250 case JCS_EXT_BGR: 251 altivecfct = jsimd_extbgr_ycc_convert_altivec; 252 break; 253 case JCS_EXT_BGRX: 254 case JCS_EXT_BGRA: 255 altivecfct = jsimd_extbgrx_ycc_convert_altivec; 256 break; 257 case JCS_EXT_XBGR: 258 case JCS_EXT_ABGR: 259 altivecfct = jsimd_extxbgr_ycc_convert_altivec; 260 break; 261 case JCS_EXT_XRGB: 262 case JCS_EXT_ARGB: 263 altivecfct = jsimd_extxrgb_ycc_convert_altivec; 264 break; 265 default: 266 altivecfct = jsimd_rgb_ycc_convert_altivec; 267 break; 268 } 269 270 altivecfct(cinfo->image_width, input_buf, output_buf, output_row, num_rows); 271 } 272 273 GLOBAL(void) 274 jsimd_rgb_gray_convert(j_compress_ptr cinfo, JSAMPARRAY input_buf, 275 JSAMPIMAGE output_buf, JDIMENSION output_row, 276 int num_rows) 277 { 278 void (*altivecfct) (JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JDIMENSION, int); 279 280 switch (cinfo->in_color_space) { 281 case JCS_EXT_RGB: 282 altivecfct = jsimd_extrgb_gray_convert_altivec; 283 break; 284 case JCS_EXT_RGBX: 285 case JCS_EXT_RGBA: 286 altivecfct = jsimd_extrgbx_gray_convert_altivec; 287 break; 288 case JCS_EXT_BGR: 289 altivecfct = jsimd_extbgr_gray_convert_altivec; 290 break; 291 case JCS_EXT_BGRX: 292 case JCS_EXT_BGRA: 293 altivecfct = jsimd_extbgrx_gray_convert_altivec; 294 break; 295 case JCS_EXT_XBGR: 296 case JCS_EXT_ABGR: 297 altivecfct = jsimd_extxbgr_gray_convert_altivec; 298 break; 299 case JCS_EXT_XRGB: 300 case JCS_EXT_ARGB: 301 altivecfct = jsimd_extxrgb_gray_convert_altivec; 302 break; 303 default: 304 altivecfct = jsimd_rgb_gray_convert_altivec; 305 break; 306 } 307 308 altivecfct(cinfo->image_width, input_buf, output_buf, output_row, num_rows); 309 } 310 311 GLOBAL(void) 312 jsimd_ycc_rgb_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf, 313 JDIMENSION input_row, JSAMPARRAY output_buf, 314 int num_rows) 315 { 316 void (*altivecfct) (JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY, int); 317 318 switch (cinfo->out_color_space) { 319 case JCS_EXT_RGB: 320 altivecfct = jsimd_ycc_extrgb_convert_altivec; 321 break; 322 case JCS_EXT_RGBX: 323 case JCS_EXT_RGBA: 324 altivecfct = jsimd_ycc_extrgbx_convert_altivec; 325 break; 326 case JCS_EXT_BGR: 327 altivecfct = jsimd_ycc_extbgr_convert_altivec; 328 break; 329 case JCS_EXT_BGRX: 330 case JCS_EXT_BGRA: 331 altivecfct = jsimd_ycc_extbgrx_convert_altivec; 332 break; 333 case JCS_EXT_XBGR: 334 case JCS_EXT_ABGR: 335 altivecfct = jsimd_ycc_extxbgr_convert_altivec; 336 break; 337 case JCS_EXT_XRGB: 338 case JCS_EXT_ARGB: 339 altivecfct = jsimd_ycc_extxrgb_convert_altivec; 340 break; 341 default: 342 altivecfct = jsimd_ycc_rgb_convert_altivec; 343 break; 344 } 345 346 altivecfct(cinfo->output_width, input_buf, input_row, output_buf, num_rows); 347 } 348 349 GLOBAL(void) 350 jsimd_ycc_rgb565_convert(j_decompress_ptr cinfo, JSAMPIMAGE input_buf, 351 JDIMENSION input_row, JSAMPARRAY output_buf, 352 int num_rows) 353 { 354 } 355 356 GLOBAL(int) 357 jsimd_can_h2v2_downsample(void) 358 { 359 init_simd(); 360 361 /* The code is optimised for these values only */ 362 if (BITS_IN_JSAMPLE != 8) 363 return 0; 364 if (sizeof(JDIMENSION) != 4) 365 return 0; 366 367 if (simd_support & JSIMD_ALTIVEC) 368 return 1; 369 370 return 0; 371 } 372 373 GLOBAL(int) 374 jsimd_can_h2v1_downsample(void) 375 { 376 init_simd(); 377 378 /* The code is optimised for these values only */ 379 if (BITS_IN_JSAMPLE != 8) 380 return 0; 381 if (sizeof(JDIMENSION) != 4) 382 return 0; 383 384 if (simd_support & JSIMD_ALTIVEC) 385 return 1; 386 387 return 0; 388 } 389 390 GLOBAL(void) 391 jsimd_h2v2_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr, 392 JSAMPARRAY input_data, JSAMPARRAY output_data) 393 { 394 jsimd_h2v2_downsample_altivec(cinfo->image_width, cinfo->max_v_samp_factor, 395 compptr->v_samp_factor, 396 compptr->width_in_blocks, input_data, 397 output_data); 398 } 399 400 GLOBAL(void) 401 jsimd_h2v1_downsample(j_compress_ptr cinfo, jpeg_component_info *compptr, 402 JSAMPARRAY input_data, JSAMPARRAY output_data) 403 { 404 jsimd_h2v1_downsample_altivec(cinfo->image_width, cinfo->max_v_samp_factor, 405 compptr->v_samp_factor, 406 compptr->width_in_blocks, input_data, 407 output_data); 408 } 409 410 GLOBAL(int) 411 jsimd_can_h2v2_upsample(void) 412 { 413 init_simd(); 414 415 /* The code is optimised for these values only */ 416 if (BITS_IN_JSAMPLE != 8) 417 return 0; 418 if (sizeof(JDIMENSION) != 4) 419 return 0; 420 421 if (simd_support & JSIMD_ALTIVEC) 422 return 1; 423 424 return 0; 425 } 426 427 GLOBAL(int) 428 jsimd_can_h2v1_upsample(void) 429 { 430 init_simd(); 431 432 /* The code is optimised for these values only */ 433 if (BITS_IN_JSAMPLE != 8) 434 return 0; 435 if (sizeof(JDIMENSION) != 4) 436 return 0; 437 438 if (simd_support & JSIMD_ALTIVEC) 439 return 1; 440 441 return 0; 442 } 443 444 GLOBAL(void) 445 jsimd_h2v2_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr, 446 JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr) 447 { 448 jsimd_h2v2_upsample_altivec(cinfo->max_v_samp_factor, cinfo->output_width, 449 input_data, output_data_ptr); 450 } 451 452 GLOBAL(void) 453 jsimd_h2v1_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr, 454 JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr) 455 { 456 jsimd_h2v1_upsample_altivec(cinfo->max_v_samp_factor, cinfo->output_width, 457 input_data, output_data_ptr); 458 } 459 460 GLOBAL(int) 461 jsimd_can_h2v2_fancy_upsample(void) 462 { 463 init_simd(); 464 465 /* The code is optimised for these values only */ 466 if (BITS_IN_JSAMPLE != 8) 467 return 0; 468 if (sizeof(JDIMENSION) != 4) 469 return 0; 470 471 if (simd_support & JSIMD_ALTIVEC) 472 return 1; 473 474 return 0; 475 } 476 477 GLOBAL(int) 478 jsimd_can_h2v1_fancy_upsample(void) 479 { 480 init_simd(); 481 482 /* The code is optimised for these values only */ 483 if (BITS_IN_JSAMPLE != 8) 484 return 0; 485 if (sizeof(JDIMENSION) != 4) 486 return 0; 487 488 if (simd_support & JSIMD_ALTIVEC) 489 return 1; 490 491 return 0; 492 } 493 494 GLOBAL(void) 495 jsimd_h2v2_fancy_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr, 496 JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr) 497 { 498 jsimd_h2v2_fancy_upsample_altivec(cinfo->max_v_samp_factor, 499 compptr->downsampled_width, input_data, 500 output_data_ptr); 501 } 502 503 GLOBAL(void) 504 jsimd_h2v1_fancy_upsample(j_decompress_ptr cinfo, jpeg_component_info *compptr, 505 JSAMPARRAY input_data, JSAMPARRAY *output_data_ptr) 506 { 507 jsimd_h2v1_fancy_upsample_altivec(cinfo->max_v_samp_factor, 508 compptr->downsampled_width, input_data, 509 output_data_ptr); 510 } 511 512 GLOBAL(int) 513 jsimd_can_h2v2_merged_upsample(void) 514 { 515 init_simd(); 516 517 /* The code is optimised for these values only */ 518 if (BITS_IN_JSAMPLE != 8) 519 return 0; 520 if (sizeof(JDIMENSION) != 4) 521 return 0; 522 523 if (simd_support & JSIMD_ALTIVEC) 524 return 1; 525 526 return 0; 527 } 528 529 GLOBAL(int) 530 jsimd_can_h2v1_merged_upsample(void) 531 { 532 init_simd(); 533 534 /* The code is optimised for these values only */ 535 if (BITS_IN_JSAMPLE != 8) 536 return 0; 537 if (sizeof(JDIMENSION) != 4) 538 return 0; 539 540 if (simd_support & JSIMD_ALTIVEC) 541 return 1; 542 543 return 0; 544 } 545 546 GLOBAL(void) 547 jsimd_h2v2_merged_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf, 548 JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf) 549 { 550 void (*altivecfct) (JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY); 551 552 switch (cinfo->out_color_space) { 553 case JCS_EXT_RGB: 554 altivecfct = jsimd_h2v2_extrgb_merged_upsample_altivec; 555 break; 556 case JCS_EXT_RGBX: 557 case JCS_EXT_RGBA: 558 altivecfct = jsimd_h2v2_extrgbx_merged_upsample_altivec; 559 break; 560 case JCS_EXT_BGR: 561 altivecfct = jsimd_h2v2_extbgr_merged_upsample_altivec; 562 break; 563 case JCS_EXT_BGRX: 564 case JCS_EXT_BGRA: 565 altivecfct = jsimd_h2v2_extbgrx_merged_upsample_altivec; 566 break; 567 case JCS_EXT_XBGR: 568 case JCS_EXT_ABGR: 569 altivecfct = jsimd_h2v2_extxbgr_merged_upsample_altivec; 570 break; 571 case JCS_EXT_XRGB: 572 case JCS_EXT_ARGB: 573 altivecfct = jsimd_h2v2_extxrgb_merged_upsample_altivec; 574 break; 575 default: 576 altivecfct = jsimd_h2v2_merged_upsample_altivec; 577 break; 578 } 579 580 altivecfct(cinfo->output_width, input_buf, in_row_group_ctr, output_buf); 581 } 582 583 GLOBAL(void) 584 jsimd_h2v1_merged_upsample(j_decompress_ptr cinfo, JSAMPIMAGE input_buf, 585 JDIMENSION in_row_group_ctr, JSAMPARRAY output_buf) 586 { 587 void (*altivecfct) (JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY); 588 589 switch (cinfo->out_color_space) { 590 case JCS_EXT_RGB: 591 altivecfct = jsimd_h2v1_extrgb_merged_upsample_altivec; 592 break; 593 case JCS_EXT_RGBX: 594 case JCS_EXT_RGBA: 595 altivecfct = jsimd_h2v1_extrgbx_merged_upsample_altivec; 596 break; 597 case JCS_EXT_BGR: 598 altivecfct = jsimd_h2v1_extbgr_merged_upsample_altivec; 599 break; 600 case JCS_EXT_BGRX: 601 case JCS_EXT_BGRA: 602 altivecfct = jsimd_h2v1_extbgrx_merged_upsample_altivec; 603 break; 604 case JCS_EXT_XBGR: 605 case JCS_EXT_ABGR: 606 altivecfct = jsimd_h2v1_extxbgr_merged_upsample_altivec; 607 break; 608 case JCS_EXT_XRGB: 609 case JCS_EXT_ARGB: 610 altivecfct = jsimd_h2v1_extxrgb_merged_upsample_altivec; 611 break; 612 default: 613 altivecfct = jsimd_h2v1_merged_upsample_altivec; 614 break; 615 } 616 617 altivecfct(cinfo->output_width, input_buf, in_row_group_ctr, output_buf); 618 } 619 620 GLOBAL(int) 621 jsimd_can_convsamp(void) 622 { 623 init_simd(); 624 625 /* The code is optimised for these values only */ 626 if (DCTSIZE != 8) 627 return 0; 628 if (BITS_IN_JSAMPLE != 8) 629 return 0; 630 if (sizeof(JDIMENSION) != 4) 631 return 0; 632 if (sizeof(DCTELEM) != 2) 633 return 0; 634 635 if (simd_support & JSIMD_ALTIVEC) 636 return 1; 637 638 return 0; 639 } 640 641 GLOBAL(int) 642 jsimd_can_convsamp_float(void) 643 { 644 return 0; 645 } 646 647 GLOBAL(void) 648 jsimd_convsamp(JSAMPARRAY sample_data, JDIMENSION start_col, 649 DCTELEM *workspace) 650 { 651 jsimd_convsamp_altivec(sample_data, start_col, workspace); 652 } 653 654 GLOBAL(void) 655 jsimd_convsamp_float(JSAMPARRAY sample_data, JDIMENSION start_col, 656 FAST_FLOAT *workspace) 657 { 658 } 659 660 GLOBAL(int) 661 jsimd_can_fdct_islow(void) 662 { 663 init_simd(); 664 665 /* The code is optimised for these values only */ 666 if (DCTSIZE != 8) 667 return 0; 668 if (sizeof(DCTELEM) != 2) 669 return 0; 670 671 if (simd_support & JSIMD_ALTIVEC) 672 return 1; 673 674 return 0; 675 } 676 677 GLOBAL(int) 678 jsimd_can_fdct_ifast(void) 679 { 680 init_simd(); 681 682 /* The code is optimised for these values only */ 683 if (DCTSIZE != 8) 684 return 0; 685 if (sizeof(DCTELEM) != 2) 686 return 0; 687 688 if (simd_support & JSIMD_ALTIVEC) 689 return 1; 690 691 return 0; 692 } 693 694 GLOBAL(int) 695 jsimd_can_fdct_float(void) 696 { 697 return 0; 698 } 699 700 GLOBAL(void) 701 jsimd_fdct_islow(DCTELEM *data) 702 { 703 jsimd_fdct_islow_altivec(data); 704 } 705 706 GLOBAL(void) 707 jsimd_fdct_ifast(DCTELEM *data) 708 { 709 jsimd_fdct_ifast_altivec(data); 710 } 711 712 GLOBAL(void) 713 jsimd_fdct_float(FAST_FLOAT *data) 714 { 715 } 716 717 GLOBAL(int) 718 jsimd_can_quantize(void) 719 { 720 init_simd(); 721 722 /* The code is optimised for these values only */ 723 if (DCTSIZE != 8) 724 return 0; 725 if (sizeof(JCOEF) != 2) 726 return 0; 727 if (sizeof(DCTELEM) != 2) 728 return 0; 729 730 if (simd_support & JSIMD_ALTIVEC) 731 return 1; 732 733 return 0; 734 } 735 736 GLOBAL(int) 737 jsimd_can_quantize_float(void) 738 { 739 return 0; 740 } 741 742 GLOBAL(void) 743 jsimd_quantize(JCOEFPTR coef_block, DCTELEM *divisors, DCTELEM *workspace) 744 { 745 jsimd_quantize_altivec(coef_block, divisors, workspace); 746 } 747 748 GLOBAL(void) 749 jsimd_quantize_float(JCOEFPTR coef_block, FAST_FLOAT *divisors, 750 FAST_FLOAT *workspace) 751 { 752 } 753 754 GLOBAL(int) 755 jsimd_can_idct_2x2(void) 756 { 757 return 0; 758 } 759 760 GLOBAL(int) 761 jsimd_can_idct_4x4(void) 762 { 763 return 0; 764 } 765 766 GLOBAL(void) 767 jsimd_idct_2x2(j_decompress_ptr cinfo, jpeg_component_info *compptr, 768 JCOEFPTR coef_block, JSAMPARRAY output_buf, 769 JDIMENSION output_col) 770 { 771 } 772 773 GLOBAL(void) 774 jsimd_idct_4x4(j_decompress_ptr cinfo, jpeg_component_info *compptr, 775 JCOEFPTR coef_block, JSAMPARRAY output_buf, 776 JDIMENSION output_col) 777 { 778 } 779 780 GLOBAL(int) 781 jsimd_can_idct_islow(void) 782 { 783 init_simd(); 784 785 /* The code is optimised for these values only */ 786 if (DCTSIZE != 8) 787 return 0; 788 if (sizeof(JCOEF) != 2) 789 return 0; 790 791 if (simd_support & JSIMD_ALTIVEC) 792 return 1; 793 794 return 0; 795 } 796 797 GLOBAL(int) 798 jsimd_can_idct_ifast(void) 799 { 800 init_simd(); 801 802 /* The code is optimised for these values only */ 803 if (DCTSIZE != 8) 804 return 0; 805 if (sizeof(JCOEF) != 2) 806 return 0; 807 808 if (simd_support & JSIMD_ALTIVEC) 809 return 1; 810 811 return 0; 812 } 813 814 GLOBAL(int) 815 jsimd_can_idct_float(void) 816 { 817 return 0; 818 } 819 820 GLOBAL(void) 821 jsimd_idct_islow(j_decompress_ptr cinfo, jpeg_component_info *compptr, 822 JCOEFPTR coef_block, JSAMPARRAY output_buf, 823 JDIMENSION output_col) 824 { 825 jsimd_idct_islow_altivec(compptr->dct_table, coef_block, output_buf, 826 output_col); 827 } 828 829 GLOBAL(void) 830 jsimd_idct_ifast(j_decompress_ptr cinfo, jpeg_component_info *compptr, 831 JCOEFPTR coef_block, JSAMPARRAY output_buf, 832 JDIMENSION output_col) 833 { 834 jsimd_idct_ifast_altivec(compptr->dct_table, coef_block, output_buf, 835 output_col); 836 } 837 838 GLOBAL(void) 839 jsimd_idct_float(j_decompress_ptr cinfo, jpeg_component_info *compptr, 840 JCOEFPTR coef_block, JSAMPARRAY output_buf, 841 JDIMENSION output_col) 842 { 843 } 844 845 GLOBAL(int) 846 jsimd_can_huff_encode_one_block(void) 847 { 848 return 0; 849 } 850 851 GLOBAL(JOCTET *) 852 jsimd_huff_encode_one_block(void *state, JOCTET *buffer, JCOEFPTR block, 853 int last_dc_val, c_derived_tbl *dctbl, 854 c_derived_tbl *actbl) 855 { 856 return NULL; 857 } 858 859 GLOBAL(int) 860 jsimd_can_encode_mcu_AC_first_prepare(void) 861 { 862 return 0; 863 } 864 865 GLOBAL(void) 866 jsimd_encode_mcu_AC_first_prepare(const JCOEF *block, 867 const int *jpeg_natural_order_start, int Sl, 868 int Al, UJCOEF *values, size_t *zerobits) 869 { 870 } 871 872 GLOBAL(int) 873 jsimd_can_encode_mcu_AC_refine_prepare(void) 874 { 875 return 0; 876 } 877 878 GLOBAL(int) 879 jsimd_encode_mcu_AC_refine_prepare(const JCOEF *block, 880 const int *jpeg_natural_order_start, int Sl, 881 int Al, UJCOEF *absvalues, size_t *bits) 882 { 883 return 0; 884 }