Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 1 | /* |
Pierre Ossman | ba82ddf | 2009-06-29 11:20:42 +0000 | [diff] [blame] | 2 | * jsimd_i386.c |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 3 | * |
| 4 | * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB |
Alex Naidis | 6eb7d37 | 2016-10-16 23:10:08 +0200 | [diff] [blame] | 5 | * Copyright (C) 2009-2011, 2013-2014, 2016, D. R. Commander. |
| 6 | * Copyright (C) 2015, Matthieu Darbois. |
DRC | 1a45b81 | 2014-05-09 18:06:58 +0000 | [diff] [blame] | 7 | * |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 8 | * Based on the x86 SIMD extension for IJG JPEG library, |
| 9 | * Copyright (C) 1999-2006, MIYASAKA Masaru. |
DRC | af1ca9b | 2011-02-02 05:42:37 +0000 | [diff] [blame] | 10 | * For conditions of distribution and use, see copyright notice in jsimdext.inc |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 11 | * |
| 12 | * This file contains the interface between the "normal" portions |
Pierre Ossman | ba82ddf | 2009-06-29 11:20:42 +0000 | [diff] [blame] | 13 | * of the library and the SIMD implementations when running on a |
| 14 | * 32-bit x86 architecture. |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | #define JPEG_INTERNALS |
Pierre Ossman | ba82ddf | 2009-06-29 11:20:42 +0000 | [diff] [blame] | 18 | #include "../jinclude.h" |
| 19 | #include "../jpeglib.h" |
| 20 | #include "../jsimd.h" |
| 21 | #include "../jdct.h" |
| 22 | #include "../jsimddct.h" |
Peter Åstrand | adfd233 | 2009-08-19 13:53:48 +0000 | [diff] [blame] | 23 | #include "jsimd.h" |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 24 | |
Pierre Ossman | 018fc42 | 2009-03-09 13:31:56 +0000 | [diff] [blame] | 25 | /* |
| 26 | * In the PIC cases, we have no guarantee that constants will keep |
| 27 | * their alignment. This macro allows us to verify it at runtime. |
| 28 | */ |
Pierre Ossman | 018fc42 | 2009-03-09 13:31:56 +0000 | [diff] [blame] | 29 | #define IS_ALIGNED(ptr, order) (((unsigned)ptr & ((1 << order) - 1)) == 0) |
Pierre Ossman | 018fc42 | 2009-03-09 13:31:56 +0000 | [diff] [blame] | 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; |
Alex Naidis | 6eb7d37 | 2016-10-16 23:10:08 +0200 | [diff] [blame] | 34 | static unsigned int simd_huffman = 1; |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 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 | char *env = NULL; |
Pierre Ossman | ba82ddf | 2009-06-29 11:20:42 +0000 | [diff] [blame] | 45 | |
DRC | d65d99a | 2012-01-31 03:39:23 +0000 | [diff] [blame] | 46 | if (simd_support != ~0U) |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 47 | return; |
| 48 | |
Pierre Ossman | 2ae181c | 2009-03-09 13:21:27 +0000 | [diff] [blame] | 49 | simd_support = jpeg_simd_cpu_support(); |
Pierre Ossman | ba82ddf | 2009-06-29 11:20:42 +0000 | [diff] [blame] | 50 | |
| 51 | /* Force different settings through environment variables */ |
| 52 | env = getenv("JSIMD_FORCEMMX"); |
| 53 | if ((env != NULL) && (strcmp(env, "1") == 0)) |
DRC | f8b77c4 | 2010-03-03 08:46:29 +0000 | [diff] [blame] | 54 | simd_support &= JSIMD_MMX; |
Pierre Ossman | ba82ddf | 2009-06-29 11:20:42 +0000 | [diff] [blame] | 55 | env = getenv("JSIMD_FORCE3DNOW"); |
| 56 | if ((env != NULL) && (strcmp(env, "1") == 0)) |
DRC | f8b77c4 | 2010-03-03 08:46:29 +0000 | [diff] [blame] | 57 | simd_support &= JSIMD_3DNOW|JSIMD_MMX; |
Pierre Ossman | ba82ddf | 2009-06-29 11:20:42 +0000 | [diff] [blame] | 58 | env = getenv("JSIMD_FORCESSE"); |
| 59 | if ((env != NULL) && (strcmp(env, "1") == 0)) |
DRC | f8b77c4 | 2010-03-03 08:46:29 +0000 | [diff] [blame] | 60 | simd_support &= JSIMD_SSE|JSIMD_MMX; |
Pierre Ossman | ba82ddf | 2009-06-29 11:20:42 +0000 | [diff] [blame] | 61 | env = getenv("JSIMD_FORCESSE2"); |
| 62 | if ((env != NULL) && (strcmp(env, "1") == 0)) |
DRC | f8b77c4 | 2010-03-03 08:46:29 +0000 | [diff] [blame] | 63 | simd_support &= JSIMD_SSE2; |
DRC | 19eeaa7 | 2013-10-31 07:40:24 +0000 | [diff] [blame] | 64 | env = getenv("JSIMD_FORCENONE"); |
| 65 | if ((env != NULL) && (strcmp(env, "1") == 0)) |
| 66 | simd_support = 0; |
Alex Naidis | 6eb7d37 | 2016-10-16 23:10:08 +0200 | [diff] [blame] | 67 | env = getenv("JSIMD_NOHUFFENC"); |
| 68 | if ((env != NULL) && (strcmp(env, "1") == 0)) |
| 69 | simd_huffman = 0; |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 70 | } |
| 71 | |
| 72 | GLOBAL(int) |
| 73 | jsimd_can_rgb_ycc (void) |
| 74 | { |
| 75 | init_simd(); |
| 76 | |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 77 | /* The code is optimised for these values only */ |
| 78 | if (BITS_IN_JSAMPLE != 8) |
| 79 | return 0; |
| 80 | if (sizeof(JDIMENSION) != 4) |
| 81 | return 0; |
| 82 | if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4)) |
| 83 | return 0; |
| 84 | |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 85 | if ((simd_support & JSIMD_SSE2) && |
| 86 | IS_ALIGNED_SSE(jconst_rgb_ycc_convert_sse2)) |
| 87 | return 1; |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 88 | if (simd_support & JSIMD_MMX) |
| 89 | return 1; |
| 90 | |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 91 | return 0; |
| 92 | } |
| 93 | |
| 94 | GLOBAL(int) |
DRC | c866633 | 2011-02-18 11:23:45 +0000 | [diff] [blame] | 95 | jsimd_can_rgb_gray (void) |
| 96 | { |
| 97 | init_simd(); |
| 98 | |
| 99 | /* The code is optimised for these values only */ |
| 100 | if (BITS_IN_JSAMPLE != 8) |
| 101 | return 0; |
| 102 | if (sizeof(JDIMENSION) != 4) |
| 103 | return 0; |
| 104 | if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4)) |
| 105 | return 0; |
| 106 | |
| 107 | if ((simd_support & JSIMD_SSE2) && |
| 108 | IS_ALIGNED_SSE(jconst_rgb_gray_convert_sse2)) |
| 109 | return 1; |
| 110 | if (simd_support & JSIMD_MMX) |
| 111 | return 1; |
| 112 | |
| 113 | return 0; |
| 114 | } |
| 115 | |
| 116 | GLOBAL(int) |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 117 | jsimd_can_ycc_rgb (void) |
| 118 | { |
| 119 | init_simd(); |
| 120 | |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 121 | /* The code is optimised for these values only */ |
| 122 | if (BITS_IN_JSAMPLE != 8) |
| 123 | return 0; |
| 124 | if (sizeof(JDIMENSION) != 4) |
| 125 | return 0; |
| 126 | if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4)) |
| 127 | return 0; |
| 128 | |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 129 | if ((simd_support & JSIMD_SSE2) && |
| 130 | IS_ALIGNED_SSE(jconst_ycc_rgb_convert_sse2)) |
| 131 | return 1; |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 132 | if (simd_support & JSIMD_MMX) |
| 133 | return 1; |
| 134 | |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 135 | return 0; |
| 136 | } |
| 137 | |
DRC | d729f4d | 2014-08-23 15:47:51 +0000 | [diff] [blame] | 138 | GLOBAL(int) |
| 139 | jsimd_can_ycc_rgb565 (void) |
| 140 | { |
| 141 | return 0; |
| 142 | } |
| 143 | |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 144 | GLOBAL(void) |
| 145 | jsimd_rgb_ycc_convert (j_compress_ptr cinfo, |
| 146 | JSAMPARRAY input_buf, JSAMPIMAGE output_buf, |
| 147 | JDIMENSION output_row, int num_rows) |
| 148 | { |
DRC | f25c071 | 2009-04-03 12:00:51 +0000 | [diff] [blame] | 149 | void (*sse2fct)(JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JDIMENSION, int); |
| 150 | void (*mmxfct)(JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JDIMENSION, int); |
Pierre Ossman | ba82ddf | 2009-06-29 11:20:42 +0000 | [diff] [blame] | 151 | |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 152 | switch(cinfo->in_color_space) { |
DRC | f25c071 | 2009-04-03 12:00:51 +0000 | [diff] [blame] | 153 | case JCS_EXT_RGB: |
| 154 | sse2fct=jsimd_extrgb_ycc_convert_sse2; |
| 155 | mmxfct=jsimd_extrgb_ycc_convert_mmx; |
| 156 | break; |
| 157 | case JCS_EXT_RGBX: |
DRC | 67ce3b2 | 2011-12-19 02:21:03 +0000 | [diff] [blame] | 158 | case JCS_EXT_RGBA: |
DRC | f25c071 | 2009-04-03 12:00:51 +0000 | [diff] [blame] | 159 | sse2fct=jsimd_extrgbx_ycc_convert_sse2; |
| 160 | mmxfct=jsimd_extrgbx_ycc_convert_mmx; |
| 161 | break; |
| 162 | case JCS_EXT_BGR: |
| 163 | sse2fct=jsimd_extbgr_ycc_convert_sse2; |
| 164 | mmxfct=jsimd_extbgr_ycc_convert_mmx; |
| 165 | break; |
| 166 | case JCS_EXT_BGRX: |
DRC | 67ce3b2 | 2011-12-19 02:21:03 +0000 | [diff] [blame] | 167 | case JCS_EXT_BGRA: |
DRC | f25c071 | 2009-04-03 12:00:51 +0000 | [diff] [blame] | 168 | sse2fct=jsimd_extbgrx_ycc_convert_sse2; |
| 169 | mmxfct=jsimd_extbgrx_ycc_convert_mmx; |
| 170 | break; |
| 171 | case JCS_EXT_XBGR: |
DRC | 67ce3b2 | 2011-12-19 02:21:03 +0000 | [diff] [blame] | 172 | case JCS_EXT_ABGR: |
DRC | f25c071 | 2009-04-03 12:00:51 +0000 | [diff] [blame] | 173 | sse2fct=jsimd_extxbgr_ycc_convert_sse2; |
| 174 | mmxfct=jsimd_extxbgr_ycc_convert_mmx; |
| 175 | break; |
| 176 | case JCS_EXT_XRGB: |
DRC | 67ce3b2 | 2011-12-19 02:21:03 +0000 | [diff] [blame] | 177 | case JCS_EXT_ARGB: |
DRC | f25c071 | 2009-04-03 12:00:51 +0000 | [diff] [blame] | 178 | sse2fct=jsimd_extxrgb_ycc_convert_sse2; |
| 179 | mmxfct=jsimd_extxrgb_ycc_convert_mmx; |
| 180 | break; |
| 181 | default: |
| 182 | sse2fct=jsimd_rgb_ycc_convert_sse2; |
| 183 | mmxfct=jsimd_rgb_ycc_convert_mmx; |
| 184 | break; |
| 185 | } |
Pierre Ossman | ba82ddf | 2009-06-29 11:20:42 +0000 | [diff] [blame] | 186 | |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 187 | if ((simd_support & JSIMD_SSE2) && |
| 188 | IS_ALIGNED_SSE(jconst_rgb_ycc_convert_sse2)) |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 189 | sse2fct(cinfo->image_width, input_buf, output_buf, output_row, num_rows); |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 190 | else if (simd_support & JSIMD_MMX) |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 191 | mmxfct(cinfo->image_width, input_buf, output_buf, output_row, num_rows); |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 192 | } |
| 193 | |
| 194 | GLOBAL(void) |
DRC | c866633 | 2011-02-18 11:23:45 +0000 | [diff] [blame] | 195 | jsimd_rgb_gray_convert (j_compress_ptr cinfo, |
| 196 | JSAMPARRAY input_buf, JSAMPIMAGE output_buf, |
| 197 | JDIMENSION output_row, int num_rows) |
| 198 | { |
| 199 | void (*sse2fct)(JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JDIMENSION, int); |
| 200 | void (*mmxfct)(JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JDIMENSION, int); |
| 201 | |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 202 | switch(cinfo->in_color_space) { |
DRC | c866633 | 2011-02-18 11:23:45 +0000 | [diff] [blame] | 203 | case JCS_EXT_RGB: |
| 204 | sse2fct=jsimd_extrgb_gray_convert_sse2; |
| 205 | mmxfct=jsimd_extrgb_gray_convert_mmx; |
| 206 | break; |
| 207 | case JCS_EXT_RGBX: |
DRC | 67ce3b2 | 2011-12-19 02:21:03 +0000 | [diff] [blame] | 208 | case JCS_EXT_RGBA: |
DRC | c866633 | 2011-02-18 11:23:45 +0000 | [diff] [blame] | 209 | sse2fct=jsimd_extrgbx_gray_convert_sse2; |
| 210 | mmxfct=jsimd_extrgbx_gray_convert_mmx; |
| 211 | break; |
| 212 | case JCS_EXT_BGR: |
| 213 | sse2fct=jsimd_extbgr_gray_convert_sse2; |
| 214 | mmxfct=jsimd_extbgr_gray_convert_mmx; |
| 215 | break; |
| 216 | case JCS_EXT_BGRX: |
DRC | 67ce3b2 | 2011-12-19 02:21:03 +0000 | [diff] [blame] | 217 | case JCS_EXT_BGRA: |
DRC | c866633 | 2011-02-18 11:23:45 +0000 | [diff] [blame] | 218 | sse2fct=jsimd_extbgrx_gray_convert_sse2; |
| 219 | mmxfct=jsimd_extbgrx_gray_convert_mmx; |
| 220 | break; |
| 221 | case JCS_EXT_XBGR: |
DRC | 67ce3b2 | 2011-12-19 02:21:03 +0000 | [diff] [blame] | 222 | case JCS_EXT_ABGR: |
DRC | c866633 | 2011-02-18 11:23:45 +0000 | [diff] [blame] | 223 | sse2fct=jsimd_extxbgr_gray_convert_sse2; |
| 224 | mmxfct=jsimd_extxbgr_gray_convert_mmx; |
| 225 | break; |
| 226 | case JCS_EXT_XRGB: |
DRC | 67ce3b2 | 2011-12-19 02:21:03 +0000 | [diff] [blame] | 227 | case JCS_EXT_ARGB: |
DRC | c866633 | 2011-02-18 11:23:45 +0000 | [diff] [blame] | 228 | sse2fct=jsimd_extxrgb_gray_convert_sse2; |
| 229 | mmxfct=jsimd_extxrgb_gray_convert_mmx; |
| 230 | break; |
| 231 | default: |
| 232 | sse2fct=jsimd_rgb_gray_convert_sse2; |
| 233 | mmxfct=jsimd_rgb_gray_convert_mmx; |
| 234 | break; |
| 235 | } |
| 236 | |
| 237 | if ((simd_support & JSIMD_SSE2) && |
| 238 | IS_ALIGNED_SSE(jconst_rgb_gray_convert_sse2)) |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 239 | sse2fct(cinfo->image_width, input_buf, output_buf, output_row, num_rows); |
DRC | c866633 | 2011-02-18 11:23:45 +0000 | [diff] [blame] | 240 | else if (simd_support & JSIMD_MMX) |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 241 | mmxfct(cinfo->image_width, input_buf, output_buf, output_row, num_rows); |
DRC | c866633 | 2011-02-18 11:23:45 +0000 | [diff] [blame] | 242 | } |
| 243 | |
| 244 | GLOBAL(void) |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 245 | jsimd_ycc_rgb_convert (j_decompress_ptr cinfo, |
| 246 | JSAMPIMAGE input_buf, JDIMENSION input_row, |
| 247 | JSAMPARRAY output_buf, int num_rows) |
| 248 | { |
DRC | f25c071 | 2009-04-03 12:00:51 +0000 | [diff] [blame] | 249 | void (*sse2fct)(JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY, int); |
| 250 | void (*mmxfct)(JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY, int); |
Pierre Ossman | ba82ddf | 2009-06-29 11:20:42 +0000 | [diff] [blame] | 251 | |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 252 | switch(cinfo->out_color_space) { |
DRC | f25c071 | 2009-04-03 12:00:51 +0000 | [diff] [blame] | 253 | case JCS_EXT_RGB: |
| 254 | sse2fct=jsimd_ycc_extrgb_convert_sse2; |
| 255 | mmxfct=jsimd_ycc_extrgb_convert_mmx; |
| 256 | break; |
| 257 | case JCS_EXT_RGBX: |
DRC | 67ce3b2 | 2011-12-19 02:21:03 +0000 | [diff] [blame] | 258 | case JCS_EXT_RGBA: |
DRC | f25c071 | 2009-04-03 12:00:51 +0000 | [diff] [blame] | 259 | sse2fct=jsimd_ycc_extrgbx_convert_sse2; |
| 260 | mmxfct=jsimd_ycc_extrgbx_convert_mmx; |
| 261 | break; |
| 262 | case JCS_EXT_BGR: |
| 263 | sse2fct=jsimd_ycc_extbgr_convert_sse2; |
| 264 | mmxfct=jsimd_ycc_extbgr_convert_mmx; |
| 265 | break; |
| 266 | case JCS_EXT_BGRX: |
DRC | 67ce3b2 | 2011-12-19 02:21:03 +0000 | [diff] [blame] | 267 | case JCS_EXT_BGRA: |
DRC | f25c071 | 2009-04-03 12:00:51 +0000 | [diff] [blame] | 268 | sse2fct=jsimd_ycc_extbgrx_convert_sse2; |
| 269 | mmxfct=jsimd_ycc_extbgrx_convert_mmx; |
| 270 | break; |
| 271 | case JCS_EXT_XBGR: |
DRC | 67ce3b2 | 2011-12-19 02:21:03 +0000 | [diff] [blame] | 272 | case JCS_EXT_ABGR: |
DRC | f25c071 | 2009-04-03 12:00:51 +0000 | [diff] [blame] | 273 | sse2fct=jsimd_ycc_extxbgr_convert_sse2; |
| 274 | mmxfct=jsimd_ycc_extxbgr_convert_mmx; |
| 275 | break; |
| 276 | case JCS_EXT_XRGB: |
DRC | 67ce3b2 | 2011-12-19 02:21:03 +0000 | [diff] [blame] | 277 | case JCS_EXT_ARGB: |
DRC | f25c071 | 2009-04-03 12:00:51 +0000 | [diff] [blame] | 278 | sse2fct=jsimd_ycc_extxrgb_convert_sse2; |
| 279 | mmxfct=jsimd_ycc_extxrgb_convert_mmx; |
| 280 | break; |
| 281 | default: |
| 282 | sse2fct=jsimd_ycc_rgb_convert_sse2; |
| 283 | mmxfct=jsimd_ycc_rgb_convert_mmx; |
| 284 | break; |
| 285 | } |
Pierre Ossman | ba82ddf | 2009-06-29 11:20:42 +0000 | [diff] [blame] | 286 | |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 287 | if ((simd_support & JSIMD_SSE2) && |
| 288 | IS_ALIGNED_SSE(jconst_ycc_rgb_convert_sse2)) |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 289 | sse2fct(cinfo->output_width, input_buf, input_row, output_buf, num_rows); |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 290 | else if (simd_support & JSIMD_MMX) |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 291 | mmxfct(cinfo->output_width, input_buf, input_row, output_buf, num_rows); |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 292 | } |
| 293 | |
DRC | d729f4d | 2014-08-23 15:47:51 +0000 | [diff] [blame] | 294 | GLOBAL(void) |
| 295 | jsimd_ycc_rgb565_convert (j_decompress_ptr cinfo, |
| 296 | JSAMPIMAGE input_buf, JDIMENSION input_row, |
| 297 | JSAMPARRAY output_buf, int num_rows) |
| 298 | { |
| 299 | } |
| 300 | |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 301 | GLOBAL(int) |
| 302 | jsimd_can_h2v2_downsample (void) |
| 303 | { |
| 304 | init_simd(); |
| 305 | |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 306 | /* The code is optimised for these values only */ |
| 307 | if (BITS_IN_JSAMPLE != 8) |
| 308 | return 0; |
| 309 | if (sizeof(JDIMENSION) != 4) |
| 310 | return 0; |
| 311 | |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 312 | if (simd_support & JSIMD_SSE2) |
| 313 | return 1; |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 314 | if (simd_support & JSIMD_MMX) |
| 315 | return 1; |
| 316 | |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 317 | return 0; |
| 318 | } |
| 319 | |
| 320 | GLOBAL(int) |
| 321 | jsimd_can_h2v1_downsample (void) |
| 322 | { |
| 323 | init_simd(); |
| 324 | |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 325 | /* The code is optimised for these values only */ |
| 326 | if (BITS_IN_JSAMPLE != 8) |
| 327 | return 0; |
| 328 | if (sizeof(JDIMENSION) != 4) |
| 329 | return 0; |
| 330 | |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 331 | if (simd_support & JSIMD_SSE2) |
| 332 | return 1; |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 333 | if (simd_support & JSIMD_MMX) |
| 334 | return 1; |
| 335 | |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 336 | return 0; |
| 337 | } |
| 338 | |
| 339 | GLOBAL(void) |
Alex Naidis | 6eb7d37 | 2016-10-16 23:10:08 +0200 | [diff] [blame] | 340 | jsimd_h2v2_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr, |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 341 | JSAMPARRAY input_data, JSAMPARRAY output_data) |
| 342 | { |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 343 | if (simd_support & JSIMD_SSE2) |
| 344 | jsimd_h2v2_downsample_sse2(cinfo->image_width, cinfo->max_v_samp_factor, |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 345 | compptr->v_samp_factor, |
| 346 | compptr->width_in_blocks, input_data, |
| 347 | output_data); |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 348 | else if (simd_support & JSIMD_MMX) |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 349 | jsimd_h2v2_downsample_mmx(cinfo->image_width, cinfo->max_v_samp_factor, |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 350 | compptr->v_samp_factor, compptr->width_in_blocks, |
| 351 | input_data, output_data); |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 352 | } |
| 353 | |
| 354 | GLOBAL(void) |
Alex Naidis | 6eb7d37 | 2016-10-16 23:10:08 +0200 | [diff] [blame] | 355 | jsimd_h2v1_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr, |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 356 | JSAMPARRAY input_data, JSAMPARRAY output_data) |
| 357 | { |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 358 | if (simd_support & JSIMD_SSE2) |
| 359 | jsimd_h2v1_downsample_sse2(cinfo->image_width, cinfo->max_v_samp_factor, |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 360 | compptr->v_samp_factor, |
| 361 | compptr->width_in_blocks, input_data, |
| 362 | output_data); |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 363 | else if (simd_support & JSIMD_MMX) |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 364 | jsimd_h2v1_downsample_mmx(cinfo->image_width, cinfo->max_v_samp_factor, |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 365 | compptr->v_samp_factor, compptr->width_in_blocks, |
| 366 | input_data, output_data); |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 367 | } |
| 368 | |
| 369 | GLOBAL(int) |
| 370 | jsimd_can_h2v2_upsample (void) |
| 371 | { |
| 372 | init_simd(); |
| 373 | |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 374 | /* The code is optimised for these values only */ |
| 375 | if (BITS_IN_JSAMPLE != 8) |
| 376 | return 0; |
| 377 | if (sizeof(JDIMENSION) != 4) |
| 378 | return 0; |
| 379 | |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 380 | if (simd_support & JSIMD_SSE2) |
| 381 | return 1; |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 382 | if (simd_support & JSIMD_MMX) |
| 383 | return 1; |
| 384 | |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 385 | return 0; |
| 386 | } |
| 387 | |
| 388 | GLOBAL(int) |
| 389 | jsimd_can_h2v1_upsample (void) |
| 390 | { |
| 391 | init_simd(); |
| 392 | |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 393 | /* The code is optimised for these values only */ |
| 394 | if (BITS_IN_JSAMPLE != 8) |
| 395 | return 0; |
| 396 | if (sizeof(JDIMENSION) != 4) |
| 397 | return 0; |
| 398 | |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 399 | if (simd_support & JSIMD_SSE2) |
| 400 | return 1; |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 401 | if (simd_support & JSIMD_MMX) |
| 402 | return 1; |
| 403 | |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 404 | return 0; |
| 405 | } |
| 406 | |
| 407 | GLOBAL(void) |
| 408 | jsimd_h2v2_upsample (j_decompress_ptr cinfo, |
Alex Naidis | 6eb7d37 | 2016-10-16 23:10:08 +0200 | [diff] [blame] | 409 | jpeg_component_info *compptr, |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 410 | JSAMPARRAY input_data, |
Alex Naidis | 6eb7d37 | 2016-10-16 23:10:08 +0200 | [diff] [blame] | 411 | JSAMPARRAY *output_data_ptr) |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 412 | { |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 413 | if (simd_support & JSIMD_SSE2) |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 414 | jsimd_h2v2_upsample_sse2(cinfo->max_v_samp_factor, cinfo->output_width, |
| 415 | input_data, output_data_ptr); |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 416 | else if (simd_support & JSIMD_MMX) |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 417 | jsimd_h2v2_upsample_mmx(cinfo->max_v_samp_factor, cinfo->output_width, |
| 418 | input_data, output_data_ptr); |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 419 | } |
| 420 | |
| 421 | GLOBAL(void) |
| 422 | jsimd_h2v1_upsample (j_decompress_ptr cinfo, |
Alex Naidis | 6eb7d37 | 2016-10-16 23:10:08 +0200 | [diff] [blame] | 423 | jpeg_component_info *compptr, |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 424 | JSAMPARRAY input_data, |
Alex Naidis | 6eb7d37 | 2016-10-16 23:10:08 +0200 | [diff] [blame] | 425 | JSAMPARRAY *output_data_ptr) |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 426 | { |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 427 | if (simd_support & JSIMD_SSE2) |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 428 | jsimd_h2v1_upsample_sse2(cinfo->max_v_samp_factor, cinfo->output_width, |
| 429 | input_data, output_data_ptr); |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 430 | else if (simd_support & JSIMD_MMX) |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 431 | jsimd_h2v1_upsample_mmx(cinfo->max_v_samp_factor, cinfo->output_width, |
| 432 | input_data, output_data_ptr); |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 433 | } |
| 434 | |
| 435 | GLOBAL(int) |
| 436 | jsimd_can_h2v2_fancy_upsample (void) |
| 437 | { |
| 438 | init_simd(); |
| 439 | |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 440 | /* The code is optimised for these values only */ |
| 441 | if (BITS_IN_JSAMPLE != 8) |
| 442 | return 0; |
| 443 | if (sizeof(JDIMENSION) != 4) |
| 444 | return 0; |
| 445 | |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 446 | if ((simd_support & JSIMD_SSE2) && |
| 447 | IS_ALIGNED_SSE(jconst_fancy_upsample_sse2)) |
| 448 | return 1; |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 449 | if (simd_support & JSIMD_MMX) |
| 450 | return 1; |
| 451 | |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 452 | return 0; |
| 453 | } |
| 454 | |
| 455 | GLOBAL(int) |
| 456 | jsimd_can_h2v1_fancy_upsample (void) |
| 457 | { |
| 458 | init_simd(); |
| 459 | |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 460 | /* The code is optimised for these values only */ |
| 461 | if (BITS_IN_JSAMPLE != 8) |
| 462 | return 0; |
| 463 | if (sizeof(JDIMENSION) != 4) |
| 464 | return 0; |
| 465 | |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 466 | if ((simd_support & JSIMD_SSE2) && |
| 467 | IS_ALIGNED_SSE(jconst_fancy_upsample_sse2)) |
| 468 | return 1; |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 469 | if (simd_support & JSIMD_MMX) |
| 470 | return 1; |
| 471 | |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 472 | return 0; |
| 473 | } |
| 474 | |
| 475 | GLOBAL(void) |
| 476 | jsimd_h2v2_fancy_upsample (j_decompress_ptr cinfo, |
Alex Naidis | 6eb7d37 | 2016-10-16 23:10:08 +0200 | [diff] [blame] | 477 | jpeg_component_info *compptr, |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 478 | JSAMPARRAY input_data, |
Alex Naidis | 6eb7d37 | 2016-10-16 23:10:08 +0200 | [diff] [blame] | 479 | JSAMPARRAY *output_data_ptr) |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 480 | { |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 481 | if ((simd_support & JSIMD_SSE2) && |
| 482 | IS_ALIGNED_SSE(jconst_fancy_upsample_sse2)) |
DRC | 3095971 | 2010-08-07 16:06:56 +0000 | [diff] [blame] | 483 | jsimd_h2v2_fancy_upsample_sse2(cinfo->max_v_samp_factor, |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 484 | compptr->downsampled_width, input_data, |
| 485 | output_data_ptr); |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 486 | else if (simd_support & JSIMD_MMX) |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 487 | jsimd_h2v2_fancy_upsample_mmx(cinfo->max_v_samp_factor, |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 488 | compptr->downsampled_width, input_data, |
| 489 | output_data_ptr); |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 490 | } |
| 491 | |
| 492 | GLOBAL(void) |
| 493 | jsimd_h2v1_fancy_upsample (j_decompress_ptr cinfo, |
Alex Naidis | 6eb7d37 | 2016-10-16 23:10:08 +0200 | [diff] [blame] | 494 | jpeg_component_info *compptr, |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 495 | JSAMPARRAY input_data, |
Alex Naidis | 6eb7d37 | 2016-10-16 23:10:08 +0200 | [diff] [blame] | 496 | JSAMPARRAY *output_data_ptr) |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 497 | { |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 498 | if ((simd_support & JSIMD_SSE2) && |
| 499 | IS_ALIGNED_SSE(jconst_fancy_upsample_sse2)) |
| 500 | jsimd_h2v1_fancy_upsample_sse2(cinfo->max_v_samp_factor, |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 501 | compptr->downsampled_width, input_data, |
| 502 | output_data_ptr); |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 503 | else if (simd_support & JSIMD_MMX) |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 504 | jsimd_h2v1_fancy_upsample_mmx(cinfo->max_v_samp_factor, |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 505 | compptr->downsampled_width, input_data, |
| 506 | output_data_ptr); |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 507 | } |
| 508 | |
| 509 | GLOBAL(int) |
| 510 | jsimd_can_h2v2_merged_upsample (void) |
| 511 | { |
| 512 | init_simd(); |
| 513 | |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 514 | /* The code is optimised for these values only */ |
| 515 | if (BITS_IN_JSAMPLE != 8) |
| 516 | return 0; |
| 517 | if (sizeof(JDIMENSION) != 4) |
| 518 | return 0; |
| 519 | |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 520 | if ((simd_support & JSIMD_SSE2) && |
| 521 | IS_ALIGNED_SSE(jconst_merged_upsample_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_h2v1_merged_upsample (void) |
| 531 | { |
| 532 | init_simd(); |
| 533 | |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 534 | /* The code is optimised for these values only */ |
| 535 | if (BITS_IN_JSAMPLE != 8) |
| 536 | return 0; |
| 537 | if (sizeof(JDIMENSION) != 4) |
| 538 | return 0; |
| 539 | |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 540 | if ((simd_support & JSIMD_SSE2) && |
| 541 | IS_ALIGNED_SSE(jconst_merged_upsample_sse2)) |
| 542 | return 1; |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 543 | if (simd_support & JSIMD_MMX) |
| 544 | return 1; |
| 545 | |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 546 | return 0; |
| 547 | } |
| 548 | |
| 549 | GLOBAL(void) |
| 550 | jsimd_h2v2_merged_upsample (j_decompress_ptr cinfo, |
| 551 | JSAMPIMAGE input_buf, |
| 552 | JDIMENSION in_row_group_ctr, |
| 553 | JSAMPARRAY output_buf) |
| 554 | { |
DRC | 720e161 | 2009-04-05 21:51:25 +0000 | [diff] [blame] | 555 | void (*sse2fct)(JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY); |
| 556 | void (*mmxfct)(JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY); |
Pierre Ossman | ba82ddf | 2009-06-29 11:20:42 +0000 | [diff] [blame] | 557 | |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 558 | switch(cinfo->out_color_space) { |
DRC | 720e161 | 2009-04-05 21:51:25 +0000 | [diff] [blame] | 559 | case JCS_EXT_RGB: |
| 560 | sse2fct=jsimd_h2v2_extrgb_merged_upsample_sse2; |
| 561 | mmxfct=jsimd_h2v2_extrgb_merged_upsample_mmx; |
| 562 | break; |
| 563 | case JCS_EXT_RGBX: |
DRC | 67ce3b2 | 2011-12-19 02:21:03 +0000 | [diff] [blame] | 564 | case JCS_EXT_RGBA: |
DRC | 720e161 | 2009-04-05 21:51:25 +0000 | [diff] [blame] | 565 | sse2fct=jsimd_h2v2_extrgbx_merged_upsample_sse2; |
| 566 | mmxfct=jsimd_h2v2_extrgbx_merged_upsample_mmx; |
| 567 | break; |
| 568 | case JCS_EXT_BGR: |
| 569 | sse2fct=jsimd_h2v2_extbgr_merged_upsample_sse2; |
| 570 | mmxfct=jsimd_h2v2_extbgr_merged_upsample_mmx; |
| 571 | break; |
| 572 | case JCS_EXT_BGRX: |
DRC | 67ce3b2 | 2011-12-19 02:21:03 +0000 | [diff] [blame] | 573 | case JCS_EXT_BGRA: |
DRC | 720e161 | 2009-04-05 21:51:25 +0000 | [diff] [blame] | 574 | sse2fct=jsimd_h2v2_extbgrx_merged_upsample_sse2; |
| 575 | mmxfct=jsimd_h2v2_extbgrx_merged_upsample_mmx; |
| 576 | break; |
| 577 | case JCS_EXT_XBGR: |
DRC | 67ce3b2 | 2011-12-19 02:21:03 +0000 | [diff] [blame] | 578 | case JCS_EXT_ABGR: |
DRC | 720e161 | 2009-04-05 21:51:25 +0000 | [diff] [blame] | 579 | sse2fct=jsimd_h2v2_extxbgr_merged_upsample_sse2; |
| 580 | mmxfct=jsimd_h2v2_extxbgr_merged_upsample_mmx; |
| 581 | break; |
| 582 | case JCS_EXT_XRGB: |
DRC | 67ce3b2 | 2011-12-19 02:21:03 +0000 | [diff] [blame] | 583 | case JCS_EXT_ARGB: |
DRC | 720e161 | 2009-04-05 21:51:25 +0000 | [diff] [blame] | 584 | sse2fct=jsimd_h2v2_extxrgb_merged_upsample_sse2; |
| 585 | mmxfct=jsimd_h2v2_extxrgb_merged_upsample_mmx; |
| 586 | break; |
| 587 | default: |
| 588 | sse2fct=jsimd_h2v2_merged_upsample_sse2; |
| 589 | mmxfct=jsimd_h2v2_merged_upsample_mmx; |
| 590 | break; |
| 591 | } |
Pierre Ossman | ba82ddf | 2009-06-29 11:20:42 +0000 | [diff] [blame] | 592 | |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 593 | if ((simd_support & JSIMD_SSE2) && |
| 594 | IS_ALIGNED_SSE(jconst_merged_upsample_sse2)) |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 595 | sse2fct(cinfo->output_width, input_buf, in_row_group_ctr, output_buf); |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 596 | else if (simd_support & JSIMD_MMX) |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 597 | mmxfct(cinfo->output_width, input_buf, in_row_group_ctr, output_buf); |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 598 | } |
| 599 | |
| 600 | GLOBAL(void) |
| 601 | jsimd_h2v1_merged_upsample (j_decompress_ptr cinfo, |
| 602 | JSAMPIMAGE input_buf, |
| 603 | JDIMENSION in_row_group_ctr, |
| 604 | JSAMPARRAY output_buf) |
| 605 | { |
DRC | 720e161 | 2009-04-05 21:51:25 +0000 | [diff] [blame] | 606 | void (*sse2fct)(JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY); |
| 607 | void (*mmxfct)(JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY); |
Pierre Ossman | ba82ddf | 2009-06-29 11:20:42 +0000 | [diff] [blame] | 608 | |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 609 | switch(cinfo->out_color_space) { |
DRC | 720e161 | 2009-04-05 21:51:25 +0000 | [diff] [blame] | 610 | case JCS_EXT_RGB: |
| 611 | sse2fct=jsimd_h2v1_extrgb_merged_upsample_sse2; |
| 612 | mmxfct=jsimd_h2v1_extrgb_merged_upsample_mmx; |
| 613 | break; |
| 614 | case JCS_EXT_RGBX: |
DRC | 67ce3b2 | 2011-12-19 02:21:03 +0000 | [diff] [blame] | 615 | case JCS_EXT_RGBA: |
DRC | 720e161 | 2009-04-05 21:51:25 +0000 | [diff] [blame] | 616 | sse2fct=jsimd_h2v1_extrgbx_merged_upsample_sse2; |
| 617 | mmxfct=jsimd_h2v1_extrgbx_merged_upsample_mmx; |
| 618 | break; |
| 619 | case JCS_EXT_BGR: |
| 620 | sse2fct=jsimd_h2v1_extbgr_merged_upsample_sse2; |
| 621 | mmxfct=jsimd_h2v1_extbgr_merged_upsample_mmx; |
| 622 | break; |
| 623 | case JCS_EXT_BGRX: |
DRC | 67ce3b2 | 2011-12-19 02:21:03 +0000 | [diff] [blame] | 624 | case JCS_EXT_BGRA: |
DRC | 720e161 | 2009-04-05 21:51:25 +0000 | [diff] [blame] | 625 | sse2fct=jsimd_h2v1_extbgrx_merged_upsample_sse2; |
| 626 | mmxfct=jsimd_h2v1_extbgrx_merged_upsample_mmx; |
| 627 | break; |
| 628 | case JCS_EXT_XBGR: |
DRC | 67ce3b2 | 2011-12-19 02:21:03 +0000 | [diff] [blame] | 629 | case JCS_EXT_ABGR: |
DRC | 720e161 | 2009-04-05 21:51:25 +0000 | [diff] [blame] | 630 | sse2fct=jsimd_h2v1_extxbgr_merged_upsample_sse2; |
| 631 | mmxfct=jsimd_h2v1_extxbgr_merged_upsample_mmx; |
| 632 | break; |
| 633 | case JCS_EXT_XRGB: |
DRC | 67ce3b2 | 2011-12-19 02:21:03 +0000 | [diff] [blame] | 634 | case JCS_EXT_ARGB: |
DRC | 720e161 | 2009-04-05 21:51:25 +0000 | [diff] [blame] | 635 | sse2fct=jsimd_h2v1_extxrgb_merged_upsample_sse2; |
| 636 | mmxfct=jsimd_h2v1_extxrgb_merged_upsample_mmx; |
| 637 | break; |
| 638 | default: |
| 639 | sse2fct=jsimd_h2v1_merged_upsample_sse2; |
| 640 | mmxfct=jsimd_h2v1_merged_upsample_mmx; |
| 641 | break; |
| 642 | } |
Pierre Ossman | ba82ddf | 2009-06-29 11:20:42 +0000 | [diff] [blame] | 643 | |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 644 | if ((simd_support & JSIMD_SSE2) && |
| 645 | IS_ALIGNED_SSE(jconst_merged_upsample_sse2)) |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 646 | sse2fct(cinfo->output_width, input_buf, in_row_group_ctr, output_buf); |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 647 | else if (simd_support & JSIMD_MMX) |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 648 | mmxfct(cinfo->output_width, input_buf, in_row_group_ctr, output_buf); |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 649 | } |
| 650 | |
| 651 | GLOBAL(int) |
| 652 | jsimd_can_convsamp (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 (BITS_IN_JSAMPLE != 8) |
| 660 | return 0; |
| 661 | if (sizeof(JDIMENSION) != 4) |
| 662 | return 0; |
| 663 | if (sizeof(DCTELEM) != 2) |
| 664 | return 0; |
| 665 | |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 666 | if (simd_support & JSIMD_SSE2) |
| 667 | return 1; |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 668 | if (simd_support & JSIMD_MMX) |
| 669 | return 1; |
| 670 | |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 671 | return 0; |
| 672 | } |
| 673 | |
| 674 | GLOBAL(int) |
| 675 | jsimd_can_convsamp_float (void) |
| 676 | { |
| 677 | init_simd(); |
| 678 | |
Pierre Ossman | 65d0317 | 2009-03-09 13:28:10 +0000 | [diff] [blame] | 679 | /* The code is optimised for these values only */ |
| 680 | if (DCTSIZE != 8) |
| 681 | return 0; |
| 682 | if (BITS_IN_JSAMPLE != 8) |
| 683 | return 0; |
| 684 | if (sizeof(JDIMENSION) != 4) |
| 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_convsamp (JSAMPARRAY sample_data, JDIMENSION start_col, |
Alex Naidis | 6eb7d37 | 2016-10-16 23:10:08 +0200 | [diff] [blame] | 701 | DCTELEM *workspace) |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 702 | { |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 703 | if (simd_support & JSIMD_SSE2) |
| 704 | jsimd_convsamp_sse2(sample_data, start_col, workspace); |
| 705 | else if (simd_support & JSIMD_MMX) |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 706 | jsimd_convsamp_mmx(sample_data, start_col, workspace); |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 707 | } |
| 708 | |
| 709 | GLOBAL(void) |
| 710 | jsimd_convsamp_float (JSAMPARRAY sample_data, JDIMENSION start_col, |
Alex Naidis | 6eb7d37 | 2016-10-16 23:10:08 +0200 | [diff] [blame] | 711 | FAST_FLOAT *workspace) |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 712 | { |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 713 | if (simd_support & JSIMD_SSE2) |
| 714 | jsimd_convsamp_float_sse2(sample_data, start_col, workspace); |
| 715 | else if (simd_support & JSIMD_SSE) |
Pierre Ossman | 018fc42 | 2009-03-09 13:31:56 +0000 | [diff] [blame] | 716 | jsimd_convsamp_float_sse(sample_data, start_col, workspace); |
| 717 | else if (simd_support & JSIMD_3DNOW) |
Pierre Ossman | 65d0317 | 2009-03-09 13:28:10 +0000 | [diff] [blame] | 718 | jsimd_convsamp_float_3dnow(sample_data, start_col, workspace); |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 719 | } |
| 720 | |
| 721 | GLOBAL(int) |
| 722 | jsimd_can_fdct_islow (void) |
| 723 | { |
| 724 | init_simd(); |
| 725 | |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 726 | /* The code is optimised for these values only */ |
| 727 | if (DCTSIZE != 8) |
| 728 | return 0; |
| 729 | if (sizeof(DCTELEM) != 2) |
| 730 | return 0; |
| 731 | |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 732 | if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_fdct_islow_sse2)) |
| 733 | return 1; |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 734 | if (simd_support & JSIMD_MMX) |
| 735 | return 1; |
| 736 | |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 737 | return 0; |
| 738 | } |
| 739 | |
| 740 | GLOBAL(int) |
| 741 | jsimd_can_fdct_ifast (void) |
| 742 | { |
| 743 | init_simd(); |
| 744 | |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 745 | /* The code is optimised for these values only */ |
| 746 | if (DCTSIZE != 8) |
| 747 | return 0; |
| 748 | if (sizeof(DCTELEM) != 2) |
| 749 | return 0; |
| 750 | |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 751 | if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_fdct_ifast_sse2)) |
| 752 | return 1; |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 753 | if (simd_support & JSIMD_MMX) |
| 754 | return 1; |
| 755 | |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 756 | return 0; |
| 757 | } |
| 758 | |
| 759 | GLOBAL(int) |
| 760 | jsimd_can_fdct_float (void) |
| 761 | { |
| 762 | init_simd(); |
| 763 | |
Pierre Ossman | 65d0317 | 2009-03-09 13:28:10 +0000 | [diff] [blame] | 764 | /* The code is optimised for these values only */ |
| 765 | if (DCTSIZE != 8) |
| 766 | return 0; |
| 767 | if (sizeof(FAST_FLOAT) != 4) |
| 768 | return 0; |
| 769 | |
Pierre Ossman | 018fc42 | 2009-03-09 13:31:56 +0000 | [diff] [blame] | 770 | if ((simd_support & JSIMD_SSE) && IS_ALIGNED_SSE(jconst_fdct_float_sse)) |
| 771 | return 1; |
Pierre Ossman | 65d0317 | 2009-03-09 13:28:10 +0000 | [diff] [blame] | 772 | if (simd_support & JSIMD_3DNOW) |
| 773 | return 1; |
| 774 | |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 775 | return 0; |
| 776 | } |
| 777 | |
| 778 | GLOBAL(void) |
Alex Naidis | 6eb7d37 | 2016-10-16 23:10:08 +0200 | [diff] [blame] | 779 | jsimd_fdct_islow (DCTELEM *data) |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 780 | { |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 781 | if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_fdct_islow_sse2)) |
| 782 | jsimd_fdct_islow_sse2(data); |
| 783 | else if (simd_support & JSIMD_MMX) |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 784 | jsimd_fdct_islow_mmx(data); |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 785 | } |
| 786 | |
| 787 | GLOBAL(void) |
Alex Naidis | 6eb7d37 | 2016-10-16 23:10:08 +0200 | [diff] [blame] | 788 | jsimd_fdct_ifast (DCTELEM *data) |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 789 | { |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 790 | if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_fdct_islow_sse2)) |
| 791 | jsimd_fdct_ifast_sse2(data); |
| 792 | else if (simd_support & JSIMD_MMX) |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 793 | jsimd_fdct_ifast_mmx(data); |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 794 | } |
| 795 | |
| 796 | GLOBAL(void) |
Alex Naidis | 6eb7d37 | 2016-10-16 23:10:08 +0200 | [diff] [blame] | 797 | jsimd_fdct_float (FAST_FLOAT *data) |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 798 | { |
Pierre Ossman | 018fc42 | 2009-03-09 13:31:56 +0000 | [diff] [blame] | 799 | if ((simd_support & JSIMD_SSE) && IS_ALIGNED_SSE(jconst_fdct_float_sse)) |
| 800 | jsimd_fdct_float_sse(data); |
| 801 | else if (simd_support & JSIMD_3DNOW) |
Pierre Ossman | 65d0317 | 2009-03-09 13:28:10 +0000 | [diff] [blame] | 802 | jsimd_fdct_float_3dnow(data); |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 803 | } |
| 804 | |
| 805 | GLOBAL(int) |
| 806 | jsimd_can_quantize (void) |
| 807 | { |
| 808 | init_simd(); |
| 809 | |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 810 | /* The code is optimised for these values only */ |
| 811 | if (DCTSIZE != 8) |
| 812 | return 0; |
| 813 | if (sizeof(JCOEF) != 2) |
| 814 | return 0; |
| 815 | if (sizeof(DCTELEM) != 2) |
| 816 | return 0; |
| 817 | |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 818 | if (simd_support & JSIMD_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_quantize_float (void) |
| 828 | { |
| 829 | init_simd(); |
| 830 | |
Pierre Ossman | 65d0317 | 2009-03-09 13:28:10 +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 (sizeof(FAST_FLOAT) != 4) |
| 837 | return 0; |
| 838 | |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 839 | if (simd_support & JSIMD_SSE2) |
| 840 | return 1; |
Pierre Ossman | 018fc42 | 2009-03-09 13:31:56 +0000 | [diff] [blame] | 841 | if (simd_support & JSIMD_SSE) |
| 842 | return 1; |
Pierre Ossman | 65d0317 | 2009-03-09 13:28:10 +0000 | [diff] [blame] | 843 | if (simd_support & JSIMD_3DNOW) |
| 844 | return 1; |
| 845 | |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 846 | return 0; |
| 847 | } |
| 848 | |
| 849 | GLOBAL(void) |
Alex Naidis | 6eb7d37 | 2016-10-16 23:10:08 +0200 | [diff] [blame] | 850 | jsimd_quantize (JCOEFPTR coef_block, DCTELEM *divisors, |
| 851 | DCTELEM *workspace) |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 852 | { |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 853 | if (simd_support & JSIMD_SSE2) |
| 854 | jsimd_quantize_sse2(coef_block, divisors, workspace); |
| 855 | else if (simd_support & JSIMD_MMX) |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 856 | jsimd_quantize_mmx(coef_block, divisors, workspace); |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 857 | } |
| 858 | |
| 859 | GLOBAL(void) |
Alex Naidis | 6eb7d37 | 2016-10-16 23:10:08 +0200 | [diff] [blame] | 860 | jsimd_quantize_float (JCOEFPTR coef_block, FAST_FLOAT *divisors, |
| 861 | FAST_FLOAT *workspace) |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 862 | { |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 863 | if (simd_support & JSIMD_SSE2) |
| 864 | jsimd_quantize_float_sse2(coef_block, divisors, workspace); |
| 865 | else if (simd_support & JSIMD_SSE) |
Pierre Ossman | 018fc42 | 2009-03-09 13:31:56 +0000 | [diff] [blame] | 866 | jsimd_quantize_float_sse(coef_block, divisors, workspace); |
| 867 | else if (simd_support & JSIMD_3DNOW) |
Pierre Ossman | 65d0317 | 2009-03-09 13:28:10 +0000 | [diff] [blame] | 868 | jsimd_quantize_float_3dnow(coef_block, divisors, workspace); |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 869 | } |
| 870 | |
| 871 | GLOBAL(int) |
| 872 | jsimd_can_idct_2x2 (void) |
| 873 | { |
| 874 | init_simd(); |
| 875 | |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 876 | /* The code is optimised for these values only */ |
| 877 | if (DCTSIZE != 8) |
| 878 | return 0; |
| 879 | if (sizeof(JCOEF) != 2) |
| 880 | return 0; |
| 881 | if (BITS_IN_JSAMPLE != 8) |
| 882 | return 0; |
| 883 | if (sizeof(JDIMENSION) != 4) |
| 884 | return 0; |
| 885 | if (sizeof(ISLOW_MULT_TYPE) != 2) |
| 886 | return 0; |
| 887 | |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 888 | if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_red_sse2)) |
| 889 | return 1; |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 890 | if (simd_support & JSIMD_MMX) |
| 891 | return 1; |
| 892 | |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 893 | return 0; |
| 894 | } |
| 895 | |
| 896 | GLOBAL(int) |
| 897 | jsimd_can_idct_4x4 (void) |
| 898 | { |
| 899 | init_simd(); |
| 900 | |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 901 | /* The code is optimised for these values only */ |
| 902 | if (DCTSIZE != 8) |
| 903 | return 0; |
| 904 | if (sizeof(JCOEF) != 2) |
| 905 | return 0; |
| 906 | if (BITS_IN_JSAMPLE != 8) |
| 907 | return 0; |
| 908 | if (sizeof(JDIMENSION) != 4) |
| 909 | return 0; |
| 910 | if (sizeof(ISLOW_MULT_TYPE) != 2) |
| 911 | return 0; |
| 912 | |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 913 | if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_red_sse2)) |
| 914 | return 1; |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 915 | if (simd_support & JSIMD_MMX) |
| 916 | return 1; |
| 917 | |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 918 | return 0; |
| 919 | } |
| 920 | |
| 921 | GLOBAL(void) |
Alex Naidis | 6eb7d37 | 2016-10-16 23:10:08 +0200 | [diff] [blame] | 922 | jsimd_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info *compptr, |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 923 | JCOEFPTR coef_block, JSAMPARRAY output_buf, |
| 924 | JDIMENSION output_col) |
| 925 | { |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 926 | if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_red_sse2)) |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 927 | jsimd_idct_2x2_sse2(compptr->dct_table, coef_block, output_buf, |
| 928 | output_col); |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 929 | else if (simd_support & JSIMD_MMX) |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 930 | jsimd_idct_2x2_mmx(compptr->dct_table, coef_block, output_buf, output_col); |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 931 | } |
| 932 | |
| 933 | GLOBAL(void) |
Alex Naidis | 6eb7d37 | 2016-10-16 23:10:08 +0200 | [diff] [blame] | 934 | jsimd_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info *compptr, |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 935 | JCOEFPTR coef_block, JSAMPARRAY output_buf, |
| 936 | JDIMENSION output_col) |
| 937 | { |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 938 | if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_red_sse2)) |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 939 | jsimd_idct_4x4_sse2(compptr->dct_table, coef_block, output_buf, |
| 940 | output_col); |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 941 | else if (simd_support & JSIMD_MMX) |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 942 | jsimd_idct_4x4_mmx(compptr->dct_table, coef_block, output_buf, output_col); |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 943 | } |
| 944 | |
| 945 | GLOBAL(int) |
| 946 | jsimd_can_idct_islow (void) |
| 947 | { |
| 948 | init_simd(); |
| 949 | |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 950 | /* The code is optimised for these values only */ |
| 951 | if (DCTSIZE != 8) |
| 952 | return 0; |
| 953 | if (sizeof(JCOEF) != 2) |
| 954 | return 0; |
| 955 | if (BITS_IN_JSAMPLE != 8) |
| 956 | return 0; |
| 957 | if (sizeof(JDIMENSION) != 4) |
| 958 | return 0; |
| 959 | if (sizeof(ISLOW_MULT_TYPE) != 2) |
| 960 | return 0; |
| 961 | |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 962 | if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_islow_sse2)) |
| 963 | return 1; |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 964 | if (simd_support & JSIMD_MMX) |
| 965 | return 1; |
| 966 | |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 967 | return 0; |
| 968 | } |
| 969 | |
| 970 | GLOBAL(int) |
| 971 | jsimd_can_idct_ifast (void) |
| 972 | { |
| 973 | init_simd(); |
| 974 | |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 975 | /* The code is optimised for these values only */ |
| 976 | if (DCTSIZE != 8) |
| 977 | return 0; |
| 978 | if (sizeof(JCOEF) != 2) |
| 979 | return 0; |
| 980 | if (BITS_IN_JSAMPLE != 8) |
| 981 | return 0; |
| 982 | if (sizeof(JDIMENSION) != 4) |
| 983 | return 0; |
| 984 | if (sizeof(IFAST_MULT_TYPE) != 2) |
| 985 | return 0; |
| 986 | if (IFAST_SCALE_BITS != 2) |
| 987 | return 0; |
| 988 | |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 989 | if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_ifast_sse2)) |
| 990 | return 1; |
Pierre Ossman | 5eb84ff | 2009-03-09 13:25:30 +0000 | [diff] [blame] | 991 | if (simd_support & JSIMD_MMX) |
| 992 | return 1; |
| 993 | |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 994 | return 0; |
| 995 | } |
| 996 | |
| 997 | GLOBAL(int) |
| 998 | jsimd_can_idct_float (void) |
| 999 | { |
| 1000 | init_simd(); |
| 1001 | |
Pierre Ossman | 65d0317 | 2009-03-09 13:28:10 +0000 | [diff] [blame] | 1002 | if (DCTSIZE != 8) |
| 1003 | return 0; |
| 1004 | if (sizeof(JCOEF) != 2) |
| 1005 | return 0; |
| 1006 | if (BITS_IN_JSAMPLE != 8) |
| 1007 | return 0; |
| 1008 | if (sizeof(JDIMENSION) != 4) |
| 1009 | return 0; |
| 1010 | if (sizeof(FAST_FLOAT) != 4) |
| 1011 | return 0; |
| 1012 | if (sizeof(FLOAT_MULT_TYPE) != 4) |
| 1013 | return 0; |
| 1014 | |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 1015 | if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_float_sse2)) |
| 1016 | return 1; |
Pierre Ossman | 018fc42 | 2009-03-09 13:31:56 +0000 | [diff] [blame] | 1017 | if ((simd_support & JSIMD_SSE) && IS_ALIGNED_SSE(jconst_idct_float_sse)) |
| 1018 | return 1; |
Pierre Ossman | 65d0317 | 2009-03-09 13:28:10 +0000 | [diff] [blame] | 1019 | if (simd_support & JSIMD_3DNOW) |
| 1020 | return 1; |
| 1021 | |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 1022 | return 0; |
| 1023 | } |
| 1024 | |
| 1025 | GLOBAL(void) |
Alex Naidis | 6eb7d37 | 2016-10-16 23:10:08 +0200 | [diff] [blame] | 1026 | jsimd_idct_islow (j_decompress_ptr cinfo, jpeg_component_info *compptr, |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 1027 | JCOEFPTR coef_block, JSAMPARRAY output_buf, |
| 1028 | JDIMENSION output_col) |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 1029 | { |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 1030 | if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_islow_sse2)) |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 1031 | jsimd_idct_islow_sse2(compptr->dct_table, coef_block, output_buf, |
| 1032 | output_col); |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 1033 | else if (simd_support & JSIMD_MMX) |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 1034 | jsimd_idct_islow_mmx(compptr->dct_table, coef_block, output_buf, |
| 1035 | output_col); |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 1036 | } |
| 1037 | |
| 1038 | GLOBAL(void) |
Alex Naidis | 6eb7d37 | 2016-10-16 23:10:08 +0200 | [diff] [blame] | 1039 | jsimd_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info *compptr, |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 1040 | JCOEFPTR coef_block, JSAMPARRAY output_buf, |
| 1041 | JDIMENSION output_col) |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 1042 | { |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 1043 | if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_ifast_sse2)) |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 1044 | jsimd_idct_ifast_sse2(compptr->dct_table, coef_block, output_buf, |
| 1045 | output_col); |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 1046 | else if (simd_support & JSIMD_MMX) |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 1047 | jsimd_idct_ifast_mmx(compptr->dct_table, coef_block, output_buf, |
| 1048 | output_col); |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 1049 | } |
| 1050 | |
| 1051 | GLOBAL(void) |
Alex Naidis | 6eb7d37 | 2016-10-16 23:10:08 +0200 | [diff] [blame] | 1052 | jsimd_idct_float (j_decompress_ptr cinfo, jpeg_component_info *compptr, |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 1053 | JCOEFPTR coef_block, JSAMPARRAY output_buf, |
| 1054 | JDIMENSION output_col) |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 1055 | { |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 1056 | if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_float_sse2)) |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 1057 | jsimd_idct_float_sse2(compptr->dct_table, coef_block, output_buf, |
| 1058 | output_col); |
Pierre Ossman | eea7215 | 2009-03-09 13:34:17 +0000 | [diff] [blame] | 1059 | else if ((simd_support & JSIMD_SSE) && IS_ALIGNED_SSE(jconst_idct_float_sse)) |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 1060 | jsimd_idct_float_sse(compptr->dct_table, coef_block, output_buf, |
| 1061 | output_col); |
Pierre Ossman | 018fc42 | 2009-03-09 13:31:56 +0000 | [diff] [blame] | 1062 | else if (simd_support & JSIMD_3DNOW) |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 1063 | jsimd_idct_float_3dnow(compptr->dct_table, coef_block, output_buf, |
| 1064 | output_col); |
Pierre Ossman | 59a3938 | 2009-03-09 13:15:56 +0000 | [diff] [blame] | 1065 | } |
| 1066 | |
Alex Naidis | 6eb7d37 | 2016-10-16 23:10:08 +0200 | [diff] [blame] | 1067 | GLOBAL(int) |
| 1068 | jsimd_can_huff_encode_one_block (void) |
| 1069 | { |
| 1070 | init_simd(); |
| 1071 | |
| 1072 | if (DCTSIZE != 8) |
| 1073 | return 0; |
| 1074 | if (sizeof(JCOEF) != 2) |
| 1075 | return 0; |
| 1076 | |
| 1077 | if ((simd_support & JSIMD_SSE2) && simd_huffman && |
| 1078 | IS_ALIGNED_SSE(jconst_huff_encode_one_block)) |
| 1079 | return 1; |
| 1080 | |
| 1081 | return 0; |
| 1082 | } |
| 1083 | |
| 1084 | GLOBAL(JOCTET*) |
| 1085 | jsimd_huff_encode_one_block (void *state, JOCTET *buffer, JCOEFPTR block, |
| 1086 | int last_dc_val, c_derived_tbl *dctbl, |
| 1087 | c_derived_tbl *actbl) |
| 1088 | { |
| 1089 | return jsimd_huff_encode_one_block_sse2(state, buffer, block, last_dc_val, |
| 1090 | dctbl, actbl); |
| 1091 | } |