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 | |
| 367 | return 0; |
| 368 | } |
| 369 | |
| 370 | GLOBAL(void) |
| 371 | jsimd_convsamp (JSAMPARRAY sample_data, JDIMENSION start_col, |
| 372 | DCTELEM * workspace) |
| 373 | { |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame^] | 374 | #ifdef WITH_SIMD |
| 375 | if (simd_support & JSIMD_MMX) |
| 376 | jsimd_convsamp_mmx(sample_data, start_col, workspace); |
| 377 | #endif |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 378 | } |
| 379 | |
| 380 | GLOBAL(void) |
| 381 | jsimd_convsamp_float (JSAMPARRAY sample_data, JDIMENSION start_col, |
| 382 | FAST_FLOAT * workspace) |
| 383 | { |
| 384 | } |
| 385 | |
| 386 | GLOBAL(int) |
| 387 | jsimd_can_fdct_islow (void) |
| 388 | { |
| 389 | init_simd(); |
| 390 | |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame^] | 391 | /* The code is optimised for these values only */ |
| 392 | if (DCTSIZE != 8) |
| 393 | return 0; |
| 394 | if (sizeof(DCTELEM) != 2) |
| 395 | return 0; |
| 396 | |
| 397 | if (simd_support & JSIMD_MMX) |
| 398 | return 1; |
| 399 | |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 400 | return 0; |
| 401 | } |
| 402 | |
| 403 | GLOBAL(int) |
| 404 | jsimd_can_fdct_ifast (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_float (void) |
| 422 | { |
| 423 | init_simd(); |
| 424 | |
| 425 | return 0; |
| 426 | } |
| 427 | |
| 428 | GLOBAL(void) |
| 429 | jsimd_fdct_islow (DCTELEM * data) |
| 430 | { |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame^] | 431 | #ifdef WITH_SIMD |
| 432 | if (simd_support & JSIMD_MMX) |
| 433 | jsimd_fdct_islow_mmx(data); |
| 434 | #endif |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 435 | } |
| 436 | |
| 437 | GLOBAL(void) |
| 438 | jsimd_fdct_ifast (DCTELEM * data) |
| 439 | { |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame^] | 440 | #ifdef WITH_SIMD |
| 441 | if (simd_support & JSIMD_MMX) |
| 442 | jsimd_fdct_ifast_mmx(data); |
| 443 | #endif |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 444 | } |
| 445 | |
| 446 | GLOBAL(void) |
| 447 | jsimd_fdct_float (FAST_FLOAT * data) |
| 448 | { |
| 449 | } |
| 450 | |
| 451 | GLOBAL(int) |
| 452 | jsimd_can_quantize (void) |
| 453 | { |
| 454 | init_simd(); |
| 455 | |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame^] | 456 | /* The code is optimised for these values only */ |
| 457 | if (DCTSIZE != 8) |
| 458 | return 0; |
| 459 | if (sizeof(JCOEF) != 2) |
| 460 | return 0; |
| 461 | if (sizeof(DCTELEM) != 2) |
| 462 | return 0; |
| 463 | |
| 464 | if (simd_support & JSIMD_MMX) |
| 465 | return 1; |
| 466 | |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 467 | return 0; |
| 468 | } |
| 469 | |
| 470 | GLOBAL(int) |
| 471 | jsimd_can_quantize_float (void) |
| 472 | { |
| 473 | init_simd(); |
| 474 | |
| 475 | return 0; |
| 476 | } |
| 477 | |
| 478 | GLOBAL(void) |
| 479 | jsimd_quantize (JCOEFPTR coef_block, DCTELEM * divisors, |
| 480 | DCTELEM * workspace) |
| 481 | { |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame^] | 482 | #ifdef WITH_SIMD |
| 483 | if (simd_support & JSIMD_MMX) |
| 484 | jsimd_quantize_mmx(coef_block, divisors, workspace); |
| 485 | #endif |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 486 | } |
| 487 | |
| 488 | GLOBAL(void) |
| 489 | jsimd_quantize_float (JCOEFPTR coef_block, FAST_FLOAT * divisors, |
| 490 | FAST_FLOAT * workspace) |
| 491 | { |
| 492 | } |
| 493 | |
| 494 | GLOBAL(int) |
| 495 | jsimd_can_idct_2x2 (void) |
| 496 | { |
| 497 | init_simd(); |
| 498 | |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame^] | 499 | /* The code is optimised for these values only */ |
| 500 | if (DCTSIZE != 8) |
| 501 | return 0; |
| 502 | if (sizeof(JCOEF) != 2) |
| 503 | return 0; |
| 504 | if (BITS_IN_JSAMPLE != 8) |
| 505 | return 0; |
| 506 | if (sizeof(JDIMENSION) != 4) |
| 507 | return 0; |
| 508 | if (sizeof(ISLOW_MULT_TYPE) != 2) |
| 509 | return 0; |
| 510 | |
| 511 | if (simd_support & JSIMD_MMX) |
| 512 | return 1; |
| 513 | |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 514 | return 0; |
| 515 | } |
| 516 | |
| 517 | GLOBAL(int) |
| 518 | jsimd_can_idct_4x4 (void) |
| 519 | { |
| 520 | init_simd(); |
| 521 | |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame^] | 522 | /* The code is optimised for these values only */ |
| 523 | if (DCTSIZE != 8) |
| 524 | return 0; |
| 525 | if (sizeof(JCOEF) != 2) |
| 526 | return 0; |
| 527 | if (BITS_IN_JSAMPLE != 8) |
| 528 | return 0; |
| 529 | if (sizeof(JDIMENSION) != 4) |
| 530 | return 0; |
| 531 | if (sizeof(ISLOW_MULT_TYPE) != 2) |
| 532 | return 0; |
| 533 | |
| 534 | if (simd_support & JSIMD_MMX) |
| 535 | return 1; |
| 536 | |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 537 | return 0; |
| 538 | } |
| 539 | |
| 540 | GLOBAL(void) |
| 541 | jsimd_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
| 542 | JCOEFPTR coef_block, JSAMPARRAY output_buf, |
| 543 | JDIMENSION output_col) |
| 544 | { |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame^] | 545 | #if WITH_SIMD |
| 546 | if (simd_support & JSIMD_MMX) |
| 547 | jsimd_idct_2x2_mmx(compptr->dct_table, coef_block, output_buf, output_col); |
| 548 | #endif |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 549 | } |
| 550 | |
| 551 | GLOBAL(void) |
| 552 | jsimd_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
| 553 | JCOEFPTR coef_block, JSAMPARRAY output_buf, |
| 554 | JDIMENSION output_col) |
| 555 | { |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame^] | 556 | #if WITH_SIMD |
| 557 | if (simd_support & JSIMD_MMX) |
| 558 | jsimd_idct_4x4_mmx(compptr->dct_table, coef_block, output_buf, output_col); |
| 559 | #endif |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 560 | } |
| 561 | |
| 562 | GLOBAL(int) |
| 563 | jsimd_can_idct_islow (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(int) |
| 586 | jsimd_can_idct_ifast (void) |
| 587 | { |
| 588 | init_simd(); |
| 589 | |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame^] | 590 | /* The code is optimised for these values only */ |
| 591 | if (DCTSIZE != 8) |
| 592 | return 0; |
| 593 | if (sizeof(JCOEF) != 2) |
| 594 | return 0; |
| 595 | if (BITS_IN_JSAMPLE != 8) |
| 596 | return 0; |
| 597 | if (sizeof(JDIMENSION) != 4) |
| 598 | return 0; |
| 599 | if (sizeof(IFAST_MULT_TYPE) != 2) |
| 600 | return 0; |
| 601 | if (IFAST_SCALE_BITS != 2) |
| 602 | return 0; |
| 603 | |
| 604 | if (simd_support & JSIMD_MMX) |
| 605 | return 1; |
| 606 | |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 607 | return 0; |
| 608 | } |
| 609 | |
| 610 | GLOBAL(int) |
| 611 | jsimd_can_idct_float (void) |
| 612 | { |
| 613 | init_simd(); |
| 614 | |
| 615 | return 0; |
| 616 | } |
| 617 | |
| 618 | GLOBAL(void) |
| 619 | jsimd_idct_islow (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
| 620 | JCOEFPTR coef_block, JSAMPARRAY output_buf, |
| 621 | JDIMENSION output_col) |
| 622 | { |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame^] | 623 | #if WITH_SIMD |
| 624 | if (simd_support & JSIMD_MMX) |
| 625 | jsimd_idct_islow_mmx(compptr->dct_table, coef_block, output_buf, output_col); |
| 626 | #endif |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 627 | } |
| 628 | |
| 629 | GLOBAL(void) |
| 630 | jsimd_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
| 631 | JCOEFPTR coef_block, JSAMPARRAY output_buf, |
| 632 | JDIMENSION output_col) |
| 633 | { |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame^] | 634 | #if WITH_SIMD |
| 635 | if (simd_support & JSIMD_MMX) |
| 636 | jsimd_idct_ifast_mmx(compptr->dct_table, coef_block, output_buf, output_col); |
| 637 | #endif |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 638 | } |
| 639 | |
| 640 | GLOBAL(void) |
| 641 | jsimd_idct_float (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
| 642 | JCOEFPTR coef_block, JSAMPARRAY output_buf, |
| 643 | JDIMENSION output_col) |
| 644 | { |
| 645 | } |
| 646 | |