DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 1 | /* |
DRC | bf8a5fe | 2014-12-22 01:10:11 +0000 | [diff] [blame] | 2 | * jsimd_powerpc.c |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 3 | * |
| 4 | * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB |
DRC | 52a4ec6 | 2015-01-13 09:02:29 +0000 | [diff] [blame] | 5 | * Copyright 2009-2011, 2014-2015 D. R. Commander |
DRC | f3a8684 | 2016-01-07 00:19:43 -0600 | [diff] [blame] | 6 | * Copyright 2015 Matthieu Darbois |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 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 |
DRC | 2204820 | 2015-01-08 06:18:33 +0000 | [diff] [blame] | 14 | * PowerPC architecture. |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 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 | { |
DRC | 62bae20 | 2014-12-22 13:42:26 +0000 | [diff] [blame] | 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 | |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 59 | return 0; |
| 60 | } |
| 61 | |
| 62 | GLOBAL(int) |
| 63 | jsimd_can_rgb_gray (void) |
| 64 | { |
DRC | b1fec4f | 2014-12-22 14:10:33 +0000 | [diff] [blame] | 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 | |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 78 | return 0; |
| 79 | } |
| 80 | |
| 81 | GLOBAL(int) |
| 82 | jsimd_can_ycc_rgb (void) |
| 83 | { |
DRC | ac4daa7 | 2015-01-10 22:56:26 +0000 | [diff] [blame] | 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 | |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 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 | { |
DRC | 62bae20 | 2014-12-22 13:42:26 +0000 | [diff] [blame] | 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); |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 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 | { |
DRC | b1fec4f | 2014-12-22 14:10:33 +0000 | [diff] [blame] | 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); |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 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 | { |
DRC | ac4daa7 | 2015-01-10 22:56:26 +0000 | [diff] [blame] | 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); |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 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 | { |
DRC | 2204820 | 2015-01-08 06:18:33 +0000 | [diff] [blame] | 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 | |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 241 | return 0; |
| 242 | } |
| 243 | |
| 244 | GLOBAL(int) |
| 245 | jsimd_can_h2v1_downsample (void) |
| 246 | { |
DRC | 2204820 | 2015-01-08 06:18:33 +0000 | [diff] [blame] | 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 | |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 258 | return 0; |
| 259 | } |
| 260 | |
| 261 | GLOBAL(void) |
DRC | bd49803 | 2016-02-19 08:53:33 -0600 | [diff] [blame] | 262 | jsimd_h2v2_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr, |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 263 | JSAMPARRAY input_data, JSAMPARRAY output_data) |
| 264 | { |
DRC | 2204820 | 2015-01-08 06:18:33 +0000 | [diff] [blame] | 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); |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 269 | } |
| 270 | |
| 271 | GLOBAL(void) |
DRC | bd49803 | 2016-02-19 08:53:33 -0600 | [diff] [blame] | 272 | jsimd_h2v1_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr, |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 273 | JSAMPARRAY input_data, JSAMPARRAY output_data) |
| 274 | { |
DRC | 2204820 | 2015-01-08 06:18:33 +0000 | [diff] [blame] | 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); |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 279 | } |
| 280 | |
| 281 | GLOBAL(int) |
| 282 | jsimd_can_h2v2_upsample (void) |
| 283 | { |
DRC | c641cdd | 2015-01-14 15:41:11 +0000 | [diff] [blame] | 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 | |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 295 | return 0; |
| 296 | } |
| 297 | |
| 298 | GLOBAL(int) |
| 299 | jsimd_can_h2v1_upsample (void) |
| 300 | { |
DRC | c641cdd | 2015-01-14 15:41:11 +0000 | [diff] [blame] | 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 | |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 312 | return 0; |
| 313 | } |
| 314 | |
| 315 | GLOBAL(void) |
| 316 | jsimd_h2v2_upsample (j_decompress_ptr cinfo, |
DRC | bd49803 | 2016-02-19 08:53:33 -0600 | [diff] [blame] | 317 | jpeg_component_info *compptr, |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 318 | JSAMPARRAY input_data, |
DRC | bd49803 | 2016-02-19 08:53:33 -0600 | [diff] [blame] | 319 | JSAMPARRAY *output_data_ptr) |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 320 | { |
DRC | c641cdd | 2015-01-14 15:41:11 +0000 | [diff] [blame] | 321 | jsimd_h2v2_upsample_altivec(cinfo->max_v_samp_factor, cinfo->output_width, |
| 322 | input_data, output_data_ptr); |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 323 | } |
| 324 | |
| 325 | GLOBAL(void) |
| 326 | jsimd_h2v1_upsample (j_decompress_ptr cinfo, |
DRC | bd49803 | 2016-02-19 08:53:33 -0600 | [diff] [blame] | 327 | jpeg_component_info *compptr, |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 328 | JSAMPARRAY input_data, |
DRC | bd49803 | 2016-02-19 08:53:33 -0600 | [diff] [blame] | 329 | JSAMPARRAY *output_data_ptr) |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 330 | { |
DRC | c641cdd | 2015-01-14 15:41:11 +0000 | [diff] [blame] | 331 | jsimd_h2v1_upsample_altivec(cinfo->max_v_samp_factor, cinfo->output_width, |
| 332 | input_data, output_data_ptr); |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 333 | } |
| 334 | |
| 335 | GLOBAL(int) |
| 336 | jsimd_can_h2v2_fancy_upsample (void) |
| 337 | { |
DRC | 52a4ec6 | 2015-01-13 09:02:29 +0000 | [diff] [blame] | 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 | |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 349 | return 0; |
| 350 | } |
| 351 | |
| 352 | GLOBAL(int) |
| 353 | jsimd_can_h2v1_fancy_upsample (void) |
| 354 | { |
DRC | 52a4ec6 | 2015-01-13 09:02:29 +0000 | [diff] [blame] | 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 | |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 366 | return 0; |
| 367 | } |
| 368 | |
| 369 | GLOBAL(void) |
| 370 | jsimd_h2v2_fancy_upsample (j_decompress_ptr cinfo, |
DRC | bd49803 | 2016-02-19 08:53:33 -0600 | [diff] [blame] | 371 | jpeg_component_info *compptr, |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 372 | JSAMPARRAY input_data, |
DRC | bd49803 | 2016-02-19 08:53:33 -0600 | [diff] [blame] | 373 | JSAMPARRAY *output_data_ptr) |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 374 | { |
DRC | 52a4ec6 | 2015-01-13 09:02:29 +0000 | [diff] [blame] | 375 | jsimd_h2v2_fancy_upsample_altivec(cinfo->max_v_samp_factor, |
| 376 | compptr->downsampled_width, input_data, |
| 377 | output_data_ptr); |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 378 | } |
| 379 | |
| 380 | GLOBAL(void) |
| 381 | jsimd_h2v1_fancy_upsample (j_decompress_ptr cinfo, |
DRC | bd49803 | 2016-02-19 08:53:33 -0600 | [diff] [blame] | 382 | jpeg_component_info *compptr, |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 383 | JSAMPARRAY input_data, |
DRC | bd49803 | 2016-02-19 08:53:33 -0600 | [diff] [blame] | 384 | JSAMPARRAY *output_data_ptr) |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 385 | { |
DRC | 52a4ec6 | 2015-01-13 09:02:29 +0000 | [diff] [blame] | 386 | jsimd_h2v1_fancy_upsample_altivec(cinfo->max_v_samp_factor, |
| 387 | compptr->downsampled_width, input_data, |
| 388 | output_data_ptr); |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 389 | } |
| 390 | |
| 391 | GLOBAL(int) |
| 392 | jsimd_can_h2v2_merged_upsample (void) |
| 393 | { |
DRC | 86af36a | 2015-01-14 13:27:32 +0000 | [diff] [blame] | 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 | |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 405 | return 0; |
| 406 | } |
| 407 | |
| 408 | GLOBAL(int) |
| 409 | jsimd_can_h2v1_merged_upsample (void) |
| 410 | { |
DRC | 86af36a | 2015-01-14 13:27:32 +0000 | [diff] [blame] | 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 | |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 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 | { |
DRC | 86af36a | 2015-01-14 13:27:32 +0000 | [diff] [blame] | 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); |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 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 | { |
DRC | 86af36a | 2015-01-14 13:27:32 +0000 | [diff] [blame] | 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); |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 501 | } |
| 502 | |
| 503 | GLOBAL(int) |
| 504 | jsimd_can_convsamp (void) |
| 505 | { |
DRC | 577ecd9 | 2014-12-23 04:14:54 +0000 | [diff] [blame] | 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 | |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 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, |
DRC | bd49803 | 2016-02-19 08:53:33 -0600 | [diff] [blame] | 532 | DCTELEM *workspace) |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 533 | { |
DRC | 577ecd9 | 2014-12-23 04:14:54 +0000 | [diff] [blame] | 534 | jsimd_convsamp_altivec(sample_data, start_col, workspace); |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 535 | } |
| 536 | |
| 537 | GLOBAL(void) |
| 538 | jsimd_convsamp_float (JSAMPARRAY sample_data, JDIMENSION start_col, |
DRC | bd49803 | 2016-02-19 08:53:33 -0600 | [diff] [blame] | 539 | FAST_FLOAT *workspace) |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 540 | { |
| 541 | } |
| 542 | |
| 543 | GLOBAL(int) |
| 544 | jsimd_can_fdct_islow (void) |
| 545 | { |
DRC | fb0c394 | 2014-12-17 08:04:39 +0000 | [diff] [blame] | 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 | |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 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) |
DRC | bd49803 | 2016-02-19 08:53:33 -0600 | [diff] [blame] | 584 | jsimd_fdct_islow (DCTELEM *data) |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 585 | { |
DRC | fb0c394 | 2014-12-17 08:04:39 +0000 | [diff] [blame] | 586 | jsimd_fdct_islow_altivec(data); |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 587 | } |
| 588 | |
| 589 | GLOBAL(void) |
DRC | bd49803 | 2016-02-19 08:53:33 -0600 | [diff] [blame] | 590 | jsimd_fdct_ifast (DCTELEM *data) |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 591 | { |
| 592 | jsimd_fdct_ifast_altivec(data); |
| 593 | } |
| 594 | |
| 595 | GLOBAL(void) |
DRC | bd49803 | 2016-02-19 08:53:33 -0600 | [diff] [blame] | 596 | jsimd_fdct_float (FAST_FLOAT *data) |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 597 | { |
| 598 | } |
| 599 | |
| 600 | GLOBAL(int) |
| 601 | jsimd_can_quantize (void) |
| 602 | { |
DRC | 577ecd9 | 2014-12-23 04:14:54 +0000 | [diff] [blame] | 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 | |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 616 | return 0; |
| 617 | } |
| 618 | |
| 619 | GLOBAL(int) |
| 620 | jsimd_can_quantize_float (void) |
| 621 | { |
| 622 | return 0; |
| 623 | } |
| 624 | |
| 625 | GLOBAL(void) |
DRC | bd49803 | 2016-02-19 08:53:33 -0600 | [diff] [blame] | 626 | jsimd_quantize (JCOEFPTR coef_block, DCTELEM *divisors, |
| 627 | DCTELEM *workspace) |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 628 | { |
DRC | 577ecd9 | 2014-12-23 04:14:54 +0000 | [diff] [blame] | 629 | jsimd_quantize_altivec(coef_block, divisors, workspace); |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 630 | } |
| 631 | |
| 632 | GLOBAL(void) |
DRC | bd49803 | 2016-02-19 08:53:33 -0600 | [diff] [blame] | 633 | jsimd_quantize_float (JCOEFPTR coef_block, FAST_FLOAT *divisors, |
| 634 | FAST_FLOAT *workspace) |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 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) |
DRC | bd49803 | 2016-02-19 08:53:33 -0600 | [diff] [blame] | 651 | jsimd_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info *compptr, |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 652 | JCOEFPTR coef_block, JSAMPARRAY output_buf, |
| 653 | JDIMENSION output_col) |
| 654 | { |
| 655 | } |
| 656 | |
| 657 | GLOBAL(void) |
DRC | bd49803 | 2016-02-19 08:53:33 -0600 | [diff] [blame] | 658 | jsimd_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info *compptr, |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 659 | JCOEFPTR coef_block, JSAMPARRAY output_buf, |
| 660 | JDIMENSION output_col) |
| 661 | { |
| 662 | } |
| 663 | |
| 664 | GLOBAL(int) |
| 665 | jsimd_can_idct_islow (void) |
| 666 | { |
DRC | 0691162 | 2014-12-20 01:17:39 +0000 | [diff] [blame] | 667 | init_simd(); |
| 668 | |
| 669 | /* The code is optimised for these values only */ |
| 670 | if (DCTSIZE != 8) |
| 671 | return 0; |
DRC | bf8a5fe | 2014-12-22 01:10:11 +0000 | [diff] [blame] | 672 | if (sizeof(JCOEF) != 2) |
DRC | 0691162 | 2014-12-20 01:17:39 +0000 | [diff] [blame] | 673 | return 0; |
| 674 | |
| 675 | if (simd_support & JSIMD_ALTIVEC) |
| 676 | return 1; |
| 677 | |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 678 | return 0; |
| 679 | } |
| 680 | |
| 681 | GLOBAL(int) |
| 682 | jsimd_can_idct_ifast (void) |
| 683 | { |
DRC | 6cb7f40 | 2014-12-18 10:12:29 +0000 | [diff] [blame] | 684 | init_simd(); |
| 685 | |
| 686 | /* The code is optimised for these values only */ |
| 687 | if (DCTSIZE != 8) |
| 688 | return 0; |
DRC | bf8a5fe | 2014-12-22 01:10:11 +0000 | [diff] [blame] | 689 | if (sizeof(JCOEF) != 2) |
DRC | 6cb7f40 | 2014-12-18 10:12:29 +0000 | [diff] [blame] | 690 | return 0; |
| 691 | |
| 692 | if (simd_support & JSIMD_ALTIVEC) |
| 693 | return 1; |
| 694 | |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 695 | return 0; |
| 696 | } |
| 697 | |
| 698 | GLOBAL(int) |
| 699 | jsimd_can_idct_float (void) |
| 700 | { |
| 701 | return 0; |
| 702 | } |
| 703 | |
| 704 | GLOBAL(void) |
DRC | bd49803 | 2016-02-19 08:53:33 -0600 | [diff] [blame] | 705 | jsimd_idct_islow (j_decompress_ptr cinfo, jpeg_component_info *compptr, |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 706 | JCOEFPTR coef_block, JSAMPARRAY output_buf, |
| 707 | JDIMENSION output_col) |
| 708 | { |
DRC | 0691162 | 2014-12-20 01:17:39 +0000 | [diff] [blame] | 709 | jsimd_idct_islow_altivec(compptr->dct_table, coef_block, output_buf, |
| 710 | output_col); |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 711 | } |
| 712 | |
| 713 | GLOBAL(void) |
DRC | bd49803 | 2016-02-19 08:53:33 -0600 | [diff] [blame] | 714 | jsimd_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info *compptr, |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 715 | JCOEFPTR coef_block, JSAMPARRAY output_buf, |
| 716 | JDIMENSION output_col) |
| 717 | { |
DRC | 6cb7f40 | 2014-12-18 10:12:29 +0000 | [diff] [blame] | 718 | jsimd_idct_ifast_altivec(compptr->dct_table, coef_block, output_buf, |
| 719 | output_col); |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 720 | } |
| 721 | |
| 722 | GLOBAL(void) |
DRC | bd49803 | 2016-02-19 08:53:33 -0600 | [diff] [blame] | 723 | jsimd_idct_float (j_decompress_ptr cinfo, jpeg_component_info *compptr, |
DRC | cd2d8e1 | 2014-09-05 06:33:42 +0000 | [diff] [blame] | 724 | JCOEFPTR coef_block, JSAMPARRAY output_buf, |
| 725 | JDIMENSION output_col) |
| 726 | { |
| 727 | } |
DRC | f3a8684 | 2016-01-07 00:19:43 -0600 | [diff] [blame] | 728 | |
| 729 | GLOBAL(int) |
| 730 | jsimd_can_huff_encode_one_block (void) |
| 731 | { |
| 732 | return 0; |
| 733 | } |
| 734 | |
| 735 | GLOBAL(JOCTET*) |
DRC | bd49803 | 2016-02-19 08:53:33 -0600 | [diff] [blame] | 736 | jsimd_huff_encode_one_block (void *state, JOCTET *buffer, JCOEFPTR block, |
DRC | f3a8684 | 2016-01-07 00:19:43 -0600 | [diff] [blame] | 737 | int last_dc_val, c_derived_tbl *dctbl, |
| 738 | c_derived_tbl *actbl) |
| 739 | { |
| 740 | return NULL; |
| 741 | } |