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 |
DRC | f25c071 | 2009-04-03 12:00:51 +0000 | [diff] [blame^] | 5 | * Copyright 2009 D. R. Commander |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 6 | * |
| 7 | * Based on the x86 SIMD extension for IJG JPEG library, |
| 8 | * Copyright (C) 1999-2006, MIYASAKA Masaru. |
| 9 | * |
| 10 | * This file contains the interface between the "normal" portions |
| 11 | * of the library and the SIMD implementations. |
| 12 | */ |
| 13 | |
| 14 | #define JPEG_INTERNALS |
| 15 | #include "jinclude.h" |
| 16 | #include "jpeglib.h" |
Pierre Ossman | 2ae181c | 2009-03-09 13:21:27 +0000 | [diff] [blame] | 17 | #include "jsimd.h" |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 18 | #include "jdct.h" |
Pierre Ossman | 2ae181c | 2009-03-09 13:21:27 +0000 | [diff] [blame] | 19 | #include "jsimddct.h" |
| 20 | #include "simd/jsimd.h" |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 21 | |
Pierre Ossman | 018fc42 | 2009-03-09 13:31:56 +0000 | [diff] [blame] | 22 | /* |
| 23 | * In the PIC cases, we have no guarantee that constants will keep |
| 24 | * their alignment. This macro allows us to verify it at runtime. |
| 25 | */ |
| 26 | #ifdef WITH_SIMD |
| 27 | #define IS_ALIGNED(ptr, order) (((unsigned)ptr & ((1 << order) - 1)) == 0) |
| 28 | #else |
| 29 | #define IS_ALIGNED(ptr, order) (0) |
| 30 | #endif |
| 31 | |
| 32 | #define IS_ALIGNED_SSE(ptr) (IS_ALIGNED(ptr, 4)) /* 16 byte alignment */ |
| 33 | |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 34 | static unsigned int simd_support = ~0; |
| 35 | |
| 36 | /* |
| 37 | * Check what SIMD accelerations are supported. |
| 38 | * |
| 39 | * FIXME: This code is racy under a multi-threaded environment. |
| 40 | */ |
| 41 | LOCAL(void) |
| 42 | init_simd (void) |
| 43 | { |
DRC | 59c1a25 | 2009-04-03 11:27:17 +0000 | [diff] [blame] | 44 | #ifdef WITH_SIMD |
| 45 | char *env = NULL; |
| 46 | #endif |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 47 | if (simd_support != ~0) |
| 48 | return; |
| 49 | |
Pierre Ossman | 2ae181c | 2009-03-09 13:21:27 +0000 | [diff] [blame] | 50 | #ifdef WITH_SIMD |
| 51 | simd_support = jpeg_simd_cpu_support(); |
DRC | 59c1a25 | 2009-04-03 11:27:17 +0000 | [diff] [blame] | 52 | if((env=getenv("JSIMD_FORCEMMX"))!=NULL && !strcmp(env, "1")) |
| 53 | simd_support = JSIMD_MMX; |
| 54 | else if((env=getenv("JSIMD_FORCESSE2"))!=NULL && !strcmp(env, "1")) |
| 55 | simd_support = JSIMD_SSE2; |
Pierre Ossman | 2ae181c | 2009-03-09 13:21:27 +0000 | [diff] [blame] | 56 | #else |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 57 | simd_support = JSIMD_NONE; |
Pierre Ossman | 2ae181c | 2009-03-09 13:21:27 +0000 | [diff] [blame] | 58 | #endif |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 59 | } |
| 60 | |
| 61 | GLOBAL(int) |
| 62 | jsimd_can_rgb_ycc (void) |
| 63 | { |
| 64 | init_simd(); |
| 65 | |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 66 | /* The code is optimised for these values only */ |
| 67 | if (BITS_IN_JSAMPLE != 8) |
| 68 | return 0; |
| 69 | if (sizeof(JDIMENSION) != 4) |
| 70 | return 0; |
| 71 | if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4)) |
| 72 | return 0; |
| 73 | |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 74 | if ((simd_support & JSIMD_SSE2) && |
| 75 | IS_ALIGNED_SSE(jconst_rgb_ycc_convert_sse2)) |
| 76 | return 1; |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 77 | if (simd_support & JSIMD_MMX) |
| 78 | return 1; |
| 79 | |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 80 | return 0; |
| 81 | } |
| 82 | |
| 83 | GLOBAL(int) |
| 84 | jsimd_can_ycc_rgb (void) |
| 85 | { |
| 86 | init_simd(); |
| 87 | |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 88 | /* The code is optimised for these values only */ |
| 89 | if (BITS_IN_JSAMPLE != 8) |
| 90 | return 0; |
| 91 | if (sizeof(JDIMENSION) != 4) |
| 92 | return 0; |
| 93 | if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4)) |
| 94 | return 0; |
| 95 | |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 96 | if ((simd_support & JSIMD_SSE2) && |
| 97 | IS_ALIGNED_SSE(jconst_ycc_rgb_convert_sse2)) |
| 98 | return 1; |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 99 | if (simd_support & JSIMD_MMX) |
| 100 | return 1; |
| 101 | |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 102 | return 0; |
| 103 | } |
| 104 | |
| 105 | GLOBAL(void) |
| 106 | jsimd_rgb_ycc_convert (j_compress_ptr cinfo, |
| 107 | JSAMPARRAY input_buf, JSAMPIMAGE output_buf, |
| 108 | JDIMENSION output_row, int num_rows) |
| 109 | { |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 110 | #ifdef WITH_SIMD |
DRC | f25c071 | 2009-04-03 12:00:51 +0000 | [diff] [blame^] | 111 | void (*sse2fct)(JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JDIMENSION, int); |
| 112 | void (*mmxfct)(JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JDIMENSION, int); |
| 113 | switch(cinfo->in_color_space) |
| 114 | { |
| 115 | case JCS_EXT_RGB: |
| 116 | sse2fct=jsimd_extrgb_ycc_convert_sse2; |
| 117 | mmxfct=jsimd_extrgb_ycc_convert_mmx; |
| 118 | break; |
| 119 | case JCS_EXT_RGBX: |
| 120 | sse2fct=jsimd_extrgbx_ycc_convert_sse2; |
| 121 | mmxfct=jsimd_extrgbx_ycc_convert_mmx; |
| 122 | break; |
| 123 | case JCS_EXT_BGR: |
| 124 | sse2fct=jsimd_extbgr_ycc_convert_sse2; |
| 125 | mmxfct=jsimd_extbgr_ycc_convert_mmx; |
| 126 | break; |
| 127 | case JCS_EXT_BGRX: |
| 128 | sse2fct=jsimd_extbgrx_ycc_convert_sse2; |
| 129 | mmxfct=jsimd_extbgrx_ycc_convert_mmx; |
| 130 | break; |
| 131 | case JCS_EXT_XBGR: |
| 132 | sse2fct=jsimd_extxbgr_ycc_convert_sse2; |
| 133 | mmxfct=jsimd_extxbgr_ycc_convert_mmx; |
| 134 | break; |
| 135 | case JCS_EXT_XRGB: |
| 136 | sse2fct=jsimd_extxrgb_ycc_convert_sse2; |
| 137 | mmxfct=jsimd_extxrgb_ycc_convert_mmx; |
| 138 | break; |
| 139 | default: |
| 140 | sse2fct=jsimd_rgb_ycc_convert_sse2; |
| 141 | mmxfct=jsimd_rgb_ycc_convert_mmx; |
| 142 | break; |
| 143 | } |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 144 | if ((simd_support & JSIMD_SSE2) && |
| 145 | IS_ALIGNED_SSE(jconst_rgb_ycc_convert_sse2)) |
DRC | f25c071 | 2009-04-03 12:00:51 +0000 | [diff] [blame^] | 146 | sse2fct(cinfo->image_width, input_buf, |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 147 | output_buf, output_row, num_rows); |
| 148 | else if (simd_support & JSIMD_MMX) |
DRC | f25c071 | 2009-04-03 12:00:51 +0000 | [diff] [blame^] | 149 | mmxfct(cinfo->image_width, input_buf, |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 150 | output_buf, output_row, num_rows); |
| 151 | #endif |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 152 | } |
| 153 | |
| 154 | GLOBAL(void) |
| 155 | jsimd_ycc_rgb_convert (j_decompress_ptr cinfo, |
| 156 | JSAMPIMAGE input_buf, JDIMENSION input_row, |
| 157 | JSAMPARRAY output_buf, int num_rows) |
| 158 | { |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 159 | #ifdef WITH_SIMD |
DRC | f25c071 | 2009-04-03 12:00:51 +0000 | [diff] [blame^] | 160 | void (*sse2fct)(JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY, int); |
| 161 | void (*mmxfct)(JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY, int); |
| 162 | switch(cinfo->out_color_space) |
| 163 | { |
| 164 | case JCS_EXT_RGB: |
| 165 | sse2fct=jsimd_ycc_extrgb_convert_sse2; |
| 166 | mmxfct=jsimd_ycc_extrgb_convert_mmx; |
| 167 | break; |
| 168 | case JCS_EXT_RGBX: |
| 169 | sse2fct=jsimd_ycc_extrgbx_convert_sse2; |
| 170 | mmxfct=jsimd_ycc_extrgbx_convert_mmx; |
| 171 | break; |
| 172 | case JCS_EXT_BGR: |
| 173 | sse2fct=jsimd_ycc_extbgr_convert_sse2; |
| 174 | mmxfct=jsimd_ycc_extbgr_convert_mmx; |
| 175 | break; |
| 176 | case JCS_EXT_BGRX: |
| 177 | sse2fct=jsimd_ycc_extbgrx_convert_sse2; |
| 178 | mmxfct=jsimd_ycc_extbgrx_convert_mmx; |
| 179 | break; |
| 180 | case JCS_EXT_XBGR: |
| 181 | sse2fct=jsimd_ycc_extxbgr_convert_sse2; |
| 182 | mmxfct=jsimd_ycc_extxbgr_convert_mmx; |
| 183 | break; |
| 184 | case JCS_EXT_XRGB: |
| 185 | sse2fct=jsimd_ycc_extxrgb_convert_sse2; |
| 186 | mmxfct=jsimd_ycc_extxrgb_convert_mmx; |
| 187 | break; |
| 188 | default: |
| 189 | sse2fct=jsimd_ycc_rgb_convert_sse2; |
| 190 | mmxfct=jsimd_ycc_rgb_convert_mmx; |
| 191 | break; |
| 192 | } |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 193 | if ((simd_support & JSIMD_SSE2) && |
| 194 | IS_ALIGNED_SSE(jconst_ycc_rgb_convert_sse2)) |
DRC | f25c071 | 2009-04-03 12:00:51 +0000 | [diff] [blame^] | 195 | sse2fct(cinfo->output_width, input_buf, |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 196 | input_row, output_buf, num_rows); |
| 197 | else if (simd_support & JSIMD_MMX) |
DRC | f25c071 | 2009-04-03 12:00:51 +0000 | [diff] [blame^] | 198 | mmxfct(cinfo->output_width, input_buf, |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 199 | input_row, output_buf, num_rows); |
| 200 | #endif |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 201 | } |
| 202 | |
| 203 | GLOBAL(int) |
| 204 | jsimd_can_h2v2_downsample (void) |
| 205 | { |
| 206 | init_simd(); |
| 207 | |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 208 | /* The code is optimised for these values only */ |
| 209 | if (BITS_IN_JSAMPLE != 8) |
| 210 | return 0; |
| 211 | if (sizeof(JDIMENSION) != 4) |
| 212 | return 0; |
| 213 | |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 214 | if (simd_support & JSIMD_SSE2) |
| 215 | return 1; |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 216 | if (simd_support & JSIMD_MMX) |
| 217 | return 1; |
| 218 | |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 219 | return 0; |
| 220 | } |
| 221 | |
| 222 | GLOBAL(int) |
| 223 | jsimd_can_h2v1_downsample (void) |
| 224 | { |
| 225 | init_simd(); |
| 226 | |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 227 | /* The code is optimised for these values only */ |
| 228 | if (BITS_IN_JSAMPLE != 8) |
| 229 | return 0; |
| 230 | if (sizeof(JDIMENSION) != 4) |
| 231 | return 0; |
| 232 | |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 233 | if (simd_support & JSIMD_SSE2) |
| 234 | return 1; |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 235 | if (simd_support & JSIMD_MMX) |
| 236 | return 1; |
| 237 | |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 238 | return 0; |
| 239 | } |
| 240 | |
| 241 | GLOBAL(void) |
| 242 | jsimd_h2v2_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, |
| 243 | JSAMPARRAY input_data, JSAMPARRAY output_data) |
| 244 | { |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 245 | #ifdef WITH_SIMD |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 246 | if (simd_support & JSIMD_SSE2) |
| 247 | jsimd_h2v2_downsample_sse2(cinfo->image_width, cinfo->max_v_samp_factor, |
| 248 | compptr->v_samp_factor, compptr->width_in_blocks, |
| 249 | input_data, output_data); |
| 250 | else if (simd_support & JSIMD_MMX) |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 251 | jsimd_h2v2_downsample_mmx(cinfo->image_width, cinfo->max_v_samp_factor, |
| 252 | compptr->v_samp_factor, compptr->width_in_blocks, |
| 253 | input_data, output_data); |
| 254 | #endif |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 255 | } |
| 256 | |
| 257 | GLOBAL(void) |
| 258 | jsimd_h2v1_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, |
| 259 | JSAMPARRAY input_data, JSAMPARRAY output_data) |
| 260 | { |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 261 | #ifdef WITH_SIMD |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 262 | if (simd_support & JSIMD_SSE2) |
| 263 | jsimd_h2v1_downsample_sse2(cinfo->image_width, cinfo->max_v_samp_factor, |
| 264 | compptr->v_samp_factor, compptr->width_in_blocks, |
| 265 | input_data, output_data); |
| 266 | else if (simd_support & JSIMD_MMX) |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 267 | jsimd_h2v1_downsample_mmx(cinfo->image_width, cinfo->max_v_samp_factor, |
| 268 | compptr->v_samp_factor, compptr->width_in_blocks, |
| 269 | input_data, output_data); |
| 270 | #endif |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 271 | } |
| 272 | |
| 273 | GLOBAL(int) |
| 274 | jsimd_can_h2v2_upsample (void) |
| 275 | { |
| 276 | init_simd(); |
| 277 | |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 278 | /* The code is optimised for these values only */ |
| 279 | if (BITS_IN_JSAMPLE != 8) |
| 280 | return 0; |
| 281 | if (sizeof(JDIMENSION) != 4) |
| 282 | return 0; |
| 283 | |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 284 | if (simd_support & JSIMD_SSE2) |
| 285 | return 1; |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 286 | if (simd_support & JSIMD_MMX) |
| 287 | return 1; |
| 288 | |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 289 | return 0; |
| 290 | } |
| 291 | |
| 292 | GLOBAL(int) |
| 293 | jsimd_can_h2v1_upsample (void) |
| 294 | { |
| 295 | init_simd(); |
| 296 | |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 297 | /* The code is optimised for these values only */ |
| 298 | if (BITS_IN_JSAMPLE != 8) |
| 299 | return 0; |
| 300 | if (sizeof(JDIMENSION) != 4) |
| 301 | return 0; |
| 302 | |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 303 | if (simd_support & JSIMD_SSE2) |
| 304 | return 1; |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 305 | if (simd_support & JSIMD_MMX) |
| 306 | return 1; |
| 307 | |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 308 | return 0; |
| 309 | } |
| 310 | |
| 311 | GLOBAL(void) |
| 312 | jsimd_h2v2_upsample (j_decompress_ptr cinfo, |
| 313 | jpeg_component_info * compptr, |
| 314 | JSAMPARRAY input_data, |
| 315 | JSAMPARRAY * output_data_ptr) |
| 316 | { |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 317 | #ifdef WITH_SIMD |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 318 | if (simd_support & JSIMD_SSE2) |
| 319 | jsimd_h2v2_upsample_sse2(cinfo->max_v_samp_factor, |
| 320 | cinfo->output_width, input_data, output_data_ptr); |
| 321 | else if (simd_support & JSIMD_MMX) |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 322 | jsimd_h2v2_upsample_mmx(cinfo->max_v_samp_factor, |
| 323 | cinfo->output_width, input_data, output_data_ptr); |
| 324 | #endif |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 325 | } |
| 326 | |
| 327 | GLOBAL(void) |
| 328 | jsimd_h2v1_upsample (j_decompress_ptr cinfo, |
| 329 | jpeg_component_info * compptr, |
| 330 | JSAMPARRAY input_data, |
| 331 | JSAMPARRAY * output_data_ptr) |
| 332 | { |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 333 | #ifdef WITH_SIMD |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 334 | if (simd_support & JSIMD_SSE2) |
| 335 | jsimd_h2v1_upsample_sse2(cinfo->max_v_samp_factor, |
| 336 | cinfo->output_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_upsample_mmx(cinfo->max_v_samp_factor, |
| 339 | cinfo->output_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_fancy_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_fancy_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_fancy_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_fancy_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_fancy_upsample (j_decompress_ptr cinfo, |
| 385 | jpeg_component_info * compptr, |
| 386 | JSAMPARRAY input_data, |
| 387 | JSAMPARRAY * output_data_ptr) |
| 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_fancy_upsample_sse2)) |
| 392 | jsimd_h2v1_fancy_upsample_sse2(cinfo->max_v_samp_factor, |
| 393 | compptr->downsampled_width, input_data, output_data_ptr); |
| 394 | else if (simd_support & JSIMD_MMX) |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 395 | jsimd_h2v2_fancy_upsample_mmx(cinfo->max_v_samp_factor, |
| 396 | compptr->downsampled_width, input_data, output_data_ptr); |
| 397 | #endif |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 398 | } |
| 399 | |
| 400 | GLOBAL(void) |
| 401 | jsimd_h2v1_fancy_upsample (j_decompress_ptr cinfo, |
| 402 | jpeg_component_info * compptr, |
| 403 | JSAMPARRAY input_data, |
| 404 | JSAMPARRAY * output_data_ptr) |
| 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_fancy_upsample_sse2)) |
| 409 | jsimd_h2v1_fancy_upsample_sse2(cinfo->max_v_samp_factor, |
| 410 | compptr->downsampled_width, input_data, output_data_ptr); |
| 411 | else if (simd_support & JSIMD_MMX) |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 412 | jsimd_h2v1_fancy_upsample_mmx(cinfo->max_v_samp_factor, |
| 413 | compptr->downsampled_width, input_data, output_data_ptr); |
| 414 | #endif |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 415 | } |
| 416 | |
| 417 | GLOBAL(int) |
| 418 | jsimd_can_h2v2_merged_upsample (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 (BITS_IN_JSAMPLE != 8) |
| 424 | return 0; |
| 425 | if (sizeof(JDIMENSION) != 4) |
| 426 | return 0; |
| 427 | |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 428 | if ((simd_support & JSIMD_SSE2) && |
| 429 | IS_ALIGNED_SSE(jconst_merged_upsample_sse2)) |
| 430 | return 1; |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 431 | if (simd_support & JSIMD_MMX) |
| 432 | return 1; |
| 433 | |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 434 | return 0; |
| 435 | } |
| 436 | |
| 437 | GLOBAL(int) |
| 438 | jsimd_can_h2v1_merged_upsample (void) |
| 439 | { |
| 440 | init_simd(); |
| 441 | |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 442 | /* The code is optimised for these values only */ |
| 443 | if (BITS_IN_JSAMPLE != 8) |
| 444 | return 0; |
| 445 | if (sizeof(JDIMENSION) != 4) |
| 446 | return 0; |
| 447 | |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 448 | if ((simd_support & JSIMD_SSE2) && |
| 449 | IS_ALIGNED_SSE(jconst_merged_upsample_sse2)) |
| 450 | return 1; |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 451 | if (simd_support & JSIMD_MMX) |
| 452 | return 1; |
| 453 | |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 454 | return 0; |
| 455 | } |
| 456 | |
| 457 | GLOBAL(void) |
| 458 | jsimd_h2v2_merged_upsample (j_decompress_ptr cinfo, |
| 459 | JSAMPIMAGE input_buf, |
| 460 | JDIMENSION in_row_group_ctr, |
| 461 | JSAMPARRAY output_buf) |
| 462 | { |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 463 | #ifdef WITH_SIMD |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 464 | if ((simd_support & JSIMD_SSE2) && |
| 465 | IS_ALIGNED_SSE(jconst_merged_upsample_sse2)) |
| 466 | jsimd_h2v2_merged_upsample_sse2(cinfo->output_width, input_buf, |
| 467 | in_row_group_ctr, output_buf); |
| 468 | else if (simd_support & JSIMD_MMX) |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 469 | jsimd_h2v2_merged_upsample_mmx(cinfo->output_width, input_buf, |
| 470 | in_row_group_ctr, output_buf); |
| 471 | #endif |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 472 | } |
| 473 | |
| 474 | GLOBAL(void) |
| 475 | jsimd_h2v1_merged_upsample (j_decompress_ptr cinfo, |
| 476 | JSAMPIMAGE input_buf, |
| 477 | JDIMENSION in_row_group_ctr, |
| 478 | JSAMPARRAY output_buf) |
| 479 | { |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 480 | #ifdef WITH_SIMD |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 481 | if ((simd_support & JSIMD_SSE2) && |
| 482 | IS_ALIGNED_SSE(jconst_merged_upsample_sse2)) |
| 483 | jsimd_h2v1_merged_upsample_sse2(cinfo->output_width, input_buf, |
| 484 | in_row_group_ctr, output_buf); |
| 485 | else if (simd_support & JSIMD_MMX) |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 486 | jsimd_h2v1_merged_upsample_mmx(cinfo->output_width, input_buf, |
| 487 | in_row_group_ctr, output_buf); |
| 488 | #endif |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 489 | } |
| 490 | |
| 491 | GLOBAL(int) |
| 492 | jsimd_can_convsamp (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 (BITS_IN_JSAMPLE != 8) |
| 500 | return 0; |
| 501 | if (sizeof(JDIMENSION) != 4) |
| 502 | return 0; |
| 503 | if (sizeof(DCTELEM) != 2) |
| 504 | return 0; |
| 505 | |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 506 | if (simd_support & JSIMD_SSE2) |
| 507 | return 1; |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 508 | if (simd_support & JSIMD_MMX) |
| 509 | return 1; |
| 510 | |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 511 | return 0; |
| 512 | } |
| 513 | |
| 514 | GLOBAL(int) |
| 515 | jsimd_can_convsamp_float (void) |
| 516 | { |
| 517 | init_simd(); |
| 518 | |
Pierre Ossman | 65d0317 | 2009-03-09 13:28:10 +0000 | [diff] [blame] | 519 | /* The code is optimised for these values only */ |
| 520 | if (DCTSIZE != 8) |
| 521 | return 0; |
| 522 | if (BITS_IN_JSAMPLE != 8) |
| 523 | return 0; |
| 524 | if (sizeof(JDIMENSION) != 4) |
| 525 | return 0; |
| 526 | if (sizeof(FAST_FLOAT) != 4) |
| 527 | return 0; |
| 528 | |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 529 | if (simd_support & JSIMD_SSE2) |
| 530 | return 1; |
Pierre Ossman | 018fc42 | 2009-03-09 13:31:56 +0000 | [diff] [blame] | 531 | if (simd_support & JSIMD_SSE) |
| 532 | return 1; |
Pierre Ossman | 65d0317 | 2009-03-09 13:28:10 +0000 | [diff] [blame] | 533 | if (simd_support & JSIMD_3DNOW) |
| 534 | return 1; |
| 535 | |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 536 | return 0; |
| 537 | } |
| 538 | |
| 539 | GLOBAL(void) |
| 540 | jsimd_convsamp (JSAMPARRAY sample_data, JDIMENSION start_col, |
| 541 | DCTELEM * workspace) |
| 542 | { |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 543 | #ifdef WITH_SIMD |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 544 | if (simd_support & JSIMD_SSE2) |
| 545 | jsimd_convsamp_sse2(sample_data, start_col, workspace); |
| 546 | else if (simd_support & JSIMD_MMX) |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 547 | jsimd_convsamp_mmx(sample_data, start_col, workspace); |
| 548 | #endif |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 549 | } |
| 550 | |
| 551 | GLOBAL(void) |
| 552 | jsimd_convsamp_float (JSAMPARRAY sample_data, JDIMENSION start_col, |
| 553 | FAST_FLOAT * workspace) |
| 554 | { |
Pierre Ossman | 65d0317 | 2009-03-09 13:28:10 +0000 | [diff] [blame] | 555 | #ifdef WITH_SIMD |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 556 | if (simd_support & JSIMD_SSE2) |
| 557 | jsimd_convsamp_float_sse2(sample_data, start_col, workspace); |
| 558 | else if (simd_support & JSIMD_SSE) |
Pierre Ossman | 018fc42 | 2009-03-09 13:31:56 +0000 | [diff] [blame] | 559 | jsimd_convsamp_float_sse(sample_data, start_col, workspace); |
| 560 | else if (simd_support & JSIMD_3DNOW) |
Pierre Ossman | 65d0317 | 2009-03-09 13:28:10 +0000 | [diff] [blame] | 561 | jsimd_convsamp_float_3dnow(sample_data, start_col, workspace); |
| 562 | #endif |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 563 | } |
| 564 | |
| 565 | GLOBAL(int) |
| 566 | jsimd_can_fdct_islow (void) |
| 567 | { |
| 568 | init_simd(); |
| 569 | |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 570 | /* The code is optimised for these values only */ |
| 571 | if (DCTSIZE != 8) |
| 572 | return 0; |
| 573 | if (sizeof(DCTELEM) != 2) |
| 574 | return 0; |
| 575 | |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 576 | if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_fdct_islow_sse2)) |
| 577 | return 1; |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 578 | if (simd_support & JSIMD_MMX) |
| 579 | return 1; |
| 580 | |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 581 | return 0; |
| 582 | } |
| 583 | |
| 584 | GLOBAL(int) |
| 585 | jsimd_can_fdct_ifast (void) |
| 586 | { |
| 587 | init_simd(); |
| 588 | |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 589 | /* The code is optimised for these values only */ |
| 590 | if (DCTSIZE != 8) |
| 591 | return 0; |
| 592 | if (sizeof(DCTELEM) != 2) |
| 593 | return 0; |
| 594 | |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 595 | if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_fdct_ifast_sse2)) |
| 596 | return 1; |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 597 | if (simd_support & JSIMD_MMX) |
| 598 | return 1; |
| 599 | |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 600 | return 0; |
| 601 | } |
| 602 | |
| 603 | GLOBAL(int) |
| 604 | jsimd_can_fdct_float (void) |
| 605 | { |
| 606 | init_simd(); |
| 607 | |
Pierre Ossman | 65d0317 | 2009-03-09 13:28:10 +0000 | [diff] [blame] | 608 | /* The code is optimised for these values only */ |
| 609 | if (DCTSIZE != 8) |
| 610 | return 0; |
| 611 | if (sizeof(FAST_FLOAT) != 4) |
| 612 | return 0; |
| 613 | |
Pierre Ossman | 018fc42 | 2009-03-09 13:31:56 +0000 | [diff] [blame] | 614 | if ((simd_support & JSIMD_SSE) && IS_ALIGNED_SSE(jconst_fdct_float_sse)) |
| 615 | return 1; |
Pierre Ossman | 65d0317 | 2009-03-09 13:28:10 +0000 | [diff] [blame] | 616 | if (simd_support & JSIMD_3DNOW) |
| 617 | return 1; |
| 618 | |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 619 | return 0; |
| 620 | } |
| 621 | |
| 622 | GLOBAL(void) |
| 623 | jsimd_fdct_islow (DCTELEM * data) |
| 624 | { |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 625 | #ifdef WITH_SIMD |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 626 | if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_fdct_islow_sse2)) |
| 627 | jsimd_fdct_islow_sse2(data); |
| 628 | else if (simd_support & JSIMD_MMX) |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 629 | jsimd_fdct_islow_mmx(data); |
| 630 | #endif |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 631 | } |
| 632 | |
| 633 | GLOBAL(void) |
| 634 | jsimd_fdct_ifast (DCTELEM * data) |
| 635 | { |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 636 | #ifdef WITH_SIMD |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 637 | if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_fdct_islow_sse2)) |
| 638 | jsimd_fdct_ifast_sse2(data); |
| 639 | else if (simd_support & JSIMD_MMX) |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 640 | jsimd_fdct_ifast_mmx(data); |
| 641 | #endif |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 642 | } |
| 643 | |
| 644 | GLOBAL(void) |
| 645 | jsimd_fdct_float (FAST_FLOAT * data) |
| 646 | { |
Pierre Ossman | 65d0317 | 2009-03-09 13:28:10 +0000 | [diff] [blame] | 647 | #ifdef WITH_SIMD |
Pierre Ossman | 018fc42 | 2009-03-09 13:31:56 +0000 | [diff] [blame] | 648 | if ((simd_support & JSIMD_SSE) && IS_ALIGNED_SSE(jconst_fdct_float_sse)) |
| 649 | jsimd_fdct_float_sse(data); |
| 650 | else if (simd_support & JSIMD_3DNOW) |
Pierre Ossman | 65d0317 | 2009-03-09 13:28:10 +0000 | [diff] [blame] | 651 | jsimd_fdct_float_3dnow(data); |
| 652 | #endif |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 653 | } |
| 654 | |
| 655 | GLOBAL(int) |
| 656 | jsimd_can_quantize (void) |
| 657 | { |
| 658 | init_simd(); |
| 659 | |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 660 | /* The code is optimised for these values only */ |
| 661 | if (DCTSIZE != 8) |
| 662 | return 0; |
| 663 | if (sizeof(JCOEF) != 2) |
| 664 | return 0; |
| 665 | if (sizeof(DCTELEM) != 2) |
| 666 | return 0; |
| 667 | |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 668 | if (simd_support & JSIMD_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_quantize_float (void) |
| 678 | { |
| 679 | init_simd(); |
| 680 | |
Pierre Ossman | 65d0317 | 2009-03-09 13:28:10 +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 (sizeof(FAST_FLOAT) != 4) |
| 687 | return 0; |
| 688 | |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 689 | if (simd_support & JSIMD_SSE2) |
| 690 | return 1; |
Pierre Ossman | 018fc42 | 2009-03-09 13:31:56 +0000 | [diff] [blame] | 691 | if (simd_support & JSIMD_SSE) |
| 692 | return 1; |
Pierre Ossman | 65d0317 | 2009-03-09 13:28:10 +0000 | [diff] [blame] | 693 | if (simd_support & JSIMD_3DNOW) |
| 694 | return 1; |
| 695 | |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 696 | return 0; |
| 697 | } |
| 698 | |
| 699 | GLOBAL(void) |
| 700 | jsimd_quantize (JCOEFPTR coef_block, DCTELEM * divisors, |
| 701 | DCTELEM * workspace) |
| 702 | { |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 703 | #ifdef WITH_SIMD |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 704 | if (simd_support & JSIMD_SSE2) |
| 705 | jsimd_quantize_sse2(coef_block, divisors, workspace); |
| 706 | else if (simd_support & JSIMD_MMX) |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 707 | jsimd_quantize_mmx(coef_block, divisors, workspace); |
| 708 | #endif |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 709 | } |
| 710 | |
| 711 | GLOBAL(void) |
| 712 | jsimd_quantize_float (JCOEFPTR coef_block, FAST_FLOAT * divisors, |
| 713 | FAST_FLOAT * workspace) |
| 714 | { |
Pierre Ossman | 65d0317 | 2009-03-09 13:28:10 +0000 | [diff] [blame] | 715 | #ifdef WITH_SIMD |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 716 | if (simd_support & JSIMD_SSE2) |
| 717 | jsimd_quantize_float_sse2(coef_block, divisors, workspace); |
| 718 | else if (simd_support & JSIMD_SSE) |
Pierre Ossman | 018fc42 | 2009-03-09 13:31:56 +0000 | [diff] [blame] | 719 | jsimd_quantize_float_sse(coef_block, divisors, workspace); |
| 720 | else if (simd_support & JSIMD_3DNOW) |
Pierre Ossman | 65d0317 | 2009-03-09 13:28:10 +0000 | [diff] [blame] | 721 | jsimd_quantize_float_3dnow(coef_block, divisors, workspace); |
| 722 | #endif |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 723 | } |
| 724 | |
| 725 | GLOBAL(int) |
| 726 | jsimd_can_idct_2x2 (void) |
| 727 | { |
| 728 | init_simd(); |
| 729 | |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 730 | /* The code is optimised for these values only */ |
| 731 | if (DCTSIZE != 8) |
| 732 | return 0; |
| 733 | if (sizeof(JCOEF) != 2) |
| 734 | return 0; |
| 735 | if (BITS_IN_JSAMPLE != 8) |
| 736 | return 0; |
| 737 | if (sizeof(JDIMENSION) != 4) |
| 738 | return 0; |
| 739 | if (sizeof(ISLOW_MULT_TYPE) != 2) |
| 740 | return 0; |
| 741 | |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 742 | if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_red_sse2)) |
| 743 | return 1; |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 744 | if (simd_support & JSIMD_MMX) |
| 745 | return 1; |
| 746 | |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 747 | return 0; |
| 748 | } |
| 749 | |
| 750 | GLOBAL(int) |
| 751 | jsimd_can_idct_4x4 (void) |
| 752 | { |
| 753 | init_simd(); |
| 754 | |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 755 | /* The code is optimised for these values only */ |
| 756 | if (DCTSIZE != 8) |
| 757 | return 0; |
| 758 | if (sizeof(JCOEF) != 2) |
| 759 | return 0; |
| 760 | if (BITS_IN_JSAMPLE != 8) |
| 761 | return 0; |
| 762 | if (sizeof(JDIMENSION) != 4) |
| 763 | return 0; |
| 764 | if (sizeof(ISLOW_MULT_TYPE) != 2) |
| 765 | return 0; |
| 766 | |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 767 | if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_red_sse2)) |
| 768 | return 1; |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 769 | if (simd_support & JSIMD_MMX) |
| 770 | return 1; |
| 771 | |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 772 | return 0; |
| 773 | } |
| 774 | |
| 775 | GLOBAL(void) |
| 776 | jsimd_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
| 777 | JCOEFPTR coef_block, JSAMPARRAY output_buf, |
| 778 | JDIMENSION output_col) |
| 779 | { |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 780 | #if WITH_SIMD |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 781 | if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_red_sse2)) |
| 782 | jsimd_idct_2x2_sse2(compptr->dct_table, coef_block, output_buf, output_col); |
| 783 | else if (simd_support & JSIMD_MMX) |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 784 | jsimd_idct_2x2_mmx(compptr->dct_table, coef_block, output_buf, output_col); |
| 785 | #endif |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 786 | } |
| 787 | |
| 788 | GLOBAL(void) |
| 789 | jsimd_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
| 790 | JCOEFPTR coef_block, JSAMPARRAY output_buf, |
| 791 | JDIMENSION output_col) |
| 792 | { |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 793 | #if WITH_SIMD |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 794 | if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_red_sse2)) |
| 795 | jsimd_idct_4x4_sse2(compptr->dct_table, coef_block, output_buf, output_col); |
| 796 | else if (simd_support & JSIMD_MMX) |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 797 | jsimd_idct_4x4_mmx(compptr->dct_table, coef_block, output_buf, output_col); |
| 798 | #endif |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 799 | } |
| 800 | |
| 801 | GLOBAL(int) |
| 802 | jsimd_can_idct_islow (void) |
| 803 | { |
| 804 | init_simd(); |
| 805 | |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 806 | /* The code is optimised for these values only */ |
| 807 | if (DCTSIZE != 8) |
| 808 | return 0; |
| 809 | if (sizeof(JCOEF) != 2) |
| 810 | return 0; |
| 811 | if (BITS_IN_JSAMPLE != 8) |
| 812 | return 0; |
| 813 | if (sizeof(JDIMENSION) != 4) |
| 814 | return 0; |
| 815 | if (sizeof(ISLOW_MULT_TYPE) != 2) |
| 816 | return 0; |
| 817 | |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 818 | if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_islow_sse2)) |
| 819 | return 1; |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 820 | if (simd_support & JSIMD_MMX) |
| 821 | return 1; |
| 822 | |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 823 | return 0; |
| 824 | } |
| 825 | |
| 826 | GLOBAL(int) |
| 827 | jsimd_can_idct_ifast (void) |
| 828 | { |
| 829 | init_simd(); |
| 830 | |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 831 | /* The code is optimised for these values only */ |
| 832 | if (DCTSIZE != 8) |
| 833 | return 0; |
| 834 | if (sizeof(JCOEF) != 2) |
| 835 | return 0; |
| 836 | if (BITS_IN_JSAMPLE != 8) |
| 837 | return 0; |
| 838 | if (sizeof(JDIMENSION) != 4) |
| 839 | return 0; |
| 840 | if (sizeof(IFAST_MULT_TYPE) != 2) |
| 841 | return 0; |
| 842 | if (IFAST_SCALE_BITS != 2) |
| 843 | return 0; |
| 844 | |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 845 | if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_ifast_sse2)) |
| 846 | return 1; |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 847 | if (simd_support & JSIMD_MMX) |
| 848 | return 1; |
| 849 | |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 850 | return 0; |
| 851 | } |
| 852 | |
| 853 | GLOBAL(int) |
| 854 | jsimd_can_idct_float (void) |
| 855 | { |
| 856 | init_simd(); |
| 857 | |
Pierre Ossman | 65d0317 | 2009-03-09 13:28:10 +0000 | [diff] [blame] | 858 | if (DCTSIZE != 8) |
| 859 | return 0; |
| 860 | if (sizeof(JCOEF) != 2) |
| 861 | return 0; |
| 862 | if (BITS_IN_JSAMPLE != 8) |
| 863 | return 0; |
| 864 | if (sizeof(JDIMENSION) != 4) |
| 865 | return 0; |
| 866 | if (sizeof(FAST_FLOAT) != 4) |
| 867 | return 0; |
| 868 | if (sizeof(FLOAT_MULT_TYPE) != 4) |
| 869 | return 0; |
| 870 | |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 871 | if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_float_sse2)) |
| 872 | return 1; |
Pierre Ossman | 018fc42 | 2009-03-09 13:31:56 +0000 | [diff] [blame] | 873 | if ((simd_support & JSIMD_SSE) && IS_ALIGNED_SSE(jconst_idct_float_sse)) |
| 874 | return 1; |
Pierre Ossman | 65d0317 | 2009-03-09 13:28:10 +0000 | [diff] [blame] | 875 | if (simd_support & JSIMD_3DNOW) |
| 876 | return 1; |
| 877 | |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 878 | return 0; |
| 879 | } |
| 880 | |
| 881 | GLOBAL(void) |
| 882 | jsimd_idct_islow (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
| 883 | JCOEFPTR coef_block, JSAMPARRAY output_buf, |
| 884 | JDIMENSION output_col) |
| 885 | { |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 886 | #if WITH_SIMD |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 887 | if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_islow_sse2)) |
| 888 | jsimd_idct_islow_sse2(compptr->dct_table, coef_block, output_buf, output_col); |
| 889 | else if (simd_support & JSIMD_MMX) |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 890 | jsimd_idct_islow_mmx(compptr->dct_table, coef_block, output_buf, output_col); |
| 891 | #endif |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 892 | } |
| 893 | |
| 894 | GLOBAL(void) |
| 895 | jsimd_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
| 896 | JCOEFPTR coef_block, JSAMPARRAY output_buf, |
| 897 | JDIMENSION output_col) |
| 898 | { |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 899 | #if WITH_SIMD |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 900 | if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_ifast_sse2)) |
| 901 | jsimd_idct_ifast_sse2(compptr->dct_table, coef_block, output_buf, output_col); |
| 902 | else if (simd_support & JSIMD_MMX) |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 903 | jsimd_idct_ifast_mmx(compptr->dct_table, coef_block, output_buf, output_col); |
| 904 | #endif |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 905 | } |
| 906 | |
| 907 | GLOBAL(void) |
| 908 | jsimd_idct_float (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
| 909 | JCOEFPTR coef_block, JSAMPARRAY output_buf, |
| 910 | JDIMENSION output_col) |
| 911 | { |
Pierre Ossman | 65d0317 | 2009-03-09 13:28:10 +0000 | [diff] [blame] | 912 | #if WITH_SIMD |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 913 | if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_float_sse2)) |
| 914 | jsimd_idct_float_sse2(compptr->dct_table, coef_block, |
| 915 | output_buf, output_col); |
| 916 | 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] | 917 | jsimd_idct_float_sse(compptr->dct_table, coef_block, |
| 918 | output_buf, output_col); |
| 919 | else if (simd_support & JSIMD_3DNOW) |
Pierre Ossman | 65d0317 | 2009-03-09 13:28:10 +0000 | [diff] [blame] | 920 | jsimd_idct_float_3dnow(compptr->dct_table, coef_block, |
| 921 | output_buf, output_col); |
| 922 | #endif |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 923 | } |
| 924 | |