OLD | NEW |
1 /* | 1 /* |
2 * jsimd_i386.c | 2 * jsimd_i386.c |
3 * | 3 * |
4 * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB | 4 * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB |
5 * Copyright 2009 D. R. Commander | 5 * Copyright 2009-2011 D. R. Commander |
6 * | 6 * |
7 * Based on the x86 SIMD extension for IJG JPEG library, | 7 * Based on the x86 SIMD extension for IJG JPEG library, |
8 * Copyright (C) 1999-2006, MIYASAKA Masaru. | 8 * Copyright (C) 1999-2006, MIYASAKA Masaru. |
| 9 * For conditions of distribution and use, see copyright notice in jsimdext.inc |
9 * | 10 * |
10 * This file contains the interface between the "normal" portions | 11 * This file contains the interface between the "normal" portions |
11 * of the library and the SIMD implementations when running on a | 12 * of the library and the SIMD implementations when running on a |
12 * 32-bit x86 architecture. | 13 * 32-bit x86 architecture. |
13 */ | 14 */ |
14 | 15 |
15 #define JPEG_INTERNALS | 16 #define JPEG_INTERNALS |
16 #include "../jinclude.h" | 17 #include "../jinclude.h" |
17 #include "../jpeglib.h" | 18 #include "../jpeglib.h" |
18 #include "../jsimd.h" | 19 #include "../jsimd.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 if ((simd_support & JSIMD_SSE2) && | 77 if ((simd_support & JSIMD_SSE2) && |
77 IS_ALIGNED_SSE(jconst_rgb_ycc_convert_sse2)) | 78 IS_ALIGNED_SSE(jconst_rgb_ycc_convert_sse2)) |
78 return 1; | 79 return 1; |
79 if (simd_support & JSIMD_MMX) | 80 if (simd_support & JSIMD_MMX) |
80 return 1; | 81 return 1; |
81 | 82 |
82 return 0; | 83 return 0; |
83 } | 84 } |
84 | 85 |
85 GLOBAL(int) | 86 GLOBAL(int) |
| 87 jsimd_can_rgb_gray (void) |
| 88 { |
| 89 init_simd(); |
| 90 |
| 91 /* The code is optimised for these values only */ |
| 92 if (BITS_IN_JSAMPLE != 8) |
| 93 return 0; |
| 94 if (sizeof(JDIMENSION) != 4) |
| 95 return 0; |
| 96 if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4)) |
| 97 return 0; |
| 98 |
| 99 if ((simd_support & JSIMD_SSE2) && |
| 100 IS_ALIGNED_SSE(jconst_rgb_gray_convert_sse2)) |
| 101 return 1; |
| 102 if (simd_support & JSIMD_MMX) |
| 103 return 1; |
| 104 |
| 105 return 0; |
| 106 } |
| 107 |
| 108 GLOBAL(int) |
86 jsimd_can_ycc_rgb (void) | 109 jsimd_can_ycc_rgb (void) |
87 { | 110 { |
88 init_simd(); | 111 init_simd(); |
89 | 112 |
90 /* The code is optimised for these values only */ | 113 /* The code is optimised for these values only */ |
91 if (BITS_IN_JSAMPLE != 8) | 114 if (BITS_IN_JSAMPLE != 8) |
92 return 0; | 115 return 0; |
93 if (sizeof(JDIMENSION) != 4) | 116 if (sizeof(JDIMENSION) != 4) |
94 return 0; | 117 return 0; |
95 if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4)) | 118 if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4)) |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 if ((simd_support & JSIMD_SSE2) && | 170 if ((simd_support & JSIMD_SSE2) && |
148 IS_ALIGNED_SSE(jconst_rgb_ycc_convert_sse2)) | 171 IS_ALIGNED_SSE(jconst_rgb_ycc_convert_sse2)) |
149 sse2fct(cinfo->image_width, input_buf, | 172 sse2fct(cinfo->image_width, input_buf, |
150 output_buf, output_row, num_rows); | 173 output_buf, output_row, num_rows); |
151 else if (simd_support & JSIMD_MMX) | 174 else if (simd_support & JSIMD_MMX) |
152 mmxfct(cinfo->image_width, input_buf, | 175 mmxfct(cinfo->image_width, input_buf, |
153 output_buf, output_row, num_rows); | 176 output_buf, output_row, num_rows); |
154 } | 177 } |
155 | 178 |
156 GLOBAL(void) | 179 GLOBAL(void) |
| 180 jsimd_rgb_gray_convert (j_compress_ptr cinfo, |
| 181 JSAMPARRAY input_buf, JSAMPIMAGE output_buf, |
| 182 JDIMENSION output_row, int num_rows) |
| 183 { |
| 184 void (*sse2fct)(JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JDIMENSION, int); |
| 185 void (*mmxfct)(JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JDIMENSION, int); |
| 186 |
| 187 switch(cinfo->in_color_space) |
| 188 { |
| 189 case JCS_EXT_RGB: |
| 190 sse2fct=jsimd_extrgb_gray_convert_sse2; |
| 191 mmxfct=jsimd_extrgb_gray_convert_mmx; |
| 192 break; |
| 193 case JCS_EXT_RGBX: |
| 194 sse2fct=jsimd_extrgbx_gray_convert_sse2; |
| 195 mmxfct=jsimd_extrgbx_gray_convert_mmx; |
| 196 break; |
| 197 case JCS_EXT_BGR: |
| 198 sse2fct=jsimd_extbgr_gray_convert_sse2; |
| 199 mmxfct=jsimd_extbgr_gray_convert_mmx; |
| 200 break; |
| 201 case JCS_EXT_BGRX: |
| 202 sse2fct=jsimd_extbgrx_gray_convert_sse2; |
| 203 mmxfct=jsimd_extbgrx_gray_convert_mmx; |
| 204 break; |
| 205 case JCS_EXT_XBGR: |
| 206 sse2fct=jsimd_extxbgr_gray_convert_sse2; |
| 207 mmxfct=jsimd_extxbgr_gray_convert_mmx; |
| 208 break; |
| 209 case JCS_EXT_XRGB: |
| 210 sse2fct=jsimd_extxrgb_gray_convert_sse2; |
| 211 mmxfct=jsimd_extxrgb_gray_convert_mmx; |
| 212 break; |
| 213 default: |
| 214 sse2fct=jsimd_rgb_gray_convert_sse2; |
| 215 mmxfct=jsimd_rgb_gray_convert_mmx; |
| 216 break; |
| 217 } |
| 218 |
| 219 if ((simd_support & JSIMD_SSE2) && |
| 220 IS_ALIGNED_SSE(jconst_rgb_gray_convert_sse2)) |
| 221 sse2fct(cinfo->image_width, input_buf, |
| 222 output_buf, output_row, num_rows); |
| 223 else if (simd_support & JSIMD_MMX) |
| 224 mmxfct(cinfo->image_width, input_buf, |
| 225 output_buf, output_row, num_rows); |
| 226 } |
| 227 |
| 228 GLOBAL(void) |
157 jsimd_ycc_rgb_convert (j_decompress_ptr cinfo, | 229 jsimd_ycc_rgb_convert (j_decompress_ptr cinfo, |
158 JSAMPIMAGE input_buf, JDIMENSION input_row, | 230 JSAMPIMAGE input_buf, JDIMENSION input_row, |
159 JSAMPARRAY output_buf, int num_rows) | 231 JSAMPARRAY output_buf, int num_rows) |
160 { | 232 { |
161 void (*sse2fct)(JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY, int); | 233 void (*sse2fct)(JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY, int); |
162 void (*mmxfct)(JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY, int); | 234 void (*mmxfct)(JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY, int); |
163 | 235 |
164 switch(cinfo->out_color_space) | 236 switch(cinfo->out_color_space) |
165 { | 237 { |
166 case JCS_EXT_RGB: | 238 case JCS_EXT_RGB: |
(...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
947 jsimd_idct_float_sse2(compptr->dct_table, coef_block, | 1019 jsimd_idct_float_sse2(compptr->dct_table, coef_block, |
948 output_buf, output_col); | 1020 output_buf, output_col); |
949 else if ((simd_support & JSIMD_SSE) && IS_ALIGNED_SSE(jconst_idct_float_sse)) | 1021 else if ((simd_support & JSIMD_SSE) && IS_ALIGNED_SSE(jconst_idct_float_sse)) |
950 jsimd_idct_float_sse(compptr->dct_table, coef_block, | 1022 jsimd_idct_float_sse(compptr->dct_table, coef_block, |
951 output_buf, output_col); | 1023 output_buf, output_col); |
952 else if (simd_support & JSIMD_3DNOW) | 1024 else if (simd_support & JSIMD_3DNOW) |
953 jsimd_idct_float_3dnow(compptr->dct_table, coef_block, | 1025 jsimd_idct_float_3dnow(compptr->dct_table, coef_block, |
954 output_buf, output_col); | 1026 output_buf, output_col); |
955 } | 1027 } |
956 | 1028 |
OLD | NEW |