Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 1 | /* |
| 2 | * jsimd.c |
| 3 | * |
| 4 | * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB |
| 5 | * |
| 6 | * Based on the x86 SIMD extension for IJG JPEG library, |
| 7 | * Copyright (C) 1999-2006, MIYASAKA Masaru. |
| 8 | * |
| 9 | * This file contains the interface between the "normal" portions |
| 10 | * of the library and the SIMD implementations. |
| 11 | */ |
| 12 | |
| 13 | #define JPEG_INTERNALS |
| 14 | #include "jinclude.h" |
| 15 | #include "jpeglib.h" |
Pierre Ossman | 82c7f31 | 2009-03-09 13:21:27 +0000 | [diff] [blame] | 16 | #include "jsimd.h" |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 17 | #include "jdct.h" |
Pierre Ossman | 82c7f31 | 2009-03-09 13:21:27 +0000 | [diff] [blame] | 18 | #include "jsimddct.h" |
| 19 | #include "simd/jsimd.h" |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 20 | |
| 21 | static unsigned int simd_support = ~0; |
| 22 | |
| 23 | /* |
| 24 | * Check what SIMD accelerations are supported. |
| 25 | * |
| 26 | * FIXME: This code is racy under a multi-threaded environment. |
| 27 | */ |
| 28 | LOCAL(void) |
| 29 | init_simd (void) |
| 30 | { |
| 31 | if (simd_support != ~0) |
| 32 | return; |
| 33 | |
Pierre Ossman | 82c7f31 | 2009-03-09 13:21:27 +0000 | [diff] [blame] | 34 | #ifdef WITH_SIMD |
| 35 | simd_support = jpeg_simd_cpu_support(); |
| 36 | #else |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 37 | simd_support = JSIMD_NONE; |
Pierre Ossman | 82c7f31 | 2009-03-09 13:21:27 +0000 | [diff] [blame] | 38 | #endif |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | GLOBAL(int) |
| 42 | jsimd_can_rgb_ycc (void) |
| 43 | { |
| 44 | init_simd(); |
| 45 | |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 46 | /* The code is optimised for these values only */ |
| 47 | if (BITS_IN_JSAMPLE != 8) |
| 48 | return 0; |
| 49 | if (sizeof(JDIMENSION) != 4) |
| 50 | return 0; |
| 51 | if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4)) |
| 52 | return 0; |
| 53 | |
| 54 | if (simd_support & JSIMD_MMX) |
| 55 | return 1; |
| 56 | |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 57 | return 0; |
| 58 | } |
| 59 | |
| 60 | GLOBAL(int) |
| 61 | jsimd_can_ycc_rgb (void) |
| 62 | { |
| 63 | init_simd(); |
| 64 | |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 65 | /* The code is optimised for these values only */ |
| 66 | if (BITS_IN_JSAMPLE != 8) |
| 67 | return 0; |
| 68 | if (sizeof(JDIMENSION) != 4) |
| 69 | return 0; |
| 70 | if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4)) |
| 71 | return 0; |
| 72 | |
| 73 | if (simd_support & JSIMD_MMX) |
| 74 | return 1; |
| 75 | |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 76 | return 0; |
| 77 | } |
| 78 | |
| 79 | GLOBAL(void) |
| 80 | jsimd_rgb_ycc_convert (j_compress_ptr cinfo, |
| 81 | JSAMPARRAY input_buf, JSAMPIMAGE output_buf, |
| 82 | JDIMENSION output_row, int num_rows) |
| 83 | { |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 84 | #ifdef WITH_SIMD |
| 85 | if (simd_support & JSIMD_MMX) |
| 86 | jsimd_rgb_ycc_convert_mmx(cinfo->image_width, input_buf, |
| 87 | output_buf, output_row, num_rows); |
| 88 | #endif |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 89 | } |
| 90 | |
| 91 | GLOBAL(void) |
| 92 | jsimd_ycc_rgb_convert (j_decompress_ptr cinfo, |
| 93 | JSAMPIMAGE input_buf, JDIMENSION input_row, |
| 94 | JSAMPARRAY output_buf, int num_rows) |
| 95 | { |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 96 | #ifdef WITH_SIMD |
| 97 | if (simd_support & JSIMD_MMX) |
| 98 | jsimd_ycc_rgb_convert_mmx(cinfo->output_width, input_buf, |
| 99 | input_row, output_buf, num_rows); |
| 100 | #endif |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 101 | } |
| 102 | |
| 103 | GLOBAL(int) |
| 104 | jsimd_can_h2v2_downsample (void) |
| 105 | { |
| 106 | init_simd(); |
| 107 | |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 108 | /* The code is optimised for these values only */ |
| 109 | if (BITS_IN_JSAMPLE != 8) |
| 110 | return 0; |
| 111 | if (sizeof(JDIMENSION) != 4) |
| 112 | return 0; |
| 113 | |
| 114 | if (simd_support & JSIMD_MMX) |
| 115 | return 1; |
| 116 | |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 117 | return 0; |
| 118 | } |
| 119 | |
| 120 | GLOBAL(int) |
| 121 | jsimd_can_h2v1_downsample (void) |
| 122 | { |
| 123 | init_simd(); |
| 124 | |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 125 | /* The code is optimised for these values only */ |
| 126 | if (BITS_IN_JSAMPLE != 8) |
| 127 | return 0; |
| 128 | if (sizeof(JDIMENSION) != 4) |
| 129 | return 0; |
| 130 | |
| 131 | if (simd_support & JSIMD_MMX) |
| 132 | return 1; |
| 133 | |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 134 | return 0; |
| 135 | } |
| 136 | |
| 137 | GLOBAL(void) |
| 138 | jsimd_h2v2_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, |
| 139 | JSAMPARRAY input_data, JSAMPARRAY output_data) |
| 140 | { |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 141 | #ifdef WITH_SIMD |
| 142 | if (simd_support & JSIMD_MMX) |
| 143 | jsimd_h2v2_downsample_mmx(cinfo->image_width, cinfo->max_v_samp_factor, |
| 144 | compptr->v_samp_factor, compptr->width_in_blocks, |
| 145 | input_data, output_data); |
| 146 | #endif |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 147 | } |
| 148 | |
| 149 | GLOBAL(void) |
| 150 | jsimd_h2v1_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, |
| 151 | JSAMPARRAY input_data, JSAMPARRAY output_data) |
| 152 | { |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 153 | #ifdef WITH_SIMD |
| 154 | if (simd_support & JSIMD_MMX) |
| 155 | jsimd_h2v1_downsample_mmx(cinfo->image_width, cinfo->max_v_samp_factor, |
| 156 | compptr->v_samp_factor, compptr->width_in_blocks, |
| 157 | input_data, output_data); |
| 158 | #endif |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 159 | } |
| 160 | |
| 161 | GLOBAL(int) |
| 162 | jsimd_can_h2v2_upsample (void) |
| 163 | { |
| 164 | init_simd(); |
| 165 | |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 166 | /* The code is optimised for these values only */ |
| 167 | if (BITS_IN_JSAMPLE != 8) |
| 168 | return 0; |
| 169 | if (sizeof(JDIMENSION) != 4) |
| 170 | return 0; |
| 171 | |
| 172 | if (simd_support & JSIMD_MMX) |
| 173 | return 1; |
| 174 | |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 175 | return 0; |
| 176 | } |
| 177 | |
| 178 | GLOBAL(int) |
| 179 | jsimd_can_h2v1_upsample (void) |
| 180 | { |
| 181 | init_simd(); |
| 182 | |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 183 | /* The code is optimised for these values only */ |
| 184 | if (BITS_IN_JSAMPLE != 8) |
| 185 | return 0; |
| 186 | if (sizeof(JDIMENSION) != 4) |
| 187 | return 0; |
| 188 | |
| 189 | if (simd_support & JSIMD_MMX) |
| 190 | return 1; |
| 191 | |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 192 | return 0; |
| 193 | } |
| 194 | |
| 195 | GLOBAL(void) |
| 196 | jsimd_h2v2_upsample (j_decompress_ptr cinfo, |
| 197 | jpeg_component_info * compptr, |
| 198 | JSAMPARRAY input_data, |
| 199 | JSAMPARRAY * output_data_ptr) |
| 200 | { |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 201 | #ifdef WITH_SIMD |
| 202 | if (simd_support & JSIMD_MMX) |
| 203 | jsimd_h2v2_upsample_mmx(cinfo->max_v_samp_factor, |
| 204 | cinfo->output_width, input_data, output_data_ptr); |
| 205 | #endif |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 206 | } |
| 207 | |
| 208 | GLOBAL(void) |
| 209 | jsimd_h2v1_upsample (j_decompress_ptr cinfo, |
| 210 | jpeg_component_info * compptr, |
| 211 | JSAMPARRAY input_data, |
| 212 | JSAMPARRAY * output_data_ptr) |
| 213 | { |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 214 | #ifdef WITH_SIMD |
| 215 | if (simd_support & JSIMD_MMX) |
| 216 | jsimd_h2v1_upsample_mmx(cinfo->max_v_samp_factor, |
| 217 | cinfo->output_width, input_data, output_data_ptr); |
| 218 | #endif |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 219 | } |
| 220 | |
| 221 | GLOBAL(int) |
| 222 | jsimd_can_h2v2_fancy_upsample (void) |
| 223 | { |
| 224 | init_simd(); |
| 225 | |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 226 | /* The code is optimised for these values only */ |
| 227 | if (BITS_IN_JSAMPLE != 8) |
| 228 | return 0; |
| 229 | if (sizeof(JDIMENSION) != 4) |
| 230 | return 0; |
| 231 | |
| 232 | if (simd_support & JSIMD_MMX) |
| 233 | return 1; |
| 234 | |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 235 | return 0; |
| 236 | } |
| 237 | |
| 238 | GLOBAL(int) |
| 239 | jsimd_can_h2v1_fancy_upsample (void) |
| 240 | { |
| 241 | init_simd(); |
| 242 | |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 243 | /* The code is optimised for these values only */ |
| 244 | if (BITS_IN_JSAMPLE != 8) |
| 245 | return 0; |
| 246 | if (sizeof(JDIMENSION) != 4) |
| 247 | return 0; |
| 248 | |
| 249 | if (simd_support & JSIMD_MMX) |
| 250 | return 1; |
| 251 | |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 252 | return 0; |
| 253 | } |
| 254 | |
| 255 | GLOBAL(void) |
| 256 | jsimd_h2v2_fancy_upsample (j_decompress_ptr cinfo, |
| 257 | jpeg_component_info * compptr, |
| 258 | JSAMPARRAY input_data, |
| 259 | JSAMPARRAY * output_data_ptr) |
| 260 | { |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 261 | #ifdef WITH_SIMD |
| 262 | if (simd_support & JSIMD_MMX) |
| 263 | jsimd_h2v2_fancy_upsample_mmx(cinfo->max_v_samp_factor, |
| 264 | compptr->downsampled_width, input_data, output_data_ptr); |
| 265 | #endif |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 266 | } |
| 267 | |
| 268 | GLOBAL(void) |
| 269 | jsimd_h2v1_fancy_upsample (j_decompress_ptr cinfo, |
| 270 | jpeg_component_info * compptr, |
| 271 | JSAMPARRAY input_data, |
| 272 | JSAMPARRAY * output_data_ptr) |
| 273 | { |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 274 | #ifdef WITH_SIMD |
| 275 | if (simd_support & JSIMD_MMX) |
| 276 | jsimd_h2v1_fancy_upsample_mmx(cinfo->max_v_samp_factor, |
| 277 | compptr->downsampled_width, input_data, output_data_ptr); |
| 278 | #endif |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 279 | } |
| 280 | |
| 281 | GLOBAL(int) |
| 282 | jsimd_can_h2v2_merged_upsample (void) |
| 283 | { |
| 284 | init_simd(); |
| 285 | |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 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_MMX) |
| 293 | return 1; |
| 294 | |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 295 | return 0; |
| 296 | } |
| 297 | |
| 298 | GLOBAL(int) |
| 299 | jsimd_can_h2v1_merged_upsample (void) |
| 300 | { |
| 301 | init_simd(); |
| 302 | |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 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_MMX) |
| 310 | return 1; |
| 311 | |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 312 | return 0; |
| 313 | } |
| 314 | |
| 315 | GLOBAL(void) |
| 316 | jsimd_h2v2_merged_upsample (j_decompress_ptr cinfo, |
| 317 | JSAMPIMAGE input_buf, |
| 318 | JDIMENSION in_row_group_ctr, |
| 319 | JSAMPARRAY output_buf) |
| 320 | { |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 321 | #ifdef WITH_SIMD |
| 322 | if (simd_support & JSIMD_MMX) |
| 323 | jsimd_h2v2_merged_upsample_mmx(cinfo->output_width, input_buf, |
| 324 | in_row_group_ctr, output_buf); |
| 325 | #endif |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 326 | } |
| 327 | |
| 328 | GLOBAL(void) |
| 329 | jsimd_h2v1_merged_upsample (j_decompress_ptr cinfo, |
| 330 | JSAMPIMAGE input_buf, |
| 331 | JDIMENSION in_row_group_ctr, |
| 332 | JSAMPARRAY output_buf) |
| 333 | { |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 334 | #ifdef WITH_SIMD |
| 335 | if (simd_support & JSIMD_MMX) |
| 336 | jsimd_h2v1_merged_upsample_mmx(cinfo->output_width, input_buf, |
| 337 | in_row_group_ctr, output_buf); |
| 338 | #endif |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 339 | } |
| 340 | |
| 341 | GLOBAL(int) |
| 342 | jsimd_can_convsamp (void) |
| 343 | { |
| 344 | init_simd(); |
| 345 | |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 346 | /* The code is optimised for these values only */ |
| 347 | if (DCTSIZE != 8) |
| 348 | return 0; |
| 349 | if (BITS_IN_JSAMPLE != 8) |
| 350 | return 0; |
| 351 | if (sizeof(JDIMENSION) != 4) |
| 352 | return 0; |
| 353 | if (sizeof(DCTELEM) != 2) |
| 354 | return 0; |
| 355 | |
| 356 | if (simd_support & JSIMD_MMX) |
| 357 | return 1; |
| 358 | |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 359 | return 0; |
| 360 | } |
| 361 | |
| 362 | GLOBAL(int) |
| 363 | jsimd_can_convsamp_float (void) |
| 364 | { |
| 365 | init_simd(); |
| 366 | |
Pierre Ossman | 2c2e54b | 2009-03-09 13:28:10 +0000 | [diff] [blame] | 367 | /* The code is optimised for these values only */ |
| 368 | if (DCTSIZE != 8) |
| 369 | return 0; |
| 370 | if (BITS_IN_JSAMPLE != 8) |
| 371 | return 0; |
| 372 | if (sizeof(JDIMENSION) != 4) |
| 373 | return 0; |
| 374 | if (sizeof(FAST_FLOAT) != 4) |
| 375 | return 0; |
| 376 | |
| 377 | if (simd_support & JSIMD_3DNOW) |
| 378 | return 1; |
| 379 | |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 380 | return 0; |
| 381 | } |
| 382 | |
| 383 | GLOBAL(void) |
| 384 | jsimd_convsamp (JSAMPARRAY sample_data, JDIMENSION start_col, |
| 385 | DCTELEM * workspace) |
| 386 | { |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 387 | #ifdef WITH_SIMD |
| 388 | if (simd_support & JSIMD_MMX) |
| 389 | jsimd_convsamp_mmx(sample_data, start_col, workspace); |
| 390 | #endif |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 391 | } |
| 392 | |
| 393 | GLOBAL(void) |
| 394 | jsimd_convsamp_float (JSAMPARRAY sample_data, JDIMENSION start_col, |
| 395 | FAST_FLOAT * workspace) |
| 396 | { |
Pierre Ossman | 2c2e54b | 2009-03-09 13:28:10 +0000 | [diff] [blame] | 397 | #ifdef WITH_SIMD |
| 398 | if (simd_support & JSIMD_3DNOW) |
| 399 | jsimd_convsamp_float_3dnow(sample_data, start_col, workspace); |
| 400 | #endif |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 401 | } |
| 402 | |
| 403 | GLOBAL(int) |
| 404 | jsimd_can_fdct_islow (void) |
| 405 | { |
| 406 | init_simd(); |
| 407 | |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 408 | /* The code is optimised for these values only */ |
| 409 | if (DCTSIZE != 8) |
| 410 | return 0; |
| 411 | if (sizeof(DCTELEM) != 2) |
| 412 | return 0; |
| 413 | |
| 414 | if (simd_support & JSIMD_MMX) |
| 415 | return 1; |
| 416 | |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 417 | return 0; |
| 418 | } |
| 419 | |
| 420 | GLOBAL(int) |
| 421 | jsimd_can_fdct_ifast (void) |
| 422 | { |
| 423 | init_simd(); |
| 424 | |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 425 | /* The code is optimised for these values only */ |
| 426 | if (DCTSIZE != 8) |
| 427 | return 0; |
| 428 | if (sizeof(DCTELEM) != 2) |
| 429 | return 0; |
| 430 | |
| 431 | if (simd_support & JSIMD_MMX) |
| 432 | return 1; |
| 433 | |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 434 | return 0; |
| 435 | } |
| 436 | |
| 437 | GLOBAL(int) |
| 438 | jsimd_can_fdct_float (void) |
| 439 | { |
| 440 | init_simd(); |
| 441 | |
Pierre Ossman | 2c2e54b | 2009-03-09 13:28:10 +0000 | [diff] [blame] | 442 | /* The code is optimised for these values only */ |
| 443 | if (DCTSIZE != 8) |
| 444 | return 0; |
| 445 | if (sizeof(FAST_FLOAT) != 4) |
| 446 | return 0; |
| 447 | |
| 448 | if (simd_support & JSIMD_3DNOW) |
| 449 | return 1; |
| 450 | |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 451 | return 0; |
| 452 | } |
| 453 | |
| 454 | GLOBAL(void) |
| 455 | jsimd_fdct_islow (DCTELEM * data) |
| 456 | { |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 457 | #ifdef WITH_SIMD |
| 458 | if (simd_support & JSIMD_MMX) |
| 459 | jsimd_fdct_islow_mmx(data); |
| 460 | #endif |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 461 | } |
| 462 | |
| 463 | GLOBAL(void) |
| 464 | jsimd_fdct_ifast (DCTELEM * data) |
| 465 | { |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 466 | #ifdef WITH_SIMD |
| 467 | if (simd_support & JSIMD_MMX) |
| 468 | jsimd_fdct_ifast_mmx(data); |
| 469 | #endif |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 470 | } |
| 471 | |
| 472 | GLOBAL(void) |
| 473 | jsimd_fdct_float (FAST_FLOAT * data) |
| 474 | { |
Pierre Ossman | 2c2e54b | 2009-03-09 13:28:10 +0000 | [diff] [blame] | 475 | #ifdef WITH_SIMD |
| 476 | if (simd_support & JSIMD_3DNOW) |
| 477 | jsimd_fdct_float_3dnow(data); |
| 478 | #endif |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 479 | } |
| 480 | |
| 481 | GLOBAL(int) |
| 482 | jsimd_can_quantize (void) |
| 483 | { |
| 484 | init_simd(); |
| 485 | |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 486 | /* The code is optimised for these values only */ |
| 487 | if (DCTSIZE != 8) |
| 488 | return 0; |
| 489 | if (sizeof(JCOEF) != 2) |
| 490 | return 0; |
| 491 | if (sizeof(DCTELEM) != 2) |
| 492 | return 0; |
| 493 | |
| 494 | if (simd_support & JSIMD_MMX) |
| 495 | return 1; |
| 496 | |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 497 | return 0; |
| 498 | } |
| 499 | |
| 500 | GLOBAL(int) |
| 501 | jsimd_can_quantize_float (void) |
| 502 | { |
| 503 | init_simd(); |
| 504 | |
Pierre Ossman | 2c2e54b | 2009-03-09 13:28:10 +0000 | [diff] [blame] | 505 | /* The code is optimised for these values only */ |
| 506 | if (DCTSIZE != 8) |
| 507 | return 0; |
| 508 | if (sizeof(JCOEF) != 2) |
| 509 | return 0; |
| 510 | if (sizeof(FAST_FLOAT) != 4) |
| 511 | return 0; |
| 512 | |
| 513 | if (simd_support & JSIMD_3DNOW) |
| 514 | return 1; |
| 515 | |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 516 | return 0; |
| 517 | } |
| 518 | |
| 519 | GLOBAL(void) |
| 520 | jsimd_quantize (JCOEFPTR coef_block, DCTELEM * divisors, |
| 521 | DCTELEM * workspace) |
| 522 | { |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 523 | #ifdef WITH_SIMD |
| 524 | if (simd_support & JSIMD_MMX) |
| 525 | jsimd_quantize_mmx(coef_block, divisors, workspace); |
| 526 | #endif |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 527 | } |
| 528 | |
| 529 | GLOBAL(void) |
| 530 | jsimd_quantize_float (JCOEFPTR coef_block, FAST_FLOAT * divisors, |
| 531 | FAST_FLOAT * workspace) |
| 532 | { |
Pierre Ossman | 2c2e54b | 2009-03-09 13:28:10 +0000 | [diff] [blame] | 533 | #ifdef WITH_SIMD |
| 534 | if (simd_support & JSIMD_3DNOW) |
| 535 | jsimd_quantize_float_3dnow(coef_block, divisors, workspace); |
| 536 | #endif |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 537 | } |
| 538 | |
| 539 | GLOBAL(int) |
| 540 | jsimd_can_idct_2x2 (void) |
| 541 | { |
| 542 | init_simd(); |
| 543 | |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 544 | /* The code is optimised for these values only */ |
| 545 | if (DCTSIZE != 8) |
| 546 | return 0; |
| 547 | if (sizeof(JCOEF) != 2) |
| 548 | return 0; |
| 549 | if (BITS_IN_JSAMPLE != 8) |
| 550 | return 0; |
| 551 | if (sizeof(JDIMENSION) != 4) |
| 552 | return 0; |
| 553 | if (sizeof(ISLOW_MULT_TYPE) != 2) |
| 554 | return 0; |
| 555 | |
| 556 | if (simd_support & JSIMD_MMX) |
| 557 | return 1; |
| 558 | |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 559 | return 0; |
| 560 | } |
| 561 | |
| 562 | GLOBAL(int) |
| 563 | jsimd_can_idct_4x4 (void) |
| 564 | { |
| 565 | init_simd(); |
| 566 | |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 567 | /* The code is optimised for these values only */ |
| 568 | if (DCTSIZE != 8) |
| 569 | return 0; |
| 570 | if (sizeof(JCOEF) != 2) |
| 571 | return 0; |
| 572 | if (BITS_IN_JSAMPLE != 8) |
| 573 | return 0; |
| 574 | if (sizeof(JDIMENSION) != 4) |
| 575 | return 0; |
| 576 | if (sizeof(ISLOW_MULT_TYPE) != 2) |
| 577 | return 0; |
| 578 | |
| 579 | if (simd_support & JSIMD_MMX) |
| 580 | return 1; |
| 581 | |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 582 | return 0; |
| 583 | } |
| 584 | |
| 585 | GLOBAL(void) |
| 586 | jsimd_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
| 587 | JCOEFPTR coef_block, JSAMPARRAY output_buf, |
| 588 | JDIMENSION output_col) |
| 589 | { |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 590 | #if WITH_SIMD |
| 591 | if (simd_support & JSIMD_MMX) |
| 592 | jsimd_idct_2x2_mmx(compptr->dct_table, coef_block, output_buf, output_col); |
| 593 | #endif |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 594 | } |
| 595 | |
| 596 | GLOBAL(void) |
| 597 | jsimd_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
| 598 | JCOEFPTR coef_block, JSAMPARRAY output_buf, |
| 599 | JDIMENSION output_col) |
| 600 | { |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 601 | #if WITH_SIMD |
| 602 | if (simd_support & JSIMD_MMX) |
| 603 | jsimd_idct_4x4_mmx(compptr->dct_table, coef_block, output_buf, output_col); |
| 604 | #endif |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 605 | } |
| 606 | |
| 607 | GLOBAL(int) |
| 608 | jsimd_can_idct_islow (void) |
| 609 | { |
| 610 | init_simd(); |
| 611 | |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 612 | /* The code is optimised for these values only */ |
| 613 | if (DCTSIZE != 8) |
| 614 | return 0; |
| 615 | if (sizeof(JCOEF) != 2) |
| 616 | return 0; |
| 617 | if (BITS_IN_JSAMPLE != 8) |
| 618 | return 0; |
| 619 | if (sizeof(JDIMENSION) != 4) |
| 620 | return 0; |
| 621 | if (sizeof(ISLOW_MULT_TYPE) != 2) |
| 622 | return 0; |
| 623 | |
| 624 | if (simd_support & JSIMD_MMX) |
| 625 | return 1; |
| 626 | |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 627 | return 0; |
| 628 | } |
| 629 | |
| 630 | GLOBAL(int) |
| 631 | jsimd_can_idct_ifast (void) |
| 632 | { |
| 633 | init_simd(); |
| 634 | |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 635 | /* The code is optimised for these values only */ |
| 636 | if (DCTSIZE != 8) |
| 637 | return 0; |
| 638 | if (sizeof(JCOEF) != 2) |
| 639 | return 0; |
| 640 | if (BITS_IN_JSAMPLE != 8) |
| 641 | return 0; |
| 642 | if (sizeof(JDIMENSION) != 4) |
| 643 | return 0; |
| 644 | if (sizeof(IFAST_MULT_TYPE) != 2) |
| 645 | return 0; |
| 646 | if (IFAST_SCALE_BITS != 2) |
| 647 | return 0; |
| 648 | |
| 649 | if (simd_support & JSIMD_MMX) |
| 650 | return 1; |
| 651 | |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 652 | return 0; |
| 653 | } |
| 654 | |
| 655 | GLOBAL(int) |
| 656 | jsimd_can_idct_float (void) |
| 657 | { |
| 658 | init_simd(); |
| 659 | |
Pierre Ossman | 2c2e54b | 2009-03-09 13:28:10 +0000 | [diff] [blame] | 660 | if (DCTSIZE != 8) |
| 661 | return 0; |
| 662 | if (sizeof(JCOEF) != 2) |
| 663 | return 0; |
| 664 | if (BITS_IN_JSAMPLE != 8) |
| 665 | return 0; |
| 666 | if (sizeof(JDIMENSION) != 4) |
| 667 | return 0; |
| 668 | if (sizeof(FAST_FLOAT) != 4) |
| 669 | return 0; |
| 670 | if (sizeof(FLOAT_MULT_TYPE) != 4) |
| 671 | return 0; |
| 672 | |
| 673 | if (simd_support & JSIMD_3DNOW) |
| 674 | return 1; |
| 675 | |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 676 | return 0; |
| 677 | } |
| 678 | |
| 679 | GLOBAL(void) |
| 680 | jsimd_idct_islow (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
| 681 | JCOEFPTR coef_block, JSAMPARRAY output_buf, |
| 682 | JDIMENSION output_col) |
| 683 | { |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 684 | #if WITH_SIMD |
| 685 | if (simd_support & JSIMD_MMX) |
| 686 | jsimd_idct_islow_mmx(compptr->dct_table, coef_block, output_buf, output_col); |
| 687 | #endif |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 688 | } |
| 689 | |
| 690 | GLOBAL(void) |
| 691 | jsimd_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
| 692 | JCOEFPTR coef_block, JSAMPARRAY output_buf, |
| 693 | JDIMENSION output_col) |
| 694 | { |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 695 | #if WITH_SIMD |
| 696 | if (simd_support & JSIMD_MMX) |
| 697 | jsimd_idct_ifast_mmx(compptr->dct_table, coef_block, output_buf, output_col); |
| 698 | #endif |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 699 | } |
| 700 | |
| 701 | GLOBAL(void) |
| 702 | jsimd_idct_float (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
| 703 | JCOEFPTR coef_block, JSAMPARRAY output_buf, |
| 704 | JDIMENSION output_col) |
| 705 | { |
Pierre Ossman | 2c2e54b | 2009-03-09 13:28:10 +0000 | [diff] [blame] | 706 | #if WITH_SIMD |
| 707 | if (simd_support & JSIMD_3DNOW) |
| 708 | jsimd_idct_float_3dnow(compptr->dct_table, coef_block, |
| 709 | output_buf, output_col); |
| 710 | #endif |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 711 | } |
| 712 | |