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 | |
Pierre Ossman | 0d37c57 | 2009-03-09 13:31:56 +0000 | [diff] [blame] | 21 | /* |
| 22 | * In the PIC cases, we have no guarantee that constants will keep |
| 23 | * their alignment. This macro allows us to verify it at runtime. |
| 24 | */ |
| 25 | #ifdef WITH_SIMD |
| 26 | #define IS_ALIGNED(ptr, order) (((unsigned)ptr & ((1 << order) - 1)) == 0) |
| 27 | #else |
| 28 | #define IS_ALIGNED(ptr, order) (0) |
| 29 | #endif |
| 30 | |
| 31 | #define IS_ALIGNED_SSE(ptr) (IS_ALIGNED(ptr, 4)) /* 16 byte alignment */ |
| 32 | |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 33 | static unsigned int simd_support = ~0; |
| 34 | |
| 35 | /* |
| 36 | * Check what SIMD accelerations are supported. |
| 37 | * |
| 38 | * FIXME: This code is racy under a multi-threaded environment. |
| 39 | */ |
| 40 | LOCAL(void) |
| 41 | init_simd (void) |
| 42 | { |
DRC | bec58d8 | 2009-04-03 11:27:17 +0000 | [diff] [blame^] | 43 | #ifdef WITH_SIMD |
| 44 | char *env = NULL; |
| 45 | #endif |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 46 | if (simd_support != ~0) |
| 47 | return; |
| 48 | |
Pierre Ossman | 82c7f31 | 2009-03-09 13:21:27 +0000 | [diff] [blame] | 49 | #ifdef WITH_SIMD |
| 50 | simd_support = jpeg_simd_cpu_support(); |
DRC | bec58d8 | 2009-04-03 11:27:17 +0000 | [diff] [blame^] | 51 | if((env=getenv("JSIMD_FORCEMMX"))!=NULL && !strcmp(env, "1")) |
| 52 | simd_support = JSIMD_MMX; |
| 53 | else if((env=getenv("JSIMD_FORCESSE2"))!=NULL && !strcmp(env, "1")) |
| 54 | simd_support = JSIMD_SSE2; |
Pierre Ossman | 82c7f31 | 2009-03-09 13:21:27 +0000 | [diff] [blame] | 55 | #else |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 56 | simd_support = JSIMD_NONE; |
Pierre Ossman | 82c7f31 | 2009-03-09 13:21:27 +0000 | [diff] [blame] | 57 | #endif |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | GLOBAL(int) |
| 61 | jsimd_can_rgb_ycc (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 | |
Pierre Ossman | 7469386 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 73 | if ((simd_support & JSIMD_SSE2) && |
| 74 | IS_ALIGNED_SSE(jconst_rgb_ycc_convert_sse2)) |
| 75 | return 1; |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 76 | if (simd_support & JSIMD_MMX) |
| 77 | return 1; |
| 78 | |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 79 | return 0; |
| 80 | } |
| 81 | |
| 82 | GLOBAL(int) |
| 83 | jsimd_can_ycc_rgb (void) |
| 84 | { |
| 85 | init_simd(); |
| 86 | |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 87 | /* The code is optimised for these values only */ |
| 88 | if (BITS_IN_JSAMPLE != 8) |
| 89 | return 0; |
| 90 | if (sizeof(JDIMENSION) != 4) |
| 91 | return 0; |
| 92 | if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4)) |
| 93 | return 0; |
| 94 | |
Pierre Ossman | 7469386 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 95 | if ((simd_support & JSIMD_SSE2) && |
| 96 | IS_ALIGNED_SSE(jconst_ycc_rgb_convert_sse2)) |
| 97 | return 1; |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 98 | if (simd_support & JSIMD_MMX) |
| 99 | return 1; |
| 100 | |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 101 | return 0; |
| 102 | } |
| 103 | |
| 104 | GLOBAL(void) |
| 105 | jsimd_rgb_ycc_convert (j_compress_ptr cinfo, |
| 106 | JSAMPARRAY input_buf, JSAMPIMAGE output_buf, |
| 107 | JDIMENSION output_row, int num_rows) |
| 108 | { |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 109 | #ifdef WITH_SIMD |
Pierre Ossman | 7469386 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 110 | if ((simd_support & JSIMD_SSE2) && |
| 111 | IS_ALIGNED_SSE(jconst_rgb_ycc_convert_sse2)) |
| 112 | jsimd_rgb_ycc_convert_sse2(cinfo->image_width, input_buf, |
| 113 | output_buf, output_row, num_rows); |
| 114 | else if (simd_support & JSIMD_MMX) |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 115 | jsimd_rgb_ycc_convert_mmx(cinfo->image_width, input_buf, |
| 116 | output_buf, output_row, num_rows); |
| 117 | #endif |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 118 | } |
| 119 | |
| 120 | GLOBAL(void) |
| 121 | jsimd_ycc_rgb_convert (j_decompress_ptr cinfo, |
| 122 | JSAMPIMAGE input_buf, JDIMENSION input_row, |
| 123 | JSAMPARRAY output_buf, int num_rows) |
| 124 | { |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 125 | #ifdef WITH_SIMD |
Pierre Ossman | 7469386 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 126 | if ((simd_support & JSIMD_SSE2) && |
| 127 | IS_ALIGNED_SSE(jconst_ycc_rgb_convert_sse2)) |
| 128 | jsimd_ycc_rgb_convert_sse2(cinfo->output_width, input_buf, |
| 129 | input_row, output_buf, num_rows); |
| 130 | else if (simd_support & JSIMD_MMX) |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 131 | jsimd_ycc_rgb_convert_mmx(cinfo->output_width, input_buf, |
| 132 | input_row, output_buf, num_rows); |
| 133 | #endif |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 134 | } |
| 135 | |
| 136 | GLOBAL(int) |
| 137 | jsimd_can_h2v2_downsample (void) |
| 138 | { |
| 139 | init_simd(); |
| 140 | |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 141 | /* The code is optimised for these values only */ |
| 142 | if (BITS_IN_JSAMPLE != 8) |
| 143 | return 0; |
| 144 | if (sizeof(JDIMENSION) != 4) |
| 145 | return 0; |
| 146 | |
Pierre Ossman | 7469386 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 147 | if (simd_support & JSIMD_SSE2) |
| 148 | return 1; |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 149 | if (simd_support & JSIMD_MMX) |
| 150 | return 1; |
| 151 | |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 152 | return 0; |
| 153 | } |
| 154 | |
| 155 | GLOBAL(int) |
| 156 | jsimd_can_h2v1_downsample (void) |
| 157 | { |
| 158 | init_simd(); |
| 159 | |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 160 | /* The code is optimised for these values only */ |
| 161 | if (BITS_IN_JSAMPLE != 8) |
| 162 | return 0; |
| 163 | if (sizeof(JDIMENSION) != 4) |
| 164 | return 0; |
| 165 | |
Pierre Ossman | 7469386 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 166 | if (simd_support & JSIMD_SSE2) |
| 167 | return 1; |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 168 | if (simd_support & JSIMD_MMX) |
| 169 | return 1; |
| 170 | |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 171 | return 0; |
| 172 | } |
| 173 | |
| 174 | GLOBAL(void) |
| 175 | jsimd_h2v2_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, |
| 176 | JSAMPARRAY input_data, JSAMPARRAY output_data) |
| 177 | { |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 178 | #ifdef WITH_SIMD |
Pierre Ossman | 7469386 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 179 | if (simd_support & JSIMD_SSE2) |
| 180 | jsimd_h2v2_downsample_sse2(cinfo->image_width, cinfo->max_v_samp_factor, |
| 181 | compptr->v_samp_factor, compptr->width_in_blocks, |
| 182 | input_data, output_data); |
| 183 | else if (simd_support & JSIMD_MMX) |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 184 | jsimd_h2v2_downsample_mmx(cinfo->image_width, cinfo->max_v_samp_factor, |
| 185 | compptr->v_samp_factor, compptr->width_in_blocks, |
| 186 | input_data, output_data); |
| 187 | #endif |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 188 | } |
| 189 | |
| 190 | GLOBAL(void) |
| 191 | jsimd_h2v1_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, |
| 192 | JSAMPARRAY input_data, JSAMPARRAY output_data) |
| 193 | { |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 194 | #ifdef WITH_SIMD |
Pierre Ossman | 7469386 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 195 | if (simd_support & JSIMD_SSE2) |
| 196 | jsimd_h2v1_downsample_sse2(cinfo->image_width, cinfo->max_v_samp_factor, |
| 197 | compptr->v_samp_factor, compptr->width_in_blocks, |
| 198 | input_data, output_data); |
| 199 | else if (simd_support & JSIMD_MMX) |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 200 | jsimd_h2v1_downsample_mmx(cinfo->image_width, cinfo->max_v_samp_factor, |
| 201 | compptr->v_samp_factor, compptr->width_in_blocks, |
| 202 | input_data, output_data); |
| 203 | #endif |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 204 | } |
| 205 | |
| 206 | GLOBAL(int) |
| 207 | jsimd_can_h2v2_upsample (void) |
| 208 | { |
| 209 | init_simd(); |
| 210 | |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 211 | /* The code is optimised for these values only */ |
| 212 | if (BITS_IN_JSAMPLE != 8) |
| 213 | return 0; |
| 214 | if (sizeof(JDIMENSION) != 4) |
| 215 | return 0; |
| 216 | |
Pierre Ossman | 7469386 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 217 | if (simd_support & JSIMD_SSE2) |
| 218 | return 1; |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 219 | if (simd_support & JSIMD_MMX) |
| 220 | return 1; |
| 221 | |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 222 | return 0; |
| 223 | } |
| 224 | |
| 225 | GLOBAL(int) |
| 226 | jsimd_can_h2v1_upsample (void) |
| 227 | { |
| 228 | init_simd(); |
| 229 | |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 230 | /* The code is optimised for these values only */ |
| 231 | if (BITS_IN_JSAMPLE != 8) |
| 232 | return 0; |
| 233 | if (sizeof(JDIMENSION) != 4) |
| 234 | return 0; |
| 235 | |
Pierre Ossman | 7469386 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 236 | if (simd_support & JSIMD_SSE2) |
| 237 | return 1; |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 238 | if (simd_support & JSIMD_MMX) |
| 239 | return 1; |
| 240 | |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 241 | return 0; |
| 242 | } |
| 243 | |
| 244 | GLOBAL(void) |
| 245 | jsimd_h2v2_upsample (j_decompress_ptr cinfo, |
| 246 | jpeg_component_info * compptr, |
| 247 | JSAMPARRAY input_data, |
| 248 | JSAMPARRAY * output_data_ptr) |
| 249 | { |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 250 | #ifdef WITH_SIMD |
Pierre Ossman | 7469386 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 251 | if (simd_support & JSIMD_SSE2) |
| 252 | jsimd_h2v2_upsample_sse2(cinfo->max_v_samp_factor, |
| 253 | cinfo->output_width, input_data, output_data_ptr); |
| 254 | else if (simd_support & JSIMD_MMX) |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 255 | jsimd_h2v2_upsample_mmx(cinfo->max_v_samp_factor, |
| 256 | cinfo->output_width, input_data, output_data_ptr); |
| 257 | #endif |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 258 | } |
| 259 | |
| 260 | GLOBAL(void) |
| 261 | jsimd_h2v1_upsample (j_decompress_ptr cinfo, |
| 262 | jpeg_component_info * compptr, |
| 263 | JSAMPARRAY input_data, |
| 264 | JSAMPARRAY * output_data_ptr) |
| 265 | { |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 266 | #ifdef WITH_SIMD |
Pierre Ossman | 7469386 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 267 | if (simd_support & JSIMD_SSE2) |
| 268 | jsimd_h2v1_upsample_sse2(cinfo->max_v_samp_factor, |
| 269 | cinfo->output_width, input_data, output_data_ptr); |
| 270 | else if (simd_support & JSIMD_MMX) |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 271 | jsimd_h2v1_upsample_mmx(cinfo->max_v_samp_factor, |
| 272 | cinfo->output_width, input_data, output_data_ptr); |
| 273 | #endif |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 274 | } |
| 275 | |
| 276 | GLOBAL(int) |
| 277 | jsimd_can_h2v2_fancy_upsample (void) |
| 278 | { |
| 279 | init_simd(); |
| 280 | |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 281 | /* The code is optimised for these values only */ |
| 282 | if (BITS_IN_JSAMPLE != 8) |
| 283 | return 0; |
| 284 | if (sizeof(JDIMENSION) != 4) |
| 285 | return 0; |
| 286 | |
Pierre Ossman | 7469386 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 287 | if ((simd_support & JSIMD_SSE2) && |
| 288 | IS_ALIGNED_SSE(jconst_fancy_upsample_sse2)) |
| 289 | return 1; |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 290 | if (simd_support & JSIMD_MMX) |
| 291 | return 1; |
| 292 | |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 293 | return 0; |
| 294 | } |
| 295 | |
| 296 | GLOBAL(int) |
| 297 | jsimd_can_h2v1_fancy_upsample (void) |
| 298 | { |
| 299 | init_simd(); |
| 300 | |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 301 | /* The code is optimised for these values only */ |
| 302 | if (BITS_IN_JSAMPLE != 8) |
| 303 | return 0; |
| 304 | if (sizeof(JDIMENSION) != 4) |
| 305 | return 0; |
| 306 | |
Pierre Ossman | 7469386 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 307 | if ((simd_support & JSIMD_SSE2) && |
| 308 | IS_ALIGNED_SSE(jconst_fancy_upsample_sse2)) |
| 309 | return 1; |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 310 | if (simd_support & JSIMD_MMX) |
| 311 | return 1; |
| 312 | |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 313 | return 0; |
| 314 | } |
| 315 | |
| 316 | GLOBAL(void) |
| 317 | jsimd_h2v2_fancy_upsample (j_decompress_ptr cinfo, |
| 318 | jpeg_component_info * compptr, |
| 319 | JSAMPARRAY input_data, |
| 320 | JSAMPARRAY * output_data_ptr) |
| 321 | { |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 322 | #ifdef WITH_SIMD |
Pierre Ossman | 7469386 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 323 | if ((simd_support & JSIMD_SSE2) && |
| 324 | IS_ALIGNED_SSE(jconst_fancy_upsample_sse2)) |
| 325 | jsimd_h2v1_fancy_upsample_sse2(cinfo->max_v_samp_factor, |
| 326 | compptr->downsampled_width, input_data, output_data_ptr); |
| 327 | else if (simd_support & JSIMD_MMX) |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 328 | jsimd_h2v2_fancy_upsample_mmx(cinfo->max_v_samp_factor, |
| 329 | compptr->downsampled_width, input_data, output_data_ptr); |
| 330 | #endif |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 331 | } |
| 332 | |
| 333 | GLOBAL(void) |
| 334 | jsimd_h2v1_fancy_upsample (j_decompress_ptr cinfo, |
| 335 | jpeg_component_info * compptr, |
| 336 | JSAMPARRAY input_data, |
| 337 | JSAMPARRAY * output_data_ptr) |
| 338 | { |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 339 | #ifdef WITH_SIMD |
Pierre Ossman | 7469386 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 340 | if ((simd_support & JSIMD_SSE2) && |
| 341 | IS_ALIGNED_SSE(jconst_fancy_upsample_sse2)) |
| 342 | jsimd_h2v1_fancy_upsample_sse2(cinfo->max_v_samp_factor, |
| 343 | compptr->downsampled_width, input_data, output_data_ptr); |
| 344 | else if (simd_support & JSIMD_MMX) |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 345 | jsimd_h2v1_fancy_upsample_mmx(cinfo->max_v_samp_factor, |
| 346 | compptr->downsampled_width, input_data, output_data_ptr); |
| 347 | #endif |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 348 | } |
| 349 | |
| 350 | GLOBAL(int) |
| 351 | jsimd_can_h2v2_merged_upsample (void) |
| 352 | { |
| 353 | init_simd(); |
| 354 | |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 355 | /* The code is optimised for these values only */ |
| 356 | if (BITS_IN_JSAMPLE != 8) |
| 357 | return 0; |
| 358 | if (sizeof(JDIMENSION) != 4) |
| 359 | return 0; |
| 360 | |
Pierre Ossman | 7469386 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 361 | if ((simd_support & JSIMD_SSE2) && |
| 362 | IS_ALIGNED_SSE(jconst_merged_upsample_sse2)) |
| 363 | return 1; |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 364 | if (simd_support & JSIMD_MMX) |
| 365 | return 1; |
| 366 | |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 367 | return 0; |
| 368 | } |
| 369 | |
| 370 | GLOBAL(int) |
| 371 | jsimd_can_h2v1_merged_upsample (void) |
| 372 | { |
| 373 | init_simd(); |
| 374 | |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 375 | /* The code is optimised for these values only */ |
| 376 | if (BITS_IN_JSAMPLE != 8) |
| 377 | return 0; |
| 378 | if (sizeof(JDIMENSION) != 4) |
| 379 | return 0; |
| 380 | |
Pierre Ossman | 7469386 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 381 | if ((simd_support & JSIMD_SSE2) && |
| 382 | IS_ALIGNED_SSE(jconst_merged_upsample_sse2)) |
| 383 | return 1; |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 384 | if (simd_support & JSIMD_MMX) |
| 385 | return 1; |
| 386 | |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 387 | return 0; |
| 388 | } |
| 389 | |
| 390 | GLOBAL(void) |
| 391 | jsimd_h2v2_merged_upsample (j_decompress_ptr cinfo, |
| 392 | JSAMPIMAGE input_buf, |
| 393 | JDIMENSION in_row_group_ctr, |
| 394 | JSAMPARRAY output_buf) |
| 395 | { |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 396 | #ifdef WITH_SIMD |
Pierre Ossman | 7469386 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 397 | if ((simd_support & JSIMD_SSE2) && |
| 398 | IS_ALIGNED_SSE(jconst_merged_upsample_sse2)) |
| 399 | jsimd_h2v2_merged_upsample_sse2(cinfo->output_width, input_buf, |
| 400 | in_row_group_ctr, output_buf); |
| 401 | else if (simd_support & JSIMD_MMX) |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 402 | jsimd_h2v2_merged_upsample_mmx(cinfo->output_width, input_buf, |
| 403 | in_row_group_ctr, output_buf); |
| 404 | #endif |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 405 | } |
| 406 | |
| 407 | GLOBAL(void) |
| 408 | jsimd_h2v1_merged_upsample (j_decompress_ptr cinfo, |
| 409 | JSAMPIMAGE input_buf, |
| 410 | JDIMENSION in_row_group_ctr, |
| 411 | JSAMPARRAY output_buf) |
| 412 | { |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 413 | #ifdef WITH_SIMD |
Pierre Ossman | 7469386 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 414 | if ((simd_support & JSIMD_SSE2) && |
| 415 | IS_ALIGNED_SSE(jconst_merged_upsample_sse2)) |
| 416 | jsimd_h2v1_merged_upsample_sse2(cinfo->output_width, input_buf, |
| 417 | in_row_group_ctr, output_buf); |
| 418 | else if (simd_support & JSIMD_MMX) |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 419 | jsimd_h2v1_merged_upsample_mmx(cinfo->output_width, input_buf, |
| 420 | in_row_group_ctr, output_buf); |
| 421 | #endif |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 422 | } |
| 423 | |
| 424 | GLOBAL(int) |
| 425 | jsimd_can_convsamp (void) |
| 426 | { |
| 427 | init_simd(); |
| 428 | |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 429 | /* The code is optimised for these values only */ |
| 430 | if (DCTSIZE != 8) |
| 431 | return 0; |
| 432 | if (BITS_IN_JSAMPLE != 8) |
| 433 | return 0; |
| 434 | if (sizeof(JDIMENSION) != 4) |
| 435 | return 0; |
| 436 | if (sizeof(DCTELEM) != 2) |
| 437 | return 0; |
| 438 | |
Pierre Ossman | 7469386 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 439 | if (simd_support & JSIMD_SSE2) |
| 440 | return 1; |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 441 | if (simd_support & JSIMD_MMX) |
| 442 | return 1; |
| 443 | |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 444 | return 0; |
| 445 | } |
| 446 | |
| 447 | GLOBAL(int) |
| 448 | jsimd_can_convsamp_float (void) |
| 449 | { |
| 450 | init_simd(); |
| 451 | |
Pierre Ossman | 2c2e54b | 2009-03-09 13:28:10 +0000 | [diff] [blame] | 452 | /* The code is optimised for these values only */ |
| 453 | if (DCTSIZE != 8) |
| 454 | return 0; |
| 455 | if (BITS_IN_JSAMPLE != 8) |
| 456 | return 0; |
| 457 | if (sizeof(JDIMENSION) != 4) |
| 458 | return 0; |
| 459 | if (sizeof(FAST_FLOAT) != 4) |
| 460 | return 0; |
| 461 | |
Pierre Ossman | 7469386 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 462 | if (simd_support & JSIMD_SSE2) |
| 463 | return 1; |
Pierre Ossman | 0d37c57 | 2009-03-09 13:31:56 +0000 | [diff] [blame] | 464 | if (simd_support & JSIMD_SSE) |
| 465 | return 1; |
Pierre Ossman | 2c2e54b | 2009-03-09 13:28:10 +0000 | [diff] [blame] | 466 | if (simd_support & JSIMD_3DNOW) |
| 467 | return 1; |
| 468 | |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 469 | return 0; |
| 470 | } |
| 471 | |
| 472 | GLOBAL(void) |
| 473 | jsimd_convsamp (JSAMPARRAY sample_data, JDIMENSION start_col, |
| 474 | DCTELEM * workspace) |
| 475 | { |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 476 | #ifdef WITH_SIMD |
Pierre Ossman | 7469386 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 477 | if (simd_support & JSIMD_SSE2) |
| 478 | jsimd_convsamp_sse2(sample_data, start_col, workspace); |
| 479 | else if (simd_support & JSIMD_MMX) |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 480 | jsimd_convsamp_mmx(sample_data, start_col, workspace); |
| 481 | #endif |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 482 | } |
| 483 | |
| 484 | GLOBAL(void) |
| 485 | jsimd_convsamp_float (JSAMPARRAY sample_data, JDIMENSION start_col, |
| 486 | FAST_FLOAT * workspace) |
| 487 | { |
Pierre Ossman | 2c2e54b | 2009-03-09 13:28:10 +0000 | [diff] [blame] | 488 | #ifdef WITH_SIMD |
Pierre Ossman | 7469386 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 489 | if (simd_support & JSIMD_SSE2) |
| 490 | jsimd_convsamp_float_sse2(sample_data, start_col, workspace); |
| 491 | else if (simd_support & JSIMD_SSE) |
Pierre Ossman | 0d37c57 | 2009-03-09 13:31:56 +0000 | [diff] [blame] | 492 | jsimd_convsamp_float_sse(sample_data, start_col, workspace); |
| 493 | else if (simd_support & JSIMD_3DNOW) |
Pierre Ossman | 2c2e54b | 2009-03-09 13:28:10 +0000 | [diff] [blame] | 494 | jsimd_convsamp_float_3dnow(sample_data, start_col, workspace); |
| 495 | #endif |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 496 | } |
| 497 | |
| 498 | GLOBAL(int) |
| 499 | jsimd_can_fdct_islow (void) |
| 500 | { |
| 501 | init_simd(); |
| 502 | |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 503 | /* The code is optimised for these values only */ |
| 504 | if (DCTSIZE != 8) |
| 505 | return 0; |
| 506 | if (sizeof(DCTELEM) != 2) |
| 507 | return 0; |
| 508 | |
Pierre Ossman | 7469386 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 509 | if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_fdct_islow_sse2)) |
| 510 | return 1; |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 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_fdct_ifast (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(DCTELEM) != 2) |
| 526 | return 0; |
| 527 | |
Pierre Ossman | 7469386 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 528 | if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_fdct_ifast_sse2)) |
| 529 | return 1; |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 530 | if (simd_support & JSIMD_MMX) |
| 531 | return 1; |
| 532 | |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 533 | return 0; |
| 534 | } |
| 535 | |
| 536 | GLOBAL(int) |
| 537 | jsimd_can_fdct_float (void) |
| 538 | { |
| 539 | init_simd(); |
| 540 | |
Pierre Ossman | 2c2e54b | 2009-03-09 13:28:10 +0000 | [diff] [blame] | 541 | /* The code is optimised for these values only */ |
| 542 | if (DCTSIZE != 8) |
| 543 | return 0; |
| 544 | if (sizeof(FAST_FLOAT) != 4) |
| 545 | return 0; |
| 546 | |
Pierre Ossman | 0d37c57 | 2009-03-09 13:31:56 +0000 | [diff] [blame] | 547 | if ((simd_support & JSIMD_SSE) && IS_ALIGNED_SSE(jconst_fdct_float_sse)) |
| 548 | return 1; |
Pierre Ossman | 2c2e54b | 2009-03-09 13:28:10 +0000 | [diff] [blame] | 549 | if (simd_support & JSIMD_3DNOW) |
| 550 | return 1; |
| 551 | |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 552 | return 0; |
| 553 | } |
| 554 | |
| 555 | GLOBAL(void) |
| 556 | jsimd_fdct_islow (DCTELEM * data) |
| 557 | { |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 558 | #ifdef WITH_SIMD |
Pierre Ossman | 7469386 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 559 | if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_fdct_islow_sse2)) |
| 560 | jsimd_fdct_islow_sse2(data); |
| 561 | else if (simd_support & JSIMD_MMX) |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 562 | jsimd_fdct_islow_mmx(data); |
| 563 | #endif |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 564 | } |
| 565 | |
| 566 | GLOBAL(void) |
| 567 | jsimd_fdct_ifast (DCTELEM * data) |
| 568 | { |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 569 | #ifdef WITH_SIMD |
Pierre Ossman | 7469386 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 570 | if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_fdct_islow_sse2)) |
| 571 | jsimd_fdct_ifast_sse2(data); |
| 572 | else if (simd_support & JSIMD_MMX) |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 573 | jsimd_fdct_ifast_mmx(data); |
| 574 | #endif |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 575 | } |
| 576 | |
| 577 | GLOBAL(void) |
| 578 | jsimd_fdct_float (FAST_FLOAT * data) |
| 579 | { |
Pierre Ossman | 2c2e54b | 2009-03-09 13:28:10 +0000 | [diff] [blame] | 580 | #ifdef WITH_SIMD |
Pierre Ossman | 0d37c57 | 2009-03-09 13:31:56 +0000 | [diff] [blame] | 581 | if ((simd_support & JSIMD_SSE) && IS_ALIGNED_SSE(jconst_fdct_float_sse)) |
| 582 | jsimd_fdct_float_sse(data); |
| 583 | else if (simd_support & JSIMD_3DNOW) |
Pierre Ossman | 2c2e54b | 2009-03-09 13:28:10 +0000 | [diff] [blame] | 584 | jsimd_fdct_float_3dnow(data); |
| 585 | #endif |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 586 | } |
| 587 | |
| 588 | GLOBAL(int) |
| 589 | jsimd_can_quantize (void) |
| 590 | { |
| 591 | init_simd(); |
| 592 | |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 593 | /* The code is optimised for these values only */ |
| 594 | if (DCTSIZE != 8) |
| 595 | return 0; |
| 596 | if (sizeof(JCOEF) != 2) |
| 597 | return 0; |
| 598 | if (sizeof(DCTELEM) != 2) |
| 599 | return 0; |
| 600 | |
Pierre Ossman | 7469386 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 601 | if (simd_support & JSIMD_SSE2) |
| 602 | return 1; |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 603 | if (simd_support & JSIMD_MMX) |
| 604 | return 1; |
| 605 | |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 606 | return 0; |
| 607 | } |
| 608 | |
| 609 | GLOBAL(int) |
| 610 | jsimd_can_quantize_float (void) |
| 611 | { |
| 612 | init_simd(); |
| 613 | |
Pierre Ossman | 2c2e54b | 2009-03-09 13:28:10 +0000 | [diff] [blame] | 614 | /* The code is optimised for these values only */ |
| 615 | if (DCTSIZE != 8) |
| 616 | return 0; |
| 617 | if (sizeof(JCOEF) != 2) |
| 618 | return 0; |
| 619 | if (sizeof(FAST_FLOAT) != 4) |
| 620 | return 0; |
| 621 | |
Pierre Ossman | 7469386 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 622 | if (simd_support & JSIMD_SSE2) |
| 623 | return 1; |
Pierre Ossman | 0d37c57 | 2009-03-09 13:31:56 +0000 | [diff] [blame] | 624 | if (simd_support & JSIMD_SSE) |
| 625 | return 1; |
Pierre Ossman | 2c2e54b | 2009-03-09 13:28:10 +0000 | [diff] [blame] | 626 | if (simd_support & JSIMD_3DNOW) |
| 627 | return 1; |
| 628 | |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 629 | return 0; |
| 630 | } |
| 631 | |
| 632 | GLOBAL(void) |
| 633 | jsimd_quantize (JCOEFPTR coef_block, DCTELEM * divisors, |
| 634 | DCTELEM * workspace) |
| 635 | { |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 636 | #ifdef WITH_SIMD |
Pierre Ossman | 7469386 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 637 | if (simd_support & JSIMD_SSE2) |
| 638 | jsimd_quantize_sse2(coef_block, divisors, workspace); |
| 639 | else if (simd_support & JSIMD_MMX) |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 640 | jsimd_quantize_mmx(coef_block, divisors, workspace); |
| 641 | #endif |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 642 | } |
| 643 | |
| 644 | GLOBAL(void) |
| 645 | jsimd_quantize_float (JCOEFPTR coef_block, FAST_FLOAT * divisors, |
| 646 | FAST_FLOAT * workspace) |
| 647 | { |
Pierre Ossman | 2c2e54b | 2009-03-09 13:28:10 +0000 | [diff] [blame] | 648 | #ifdef WITH_SIMD |
Pierre Ossman | 7469386 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 649 | if (simd_support & JSIMD_SSE2) |
| 650 | jsimd_quantize_float_sse2(coef_block, divisors, workspace); |
| 651 | else if (simd_support & JSIMD_SSE) |
Pierre Ossman | 0d37c57 | 2009-03-09 13:31:56 +0000 | [diff] [blame] | 652 | jsimd_quantize_float_sse(coef_block, divisors, workspace); |
| 653 | else if (simd_support & JSIMD_3DNOW) |
Pierre Ossman | 2c2e54b | 2009-03-09 13:28:10 +0000 | [diff] [blame] | 654 | jsimd_quantize_float_3dnow(coef_block, divisors, workspace); |
| 655 | #endif |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 656 | } |
| 657 | |
| 658 | GLOBAL(int) |
| 659 | jsimd_can_idct_2x2 (void) |
| 660 | { |
| 661 | init_simd(); |
| 662 | |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 663 | /* The code is optimised for these values only */ |
| 664 | if (DCTSIZE != 8) |
| 665 | return 0; |
| 666 | if (sizeof(JCOEF) != 2) |
| 667 | return 0; |
| 668 | if (BITS_IN_JSAMPLE != 8) |
| 669 | return 0; |
| 670 | if (sizeof(JDIMENSION) != 4) |
| 671 | return 0; |
| 672 | if (sizeof(ISLOW_MULT_TYPE) != 2) |
| 673 | return 0; |
| 674 | |
Pierre Ossman | 7469386 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 675 | if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_red_sse2)) |
| 676 | return 1; |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 677 | if (simd_support & JSIMD_MMX) |
| 678 | return 1; |
| 679 | |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 680 | return 0; |
| 681 | } |
| 682 | |
| 683 | GLOBAL(int) |
| 684 | jsimd_can_idct_4x4 (void) |
| 685 | { |
| 686 | init_simd(); |
| 687 | |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 688 | /* The code is optimised for these values only */ |
| 689 | if (DCTSIZE != 8) |
| 690 | return 0; |
| 691 | if (sizeof(JCOEF) != 2) |
| 692 | return 0; |
| 693 | if (BITS_IN_JSAMPLE != 8) |
| 694 | return 0; |
| 695 | if (sizeof(JDIMENSION) != 4) |
| 696 | return 0; |
| 697 | if (sizeof(ISLOW_MULT_TYPE) != 2) |
| 698 | return 0; |
| 699 | |
Pierre Ossman | 7469386 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 700 | if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_red_sse2)) |
| 701 | return 1; |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 702 | if (simd_support & JSIMD_MMX) |
| 703 | return 1; |
| 704 | |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 705 | return 0; |
| 706 | } |
| 707 | |
| 708 | GLOBAL(void) |
| 709 | jsimd_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
| 710 | JCOEFPTR coef_block, JSAMPARRAY output_buf, |
| 711 | JDIMENSION output_col) |
| 712 | { |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 713 | #if WITH_SIMD |
Pierre Ossman | 7469386 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 714 | if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_red_sse2)) |
| 715 | jsimd_idct_2x2_sse2(compptr->dct_table, coef_block, output_buf, output_col); |
| 716 | else if (simd_support & JSIMD_MMX) |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 717 | jsimd_idct_2x2_mmx(compptr->dct_table, coef_block, output_buf, output_col); |
| 718 | #endif |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 719 | } |
| 720 | |
| 721 | GLOBAL(void) |
| 722 | jsimd_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
| 723 | JCOEFPTR coef_block, JSAMPARRAY output_buf, |
| 724 | JDIMENSION output_col) |
| 725 | { |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 726 | #if WITH_SIMD |
Pierre Ossman | 7469386 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 727 | if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_red_sse2)) |
| 728 | jsimd_idct_4x4_sse2(compptr->dct_table, coef_block, output_buf, output_col); |
| 729 | else if (simd_support & JSIMD_MMX) |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 730 | jsimd_idct_4x4_mmx(compptr->dct_table, coef_block, output_buf, output_col); |
| 731 | #endif |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 732 | } |
| 733 | |
| 734 | GLOBAL(int) |
| 735 | jsimd_can_idct_islow (void) |
| 736 | { |
| 737 | init_simd(); |
| 738 | |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 739 | /* The code is optimised for these values only */ |
| 740 | if (DCTSIZE != 8) |
| 741 | return 0; |
| 742 | if (sizeof(JCOEF) != 2) |
| 743 | return 0; |
| 744 | if (BITS_IN_JSAMPLE != 8) |
| 745 | return 0; |
| 746 | if (sizeof(JDIMENSION) != 4) |
| 747 | return 0; |
| 748 | if (sizeof(ISLOW_MULT_TYPE) != 2) |
| 749 | return 0; |
| 750 | |
Pierre Ossman | 7469386 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 751 | if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_islow_sse2)) |
| 752 | return 1; |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 753 | if (simd_support & JSIMD_MMX) |
| 754 | return 1; |
| 755 | |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 756 | return 0; |
| 757 | } |
| 758 | |
| 759 | GLOBAL(int) |
| 760 | jsimd_can_idct_ifast (void) |
| 761 | { |
| 762 | init_simd(); |
| 763 | |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 764 | /* The code is optimised for these values only */ |
| 765 | if (DCTSIZE != 8) |
| 766 | return 0; |
| 767 | if (sizeof(JCOEF) != 2) |
| 768 | return 0; |
| 769 | if (BITS_IN_JSAMPLE != 8) |
| 770 | return 0; |
| 771 | if (sizeof(JDIMENSION) != 4) |
| 772 | return 0; |
| 773 | if (sizeof(IFAST_MULT_TYPE) != 2) |
| 774 | return 0; |
| 775 | if (IFAST_SCALE_BITS != 2) |
| 776 | return 0; |
| 777 | |
Pierre Ossman | 7469386 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 778 | if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_ifast_sse2)) |
| 779 | return 1; |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 780 | if (simd_support & JSIMD_MMX) |
| 781 | return 1; |
| 782 | |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 783 | return 0; |
| 784 | } |
| 785 | |
| 786 | GLOBAL(int) |
| 787 | jsimd_can_idct_float (void) |
| 788 | { |
| 789 | init_simd(); |
| 790 | |
Pierre Ossman | 2c2e54b | 2009-03-09 13:28:10 +0000 | [diff] [blame] | 791 | if (DCTSIZE != 8) |
| 792 | return 0; |
| 793 | if (sizeof(JCOEF) != 2) |
| 794 | return 0; |
| 795 | if (BITS_IN_JSAMPLE != 8) |
| 796 | return 0; |
| 797 | if (sizeof(JDIMENSION) != 4) |
| 798 | return 0; |
| 799 | if (sizeof(FAST_FLOAT) != 4) |
| 800 | return 0; |
| 801 | if (sizeof(FLOAT_MULT_TYPE) != 4) |
| 802 | return 0; |
| 803 | |
Pierre Ossman | 7469386 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 804 | if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_float_sse2)) |
| 805 | return 1; |
Pierre Ossman | 0d37c57 | 2009-03-09 13:31:56 +0000 | [diff] [blame] | 806 | if ((simd_support & JSIMD_SSE) && IS_ALIGNED_SSE(jconst_idct_float_sse)) |
| 807 | return 1; |
Pierre Ossman | 2c2e54b | 2009-03-09 13:28:10 +0000 | [diff] [blame] | 808 | if (simd_support & JSIMD_3DNOW) |
| 809 | return 1; |
| 810 | |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 811 | return 0; |
| 812 | } |
| 813 | |
| 814 | GLOBAL(void) |
| 815 | jsimd_idct_islow (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
| 816 | JCOEFPTR coef_block, JSAMPARRAY output_buf, |
| 817 | JDIMENSION output_col) |
| 818 | { |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 819 | #if WITH_SIMD |
Pierre Ossman | 7469386 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 820 | if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_islow_sse2)) |
| 821 | jsimd_idct_islow_sse2(compptr->dct_table, coef_block, output_buf, output_col); |
| 822 | else if (simd_support & JSIMD_MMX) |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 823 | jsimd_idct_islow_mmx(compptr->dct_table, coef_block, output_buf, output_col); |
| 824 | #endif |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 825 | } |
| 826 | |
| 827 | GLOBAL(void) |
| 828 | jsimd_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
| 829 | JCOEFPTR coef_block, JSAMPARRAY output_buf, |
| 830 | JDIMENSION output_col) |
| 831 | { |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 832 | #if WITH_SIMD |
Pierre Ossman | 7469386 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 833 | if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_ifast_sse2)) |
| 834 | jsimd_idct_ifast_sse2(compptr->dct_table, coef_block, output_buf, output_col); |
| 835 | else if (simd_support & JSIMD_MMX) |
Pierre Ossman | 3e0e2de | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 836 | jsimd_idct_ifast_mmx(compptr->dct_table, coef_block, output_buf, output_col); |
| 837 | #endif |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 838 | } |
| 839 | |
| 840 | GLOBAL(void) |
| 841 | jsimd_idct_float (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
| 842 | JCOEFPTR coef_block, JSAMPARRAY output_buf, |
| 843 | JDIMENSION output_col) |
| 844 | { |
Pierre Ossman | 2c2e54b | 2009-03-09 13:28:10 +0000 | [diff] [blame] | 845 | #if WITH_SIMD |
Pierre Ossman | 7469386 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 846 | if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_float_sse2)) |
| 847 | jsimd_idct_float_sse2(compptr->dct_table, coef_block, |
| 848 | output_buf, output_col); |
| 849 | else if ((simd_support & JSIMD_SSE) && IS_ALIGNED_SSE(jconst_idct_float_sse)) |
Pierre Ossman | 0d37c57 | 2009-03-09 13:31:56 +0000 | [diff] [blame] | 850 | jsimd_idct_float_sse(compptr->dct_table, coef_block, |
| 851 | output_buf, output_col); |
| 852 | else if (simd_support & JSIMD_3DNOW) |
Pierre Ossman | 2c2e54b | 2009-03-09 13:28:10 +0000 | [diff] [blame] | 853 | jsimd_idct_float_3dnow(compptr->dct_table, coef_block, |
| 854 | output_buf, output_col); |
| 855 | #endif |
Pierre Ossman | 9ad5234 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 856 | } |
| 857 | |