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