DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 1 | /* |
| 2 | * jsimd_mips.c |
| 3 | * |
| 4 | * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB |
| 5 | * Copyright 2009-2011 D. R. Commander |
DRC | 3434786 | 2014-05-06 09:53:21 +0000 | [diff] [blame] | 6 | * Copyright (C) 2013-2014, MIPS Technologies, Inc., California |
DRC | 49eaa75 | 2013-09-27 17:39:57 +0000 | [diff] [blame] | 7 | * |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 8 | * Based on the x86 SIMD extension for IJG JPEG library, |
| 9 | * Copyright (C) 1999-2006, MIYASAKA Masaru. |
| 10 | * For conditions of distribution and use, see copyright notice in jsimdext.inc |
| 11 | * |
| 12 | * This file contains the interface between the "normal" portions |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 13 | * of the library and the SIMD implementations when running on a |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 14 | * MIPS architecture. |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | #define JPEG_INTERNALS |
| 18 | #include "../jinclude.h" |
| 19 | #include "../jpeglib.h" |
| 20 | #include "../jsimd.h" |
| 21 | #include "../jdct.h" |
| 22 | #include "../jsimddct.h" |
| 23 | #include "jsimd.h" |
| 24 | |
| 25 | #include <stdio.h> |
| 26 | #include <string.h> |
| 27 | #include <ctype.h> |
| 28 | |
| 29 | static unsigned int simd_support = ~0; |
| 30 | |
| 31 | #if defined(__linux__) |
| 32 | |
| 33 | LOCAL(int) |
| 34 | parse_proc_cpuinfo(const char* search_string) |
| 35 | { |
| 36 | const char* file_name = "/proc/cpuinfo"; |
| 37 | char cpuinfo_line[256]; |
| 38 | FILE* f = NULL; |
| 39 | simd_support = 0; |
| 40 | |
| 41 | if ((f = fopen(file_name, "r")) != NULL) { |
| 42 | while (fgets(cpuinfo_line, sizeof(cpuinfo_line), f) != NULL) { |
| 43 | if (strstr(cpuinfo_line, search_string) != NULL) { |
| 44 | fclose(f); |
| 45 | simd_support |= JSIMD_MIPS_DSPR2; |
| 46 | return 1; |
| 47 | } |
| 48 | } |
| 49 | fclose(f); |
| 50 | } |
| 51 | /* Did not find string in the proc file, or not Linux ELF. */ |
| 52 | return 0; |
| 53 | } |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 54 | |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 55 | #endif |
| 56 | |
| 57 | /* |
| 58 | * Check what SIMD accelerations are supported. |
| 59 | * |
| 60 | * FIXME: This code is racy under a multi-threaded environment. |
| 61 | */ |
| 62 | LOCAL(void) |
| 63 | init_simd (void) |
| 64 | { |
| 65 | if (simd_support != ~0U) |
| 66 | return; |
| 67 | |
| 68 | simd_support = 0; |
| 69 | |
| 70 | #if defined(__mips__) && defined(__mips_dsp) && (__mips_dsp_rev >= 2) |
| 71 | simd_support |= JSIMD_MIPS_DSPR2; |
| 72 | #elif defined(__linux__) |
| 73 | /* We still have a chance to use MIPS DSPR2 regardless of globally used |
| 74 | * -mdspr2 options passed to gcc by performing runtime detection via |
| 75 | * /proc/cpuinfo parsing on linux */ |
| 76 | if (!parse_proc_cpuinfo("MIPS 74K")) |
| 77 | return; |
| 78 | #endif |
| 79 | } |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 80 | |
DRC | d3131c1 | 2013-10-08 02:18:59 +0000 | [diff] [blame] | 81 | static const int mips_idct_ifast_coefs[4] = { |
| 82 | 0x45404540, // FIX( 1.082392200 / 2) = 17734 = 0x4546 |
| 83 | 0x5A805A80, // FIX( 1.414213562 / 2) = 23170 = 0x5A82 |
| 84 | 0x76407640, // FIX( 1.847759065 / 2) = 30274 = 0x7642 |
| 85 | 0xAC60AC60 // FIX(-2.613125930 / 4) = -21407 = 0xAC61 |
| 86 | }; |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 87 | |
| 88 | GLOBAL(int) |
| 89 | jsimd_can_rgb_ycc (void) |
| 90 | { |
| 91 | init_simd(); |
| 92 | |
| 93 | /* The code is optimised for these values only */ |
| 94 | if (BITS_IN_JSAMPLE != 8) |
| 95 | return 0; |
| 96 | if (sizeof(JDIMENSION) != 4) |
| 97 | return 0; |
| 98 | if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4)) |
| 99 | return 0; |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 100 | |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 101 | if (simd_support & JSIMD_MIPS_DSPR2) |
| 102 | return 1; |
| 103 | |
| 104 | return 0; |
| 105 | } |
| 106 | |
| 107 | GLOBAL(int) |
| 108 | jsimd_can_rgb_gray (void) |
| 109 | { |
DRC | 49eaa75 | 2013-09-27 17:39:57 +0000 | [diff] [blame] | 110 | init_simd(); |
| 111 | |
| 112 | /* The code is optimised for these values only */ |
| 113 | if (BITS_IN_JSAMPLE != 8) |
| 114 | return 0; |
| 115 | if (sizeof(JDIMENSION) != 4) |
| 116 | return 0; |
| 117 | if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4)) |
| 118 | return 0; |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 119 | |
DRC | 49eaa75 | 2013-09-27 17:39:57 +0000 | [diff] [blame] | 120 | if (simd_support & JSIMD_MIPS_DSPR2) |
| 121 | return 1; |
| 122 | |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 123 | return 0; |
| 124 | } |
| 125 | |
| 126 | GLOBAL(int) |
| 127 | jsimd_can_ycc_rgb (void) |
| 128 | { |
| 129 | init_simd(); |
| 130 | |
| 131 | /* The code is optimised for these values only */ |
| 132 | if (BITS_IN_JSAMPLE != 8) |
| 133 | return 0; |
| 134 | if (sizeof(JDIMENSION) != 4) |
| 135 | return 0; |
| 136 | if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4)) |
| 137 | return 0; |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 138 | |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 139 | if (simd_support & JSIMD_MIPS_DSPR2) |
| 140 | return 1; |
| 141 | |
| 142 | return 0; |
| 143 | } |
| 144 | |
DRC | 1b3fd7e | 2014-05-15 18:26:01 +0000 | [diff] [blame] | 145 | GLOBAL(int) |
| 146 | jsimd_c_can_null_convert (void) |
| 147 | { |
| 148 | init_simd(); |
| 149 | |
| 150 | /* The code is optimised for these values only */ |
| 151 | if (BITS_IN_JSAMPLE != 8) |
| 152 | return 0; |
| 153 | if (sizeof(JDIMENSION) != 4) |
| 154 | return 0; |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 155 | |
DRC | 1b3fd7e | 2014-05-15 18:26:01 +0000 | [diff] [blame] | 156 | if (simd_support & JSIMD_MIPS_DSPR2) |
| 157 | return 1; |
| 158 | |
| 159 | return 0; |
| 160 | } |
| 161 | |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 162 | GLOBAL(void) |
| 163 | jsimd_rgb_ycc_convert (j_compress_ptr cinfo, |
| 164 | JSAMPARRAY input_buf, JSAMPIMAGE output_buf, |
| 165 | JDIMENSION output_row, int num_rows) |
| 166 | { |
| 167 | void (*mipsdspr2fct)(JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JDIMENSION, int); |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 168 | |
| 169 | switch(cinfo->in_color_space) { |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 170 | case JCS_EXT_RGB: |
| 171 | mipsdspr2fct=jsimd_extrgb_ycc_convert_mips_dspr2; |
| 172 | break; |
| 173 | case JCS_EXT_RGBX: |
| 174 | case JCS_EXT_RGBA: |
| 175 | mipsdspr2fct=jsimd_extrgbx_ycc_convert_mips_dspr2; |
| 176 | break; |
| 177 | case JCS_EXT_BGR: |
| 178 | mipsdspr2fct=jsimd_extbgr_ycc_convert_mips_dspr2; |
| 179 | break; |
| 180 | case JCS_EXT_BGRX: |
| 181 | case JCS_EXT_BGRA: |
| 182 | mipsdspr2fct=jsimd_extbgrx_ycc_convert_mips_dspr2; |
| 183 | break; |
| 184 | case JCS_EXT_XBGR: |
| 185 | case JCS_EXT_ABGR: |
| 186 | mipsdspr2fct=jsimd_extxbgr_ycc_convert_mips_dspr2; |
| 187 | |
| 188 | break; |
| 189 | case JCS_EXT_XRGB: |
| 190 | case JCS_EXT_ARGB: |
| 191 | mipsdspr2fct=jsimd_extxrgb_ycc_convert_mips_dspr2; |
| 192 | break; |
| 193 | default: |
| 194 | mipsdspr2fct=jsimd_extrgb_ycc_convert_mips_dspr2; |
| 195 | break; |
| 196 | } |
| 197 | |
| 198 | if (simd_support & JSIMD_MIPS_DSPR2) |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 199 | mipsdspr2fct(cinfo->image_width, input_buf, output_buf, output_row, |
| 200 | num_rows); |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 201 | } |
| 202 | |
| 203 | GLOBAL(void) |
| 204 | jsimd_rgb_gray_convert (j_compress_ptr cinfo, |
| 205 | JSAMPARRAY input_buf, JSAMPIMAGE output_buf, |
| 206 | JDIMENSION output_row, int num_rows) |
| 207 | { |
DRC | 49eaa75 | 2013-09-27 17:39:57 +0000 | [diff] [blame] | 208 | void (*mipsdspr2fct)(JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JDIMENSION, int); |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 209 | |
| 210 | switch(cinfo->in_color_space) { |
DRC | 49eaa75 | 2013-09-27 17:39:57 +0000 | [diff] [blame] | 211 | case JCS_EXT_RGB: |
| 212 | mipsdspr2fct=jsimd_extrgb_gray_convert_mips_dspr2; |
| 213 | break; |
| 214 | case JCS_EXT_RGBX: |
| 215 | case JCS_EXT_RGBA: |
| 216 | mipsdspr2fct=jsimd_extrgbx_gray_convert_mips_dspr2; |
| 217 | break; |
| 218 | case JCS_EXT_BGR: |
| 219 | mipsdspr2fct=jsimd_extbgr_gray_convert_mips_dspr2; |
| 220 | break; |
| 221 | case JCS_EXT_BGRX: |
| 222 | case JCS_EXT_BGRA: |
| 223 | mipsdspr2fct=jsimd_extbgrx_gray_convert_mips_dspr2; |
| 224 | break; |
| 225 | case JCS_EXT_XBGR: |
| 226 | case JCS_EXT_ABGR: |
| 227 | mipsdspr2fct=jsimd_extxbgr_gray_convert_mips_dspr2; |
| 228 | break; |
| 229 | case JCS_EXT_XRGB: |
| 230 | case JCS_EXT_ARGB: |
| 231 | mipsdspr2fct=jsimd_extxrgb_gray_convert_mips_dspr2; |
| 232 | break; |
| 233 | default: |
| 234 | mipsdspr2fct=jsimd_extrgb_gray_convert_mips_dspr2; |
| 235 | break; |
| 236 | } |
| 237 | |
| 238 | if (simd_support & JSIMD_MIPS_DSPR2) |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 239 | mipsdspr2fct(cinfo->image_width, input_buf, output_buf, output_row, |
| 240 | num_rows); |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 241 | } |
| 242 | |
| 243 | GLOBAL(void) |
| 244 | jsimd_ycc_rgb_convert (j_decompress_ptr cinfo, |
| 245 | JSAMPIMAGE input_buf, JDIMENSION input_row, |
| 246 | JSAMPARRAY output_buf, int num_rows) |
| 247 | { |
| 248 | void (*mipsdspr2fct)(JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY, int); |
| 249 | |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 250 | switch(cinfo->out_color_space) { |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 251 | case JCS_EXT_RGB: |
| 252 | mipsdspr2fct=jsimd_ycc_extrgb_convert_mips_dspr2; |
| 253 | break; |
| 254 | case JCS_EXT_RGBX: |
| 255 | case JCS_EXT_RGBA: |
| 256 | mipsdspr2fct=jsimd_ycc_extrgbx_convert_mips_dspr2; |
| 257 | break; |
| 258 | case JCS_EXT_BGR: |
| 259 | mipsdspr2fct=jsimd_ycc_extbgr_convert_mips_dspr2; |
| 260 | break; |
| 261 | case JCS_EXT_BGRX: |
| 262 | case JCS_EXT_BGRA: |
| 263 | mipsdspr2fct=jsimd_ycc_extbgrx_convert_mips_dspr2; |
| 264 | break; |
| 265 | case JCS_EXT_XBGR: |
| 266 | case JCS_EXT_ABGR: |
| 267 | mipsdspr2fct=jsimd_ycc_extxbgr_convert_mips_dspr2; |
| 268 | break; |
| 269 | case JCS_EXT_XRGB: |
| 270 | case JCS_EXT_ARGB: |
| 271 | mipsdspr2fct=jsimd_ycc_extxrgb_convert_mips_dspr2; |
| 272 | break; |
| 273 | default: |
| 274 | mipsdspr2fct=jsimd_ycc_extrgb_convert_mips_dspr2; |
| 275 | break; |
| 276 | } |
| 277 | |
| 278 | if (simd_support & JSIMD_MIPS_DSPR2) |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 279 | mipsdspr2fct(cinfo->output_width, input_buf, input_row, output_buf, |
| 280 | num_rows); |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 281 | } |
| 282 | |
DRC | 1b3fd7e | 2014-05-15 18:26:01 +0000 | [diff] [blame] | 283 | GLOBAL(void) |
| 284 | jsimd_c_null_convert (j_compress_ptr cinfo, |
| 285 | JSAMPARRAY input_buf, JSAMPIMAGE output_buf, |
| 286 | JDIMENSION output_row, int num_rows) |
| 287 | { |
| 288 | if (simd_support & JSIMD_MIPS_DSPR2) |
DRC | c728cfd | 2014-05-18 19:36:05 +0000 | [diff] [blame^] | 289 | jsimd_c_null_convert_mips_dspr2(cinfo->image_width, input_buf, |
| 290 | output_buf, output_row, num_rows, |
| 291 | cinfo->num_components); |
DRC | 1b3fd7e | 2014-05-15 18:26:01 +0000 | [diff] [blame] | 292 | } |
| 293 | |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 294 | GLOBAL(int) |
| 295 | jsimd_can_h2v2_downsample (void) |
| 296 | { |
DRC | 6f2d3c2 | 2013-07-27 21:48:18 +0000 | [diff] [blame] | 297 | init_simd(); |
| 298 | |
| 299 | /* The code is optimised for these values only */ |
| 300 | if (BITS_IN_JSAMPLE != 8) |
| 301 | return 0; |
| 302 | if (sizeof(JDIMENSION) != 4) |
| 303 | return 0; |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 304 | |
DRC | 6f2d3c2 | 2013-07-27 21:48:18 +0000 | [diff] [blame] | 305 | if (simd_support & JSIMD_MIPS_DSPR2) |
| 306 | return 1; |
| 307 | |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 308 | return 0; |
| 309 | } |
| 310 | |
| 311 | GLOBAL(int) |
DRC | 6a61c1e | 2014-05-14 15:00:10 +0000 | [diff] [blame] | 312 | jsimd_can_h2v2_smooth_downsample (void) |
| 313 | { |
| 314 | init_simd(); |
| 315 | |
| 316 | /* The code is optimised for these values only */ |
| 317 | if (BITS_IN_JSAMPLE != 8) |
| 318 | return 0; |
| 319 | if (sizeof(JDIMENSION) != 4) |
| 320 | return 0; |
| 321 | if(DCTSIZE != 8) |
| 322 | return 0; |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 323 | |
DRC | 6a61c1e | 2014-05-14 15:00:10 +0000 | [diff] [blame] | 324 | if (simd_support & JSIMD_MIPS_DSPR2) |
| 325 | return 1; |
| 326 | |
| 327 | return 0; |
| 328 | } |
| 329 | |
| 330 | GLOBAL(int) |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 331 | jsimd_can_h2v1_downsample (void) |
| 332 | { |
DRC | 6f2d3c2 | 2013-07-27 21:48:18 +0000 | [diff] [blame] | 333 | init_simd(); |
| 334 | |
| 335 | /* The code is optimised for these values only */ |
| 336 | if (BITS_IN_JSAMPLE != 8) |
| 337 | return 0; |
| 338 | if (sizeof(JDIMENSION) != 4) |
| 339 | return 0; |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 340 | |
DRC | 6f2d3c2 | 2013-07-27 21:48:18 +0000 | [diff] [blame] | 341 | if (simd_support & JSIMD_MIPS_DSPR2) |
| 342 | return 1; |
| 343 | |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 344 | return 0; |
| 345 | } |
| 346 | |
| 347 | GLOBAL(void) |
| 348 | jsimd_h2v2_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, |
| 349 | JSAMPARRAY input_data, JSAMPARRAY output_data) |
| 350 | { |
DRC | 6f2d3c2 | 2013-07-27 21:48:18 +0000 | [diff] [blame] | 351 | if (simd_support & JSIMD_MIPS_DSPR2) |
| 352 | jsimd_h2v2_downsample_mips_dspr2(cinfo->image_width, |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 353 | cinfo->max_v_samp_factor, |
| 354 | compptr->v_samp_factor, |
| 355 | compptr->width_in_blocks, input_data, |
| 356 | output_data); |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 357 | } |
| 358 | |
| 359 | GLOBAL(void) |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 360 | jsimd_h2v2_smooth_downsample (j_compress_ptr cinfo, |
| 361 | jpeg_component_info * compptr, |
DRC | 6a61c1e | 2014-05-14 15:00:10 +0000 | [diff] [blame] | 362 | JSAMPARRAY input_data, JSAMPARRAY output_data) |
| 363 | { |
| 364 | jsimd_h2v2_smooth_downsample_mips_dspr2(input_data, output_data, |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 365 | compptr->v_samp_factor, |
| 366 | cinfo->max_v_samp_factor, |
| 367 | cinfo->smoothing_factor, |
| 368 | compptr->width_in_blocks, |
| 369 | cinfo->image_width); |
DRC | 6a61c1e | 2014-05-14 15:00:10 +0000 | [diff] [blame] | 370 | } |
| 371 | |
| 372 | GLOBAL(void) |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 373 | jsimd_h2v1_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, |
| 374 | JSAMPARRAY input_data, JSAMPARRAY output_data) |
| 375 | { |
DRC | 6f2d3c2 | 2013-07-27 21:48:18 +0000 | [diff] [blame] | 376 | if (simd_support & JSIMD_MIPS_DSPR2) |
| 377 | jsimd_h2v1_downsample_mips_dspr2(cinfo->image_width, |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 378 | cinfo->max_v_samp_factor, |
| 379 | compptr->v_samp_factor, |
| 380 | compptr->width_in_blocks, |
| 381 | input_data, output_data); |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 382 | } |
| 383 | |
| 384 | GLOBAL(int) |
| 385 | jsimd_can_h2v2_upsample (void) |
| 386 | { |
DRC | 16962c1 | 2013-07-27 21:50:02 +0000 | [diff] [blame] | 387 | init_simd(); |
| 388 | |
| 389 | /* The code is optimised for these values only */ |
| 390 | if (BITS_IN_JSAMPLE != 8) |
| 391 | return 0; |
| 392 | if (sizeof(JDIMENSION) != 4) |
| 393 | return 0; |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 394 | |
DRC | 16962c1 | 2013-07-27 21:50:02 +0000 | [diff] [blame] | 395 | if (simd_support & JSIMD_MIPS_DSPR2) |
| 396 | return 1; |
| 397 | |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 398 | return 0; |
| 399 | } |
| 400 | |
| 401 | GLOBAL(int) |
| 402 | jsimd_can_h2v1_upsample (void) |
| 403 | { |
DRC | 16962c1 | 2013-07-27 21:50:02 +0000 | [diff] [blame] | 404 | init_simd(); |
| 405 | |
| 406 | /* The code is optimised for these values only */ |
| 407 | if (BITS_IN_JSAMPLE != 8) |
| 408 | return 0; |
| 409 | if (sizeof(JDIMENSION) != 4) |
| 410 | return 0; |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 411 | |
DRC | 16962c1 | 2013-07-27 21:50:02 +0000 | [diff] [blame] | 412 | if (simd_support & JSIMD_MIPS_DSPR2) |
| 413 | return 1; |
| 414 | |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 415 | return 0; |
| 416 | } |
| 417 | |
| 418 | GLOBAL(void) |
| 419 | jsimd_h2v2_upsample (j_decompress_ptr cinfo, |
| 420 | jpeg_component_info * compptr, |
| 421 | JSAMPARRAY input_data, |
| 422 | JSAMPARRAY * output_data_ptr) |
| 423 | { |
DRC | 16962c1 | 2013-07-27 21:50:02 +0000 | [diff] [blame] | 424 | if (simd_support & JSIMD_MIPS_DSPR2) |
| 425 | jsimd_h2v2_upsample_mips_dspr2(cinfo->max_v_samp_factor, |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 426 | cinfo->output_width, input_data, |
| 427 | output_data_ptr); |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 428 | } |
| 429 | |
| 430 | GLOBAL(void) |
| 431 | jsimd_h2v1_upsample (j_decompress_ptr cinfo, |
| 432 | jpeg_component_info * compptr, |
| 433 | JSAMPARRAY input_data, |
| 434 | JSAMPARRAY * output_data_ptr) |
| 435 | { |
DRC | 16962c1 | 2013-07-27 21:50:02 +0000 | [diff] [blame] | 436 | if (simd_support & JSIMD_MIPS_DSPR2) |
| 437 | jsimd_h2v1_upsample_mips_dspr2(cinfo->max_v_samp_factor, |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 438 | cinfo->output_width, input_data, |
| 439 | output_data_ptr); |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 440 | } |
| 441 | |
| 442 | GLOBAL(int) |
| 443 | jsimd_can_h2v2_fancy_upsample (void) |
| 444 | { |
DRC | 86fbf35 | 2013-07-27 21:44:14 +0000 | [diff] [blame] | 445 | init_simd(); |
| 446 | |
| 447 | /* The code is optimised for these values only */ |
| 448 | if (BITS_IN_JSAMPLE != 8) |
| 449 | return 0; |
| 450 | if (sizeof(JDIMENSION) != 4) |
| 451 | return 0; |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 452 | |
DRC | 86fbf35 | 2013-07-27 21:44:14 +0000 | [diff] [blame] | 453 | if (simd_support & JSIMD_MIPS_DSPR2) |
| 454 | return 1; |
| 455 | |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 456 | return 0; |
| 457 | } |
| 458 | |
| 459 | GLOBAL(int) |
| 460 | jsimd_can_h2v1_fancy_upsample (void) |
| 461 | { |
DRC | 86fbf35 | 2013-07-27 21:44:14 +0000 | [diff] [blame] | 462 | init_simd(); |
| 463 | |
| 464 | /* The code is optimised for these values only */ |
| 465 | if (BITS_IN_JSAMPLE != 8) |
| 466 | return 0; |
| 467 | if (sizeof(JDIMENSION) != 4) |
| 468 | return 0; |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 469 | |
DRC | 86fbf35 | 2013-07-27 21:44:14 +0000 | [diff] [blame] | 470 | if (simd_support & JSIMD_MIPS_DSPR2) |
| 471 | return 1; |
| 472 | |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 473 | return 0; |
| 474 | } |
| 475 | |
| 476 | GLOBAL(void) |
| 477 | jsimd_h2v2_fancy_upsample (j_decompress_ptr cinfo, |
| 478 | jpeg_component_info * compptr, |
| 479 | JSAMPARRAY input_data, |
| 480 | JSAMPARRAY * output_data_ptr) |
| 481 | { |
DRC | 86fbf35 | 2013-07-27 21:44:14 +0000 | [diff] [blame] | 482 | if (simd_support & JSIMD_MIPS_DSPR2) |
| 483 | jsimd_h2v2_fancy_upsample_mips_dspr2(cinfo->max_v_samp_factor, |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 484 | compptr->downsampled_width, |
| 485 | input_data, output_data_ptr); |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 486 | } |
| 487 | |
| 488 | GLOBAL(void) |
| 489 | jsimd_h2v1_fancy_upsample (j_decompress_ptr cinfo, |
| 490 | jpeg_component_info * compptr, |
| 491 | JSAMPARRAY input_data, |
| 492 | JSAMPARRAY * output_data_ptr) |
| 493 | { |
DRC | 86fbf35 | 2013-07-27 21:44:14 +0000 | [diff] [blame] | 494 | if (simd_support & JSIMD_MIPS_DSPR2) |
| 495 | jsimd_h2v1_fancy_upsample_mips_dspr2(cinfo->max_v_samp_factor, |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 496 | compptr->downsampled_width, |
| 497 | input_data, output_data_ptr); |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 498 | } |
| 499 | |
| 500 | GLOBAL(int) |
| 501 | jsimd_can_h2v2_merged_upsample (void) |
| 502 | { |
DRC | b844eaa | 2014-05-13 18:40:14 +0000 | [diff] [blame] | 503 | if (BITS_IN_JSAMPLE != 8) |
| 504 | return 0; |
| 505 | if (sizeof(JDIMENSION) != 4) |
| 506 | return 0; |
| 507 | |
| 508 | if (simd_support & JSIMD_MIPS_DSPR2) |
| 509 | return 1; |
| 510 | |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 511 | return 0; |
| 512 | } |
| 513 | |
| 514 | GLOBAL(int) |
| 515 | jsimd_can_h2v1_merged_upsample (void) |
| 516 | { |
DRC | b844eaa | 2014-05-13 18:40:14 +0000 | [diff] [blame] | 517 | if (BITS_IN_JSAMPLE != 8) |
| 518 | return 0; |
| 519 | if (sizeof(JDIMENSION) != 4) |
| 520 | return 0; |
| 521 | |
| 522 | if (simd_support & JSIMD_MIPS_DSPR2) |
| 523 | return 1; |
| 524 | |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 525 | return 0; |
| 526 | } |
| 527 | |
| 528 | GLOBAL(void) |
| 529 | jsimd_h2v2_merged_upsample (j_decompress_ptr cinfo, |
| 530 | JSAMPIMAGE input_buf, |
| 531 | JDIMENSION in_row_group_ctr, |
| 532 | JSAMPARRAY output_buf) |
| 533 | { |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 534 | void (*mipsdspr2fct)(JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY, |
| 535 | JSAMPLE *); |
DRC | b844eaa | 2014-05-13 18:40:14 +0000 | [diff] [blame] | 536 | |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 537 | switch(cinfo->out_color_space) { |
DRC | b844eaa | 2014-05-13 18:40:14 +0000 | [diff] [blame] | 538 | case JCS_EXT_RGB: |
| 539 | mipsdspr2fct=jsimd_h2v2_extrgb_merged_upsample_mips_dspr2; |
| 540 | break; |
| 541 | case JCS_EXT_RGBX: |
| 542 | case JCS_EXT_RGBA: |
| 543 | mipsdspr2fct=jsimd_h2v2_extrgbx_merged_upsample_mips_dspr2; |
| 544 | break; |
| 545 | case JCS_EXT_BGR: |
| 546 | mipsdspr2fct=jsimd_h2v2_extbgr_merged_upsample_mips_dspr2; |
| 547 | break; |
| 548 | case JCS_EXT_BGRX: |
| 549 | case JCS_EXT_BGRA: |
| 550 | mipsdspr2fct=jsimd_h2v2_extbgrx_merged_upsample_mips_dspr2; |
| 551 | break; |
| 552 | case JCS_EXT_XBGR: |
| 553 | case JCS_EXT_ABGR: |
| 554 | mipsdspr2fct=jsimd_h2v2_extxbgr_merged_upsample_mips_dspr2; |
| 555 | break; |
| 556 | case JCS_EXT_XRGB: |
| 557 | case JCS_EXT_ARGB: |
| 558 | mipsdspr2fct=jsimd_h2v2_extxrgb_merged_upsample_mips_dspr2; |
| 559 | break; |
| 560 | default: |
| 561 | mipsdspr2fct=jsimd_h2v2_extrgb_merged_upsample_mips_dspr2; |
| 562 | break; |
| 563 | } |
| 564 | |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 565 | mipsdspr2fct(cinfo->output_width, input_buf, in_row_group_ctr, output_buf, |
| 566 | cinfo->sample_range_limit); |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 567 | } |
| 568 | |
| 569 | GLOBAL(void) |
| 570 | jsimd_h2v1_merged_upsample (j_decompress_ptr cinfo, |
| 571 | JSAMPIMAGE input_buf, |
| 572 | JDIMENSION in_row_group_ctr, |
| 573 | JSAMPARRAY output_buf) |
| 574 | { |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 575 | void (*mipsdspr2fct)(JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY, |
| 576 | JSAMPLE *); |
DRC | b844eaa | 2014-05-13 18:40:14 +0000 | [diff] [blame] | 577 | |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 578 | switch(cinfo->out_color_space) { |
DRC | b844eaa | 2014-05-13 18:40:14 +0000 | [diff] [blame] | 579 | case JCS_EXT_RGB: |
| 580 | mipsdspr2fct=jsimd_h2v1_extrgb_merged_upsample_mips_dspr2; |
| 581 | break; |
| 582 | case JCS_EXT_RGBX: |
| 583 | case JCS_EXT_RGBA: |
| 584 | mipsdspr2fct=jsimd_h2v1_extrgbx_merged_upsample_mips_dspr2; |
| 585 | break; |
| 586 | case JCS_EXT_BGR: |
| 587 | mipsdspr2fct=jsimd_h2v1_extbgr_merged_upsample_mips_dspr2; |
| 588 | break; |
| 589 | case JCS_EXT_BGRX: |
| 590 | case JCS_EXT_BGRA: |
| 591 | mipsdspr2fct=jsimd_h2v1_extbgrx_merged_upsample_mips_dspr2; |
| 592 | break; |
| 593 | case JCS_EXT_XBGR: |
| 594 | case JCS_EXT_ABGR: |
| 595 | mipsdspr2fct=jsimd_h2v1_extxbgr_merged_upsample_mips_dspr2; |
| 596 | break; |
| 597 | case JCS_EXT_XRGB: |
| 598 | case JCS_EXT_ARGB: |
| 599 | mipsdspr2fct=jsimd_h2v1_extxrgb_merged_upsample_mips_dspr2; |
| 600 | break; |
| 601 | default: |
| 602 | mipsdspr2fct=jsimd_h2v1_extrgb_merged_upsample_mips_dspr2; |
| 603 | break; |
| 604 | } |
| 605 | |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 606 | mipsdspr2fct(cinfo->output_width, input_buf, in_row_group_ctr, output_buf, |
| 607 | cinfo->sample_range_limit); |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 608 | } |
| 609 | |
| 610 | GLOBAL(int) |
| 611 | jsimd_can_convsamp (void) |
| 612 | { |
DRC | fff6c23 | 2013-10-12 21:39:20 +0000 | [diff] [blame] | 613 | init_simd(); |
| 614 | |
| 615 | /* The code is optimised for these values only */ |
| 616 | if (DCTSIZE != 8) |
| 617 | return 0; |
| 618 | if (BITS_IN_JSAMPLE != 8) |
| 619 | return 0; |
| 620 | if (sizeof(JDIMENSION) != 4) |
| 621 | return 0; |
| 622 | if (sizeof(DCTELEM) != 2) |
| 623 | return 0; |
| 624 | |
| 625 | if (simd_support & JSIMD_MIPS_DSPR2) |
| 626 | return 1; |
| 627 | |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 628 | return 0; |
| 629 | } |
| 630 | |
| 631 | GLOBAL(int) |
| 632 | jsimd_can_convsamp_float (void) |
| 633 | { |
DRC | 3d72728 | 2013-10-09 18:39:44 +0000 | [diff] [blame] | 634 | init_simd(); |
| 635 | |
| 636 | /* The code is optimised for these values only */ |
| 637 | if (DCTSIZE != 8) |
| 638 | return 0; |
| 639 | if (sizeof(JCOEF) != 2) |
| 640 | return 0; |
| 641 | if (BITS_IN_JSAMPLE != 8) |
| 642 | return 0; |
| 643 | if (sizeof(JDIMENSION) != 4) |
| 644 | return 0; |
| 645 | if (sizeof(ISLOW_MULT_TYPE) != 2) |
| 646 | return 0; |
| 647 | |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 648 | if (simd_support & JSIMD_MIPS_DSPR2) |
DRC | 3d72728 | 2013-10-09 18:39:44 +0000 | [diff] [blame] | 649 | return 1; |
| 650 | |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 651 | return 0; |
| 652 | } |
| 653 | |
| 654 | GLOBAL(void) |
| 655 | jsimd_convsamp (JSAMPARRAY sample_data, JDIMENSION start_col, |
| 656 | DCTELEM * workspace) |
| 657 | { |
DRC | fff6c23 | 2013-10-12 21:39:20 +0000 | [diff] [blame] | 658 | if (simd_support & JSIMD_MIPS_DSPR2) |
| 659 | jsimd_convsamp_mips_dspr2(sample_data, start_col, workspace); |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 660 | } |
| 661 | |
| 662 | GLOBAL(void) |
| 663 | jsimd_convsamp_float (JSAMPARRAY sample_data, JDIMENSION start_col, |
| 664 | FAST_FLOAT * workspace) |
| 665 | { |
DRC | 3d72728 | 2013-10-09 18:39:44 +0000 | [diff] [blame] | 666 | if ((simd_support & JSIMD_MIPS_DSPR2)) |
| 667 | jsimd_convsamp_float_mips_dspr2(sample_data, start_col, workspace); |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 668 | } |
| 669 | |
| 670 | GLOBAL(int) |
| 671 | jsimd_can_fdct_islow (void) |
| 672 | { |
DRC | a6b7fbd | 2013-09-30 18:13:27 +0000 | [diff] [blame] | 673 | init_simd(); |
| 674 | |
| 675 | /* The code is optimised for these values only */ |
| 676 | if (DCTSIZE != 8) |
| 677 | return 0; |
| 678 | if (sizeof(DCTELEM) != 2) |
| 679 | return 0; |
| 680 | |
| 681 | if (simd_support & JSIMD_MIPS_DSPR2) |
| 682 | return 1; |
| 683 | |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 684 | return 0; |
| 685 | } |
| 686 | |
| 687 | GLOBAL(int) |
| 688 | jsimd_can_fdct_ifast (void) |
| 689 | { |
DRC | 71e06a7 | 2013-10-08 02:11:21 +0000 | [diff] [blame] | 690 | init_simd(); |
| 691 | |
| 692 | /* The code is optimised for these values only */ |
| 693 | if (DCTSIZE != 8) |
| 694 | return 0; |
| 695 | if (sizeof(DCTELEM) != 2) |
| 696 | return 0; |
| 697 | |
| 698 | if (simd_support & JSIMD_MIPS_DSPR2) |
| 699 | return 1; |
| 700 | |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 701 | return 0; |
| 702 | } |
| 703 | |
| 704 | GLOBAL(int) |
| 705 | jsimd_can_fdct_float (void) |
| 706 | { |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 707 | init_simd(); |
| 708 | |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 709 | return 0; |
| 710 | } |
| 711 | |
| 712 | GLOBAL(void) |
| 713 | jsimd_fdct_islow (DCTELEM * data) |
| 714 | { |
DRC | a6b7fbd | 2013-09-30 18:13:27 +0000 | [diff] [blame] | 715 | if (simd_support & JSIMD_MIPS_DSPR2) |
| 716 | jsimd_fdct_islow_mips_dspr2(data); |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 717 | } |
| 718 | |
| 719 | GLOBAL(void) |
| 720 | jsimd_fdct_ifast (DCTELEM * data) |
| 721 | { |
DRC | 71e06a7 | 2013-10-08 02:11:21 +0000 | [diff] [blame] | 722 | if (simd_support & JSIMD_MIPS_DSPR2) |
| 723 | jsimd_fdct_ifast_mips_dspr2(data); |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 724 | } |
| 725 | |
| 726 | GLOBAL(void) |
| 727 | jsimd_fdct_float (FAST_FLOAT * data) |
| 728 | { |
| 729 | } |
| 730 | |
| 731 | GLOBAL(int) |
| 732 | jsimd_can_quantize (void) |
| 733 | { |
DRC | a6b7fbd | 2013-09-30 18:13:27 +0000 | [diff] [blame] | 734 | init_simd(); |
| 735 | |
| 736 | /* The code is optimised for these values only */ |
| 737 | if (DCTSIZE != 8) |
| 738 | return 0; |
| 739 | if (sizeof(JCOEF) != 2) |
| 740 | return 0; |
| 741 | if (sizeof(DCTELEM) != 2) |
| 742 | return 0; |
| 743 | |
| 744 | if (simd_support & JSIMD_MIPS_DSPR2) |
| 745 | return 1; |
| 746 | |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 747 | return 0; |
| 748 | } |
| 749 | |
| 750 | GLOBAL(int) |
| 751 | jsimd_can_quantize_float (void) |
| 752 | { |
DRC | 3d72728 | 2013-10-09 18:39:44 +0000 | [diff] [blame] | 753 | init_simd(); |
| 754 | |
| 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 | |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 767 | if (simd_support & JSIMD_MIPS_DSPR2) |
DRC | 3d72728 | 2013-10-09 18:39:44 +0000 | [diff] [blame] | 768 | return 1; |
| 769 | |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 770 | return 0; |
| 771 | } |
| 772 | |
| 773 | GLOBAL(void) |
| 774 | jsimd_quantize (JCOEFPTR coef_block, DCTELEM * divisors, |
| 775 | DCTELEM * workspace) |
| 776 | { |
DRC | a6b7fbd | 2013-09-30 18:13:27 +0000 | [diff] [blame] | 777 | if (simd_support & JSIMD_MIPS_DSPR2) |
| 778 | jsimd_quantize_mips_dspr2(coef_block, divisors, workspace); |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 779 | } |
| 780 | |
| 781 | GLOBAL(void) |
| 782 | jsimd_quantize_float (JCOEFPTR coef_block, FAST_FLOAT * divisors, |
| 783 | FAST_FLOAT * workspace) |
| 784 | { |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 785 | if (simd_support & JSIMD_MIPS_DSPR2) |
DRC | 3d72728 | 2013-10-09 18:39:44 +0000 | [diff] [blame] | 786 | jsimd_quantize_float_mips_dspr2(coef_block, divisors, workspace); |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 787 | } |
| 788 | |
| 789 | GLOBAL(int) |
| 790 | jsimd_can_idct_2x2 (void) |
| 791 | { |
DRC | 2ccf4d1 | 2013-09-27 17:43:23 +0000 | [diff] [blame] | 792 | init_simd(); |
| 793 | |
| 794 | /* The code is optimised for these values only */ |
| 795 | if (DCTSIZE != 8) |
| 796 | return 0; |
| 797 | if (sizeof(JCOEF) != 2) |
| 798 | return 0; |
| 799 | if (BITS_IN_JSAMPLE != 8) |
| 800 | return 0; |
| 801 | if (sizeof(JDIMENSION) != 4) |
| 802 | return 0; |
| 803 | if (sizeof(ISLOW_MULT_TYPE) != 2) |
| 804 | return 0; |
| 805 | |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 806 | if (simd_support & JSIMD_MIPS_DSPR2) |
DRC | 2ccf4d1 | 2013-09-27 17:43:23 +0000 | [diff] [blame] | 807 | return 1; |
| 808 | |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 809 | return 0; |
| 810 | } |
| 811 | |
| 812 | GLOBAL(int) |
| 813 | jsimd_can_idct_4x4 (void) |
| 814 | { |
DRC | 2ccf4d1 | 2013-09-27 17:43:23 +0000 | [diff] [blame] | 815 | init_simd(); |
| 816 | |
| 817 | /* The code is optimised for these values only */ |
| 818 | if (DCTSIZE != 8) |
| 819 | return 0; |
| 820 | if (sizeof(JCOEF) != 2) |
| 821 | return 0; |
| 822 | if (BITS_IN_JSAMPLE != 8) |
| 823 | return 0; |
| 824 | if (sizeof(JDIMENSION) != 4) |
| 825 | return 0; |
| 826 | if (sizeof(ISLOW_MULT_TYPE) != 2) |
| 827 | return 0; |
| 828 | |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 829 | if (simd_support & JSIMD_MIPS_DSPR2) |
DRC | 2ccf4d1 | 2013-09-27 17:43:23 +0000 | [diff] [blame] | 830 | return 1; |
| 831 | |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 832 | return 0; |
| 833 | } |
| 834 | |
DRC | e500591 | 2013-09-27 17:51:08 +0000 | [diff] [blame] | 835 | GLOBAL(int) |
| 836 | jsimd_can_idct_6x6 (void) |
| 837 | { |
| 838 | init_simd(); |
| 839 | |
| 840 | /* The code is optimised for these values only */ |
| 841 | if (DCTSIZE != 8) |
| 842 | return 0; |
| 843 | if (sizeof(JCOEF) != 2) |
| 844 | return 0; |
| 845 | if (BITS_IN_JSAMPLE != 8) |
| 846 | return 0; |
| 847 | if (sizeof(JDIMENSION) != 4) |
| 848 | return 0; |
| 849 | if (sizeof(ISLOW_MULT_TYPE) != 2) |
| 850 | return 0; |
| 851 | |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 852 | if (simd_support & JSIMD_MIPS_DSPR2) |
DRC | e500591 | 2013-09-27 17:51:08 +0000 | [diff] [blame] | 853 | return 1; |
| 854 | |
| 855 | return 0; |
| 856 | } |
| 857 | |
| 858 | GLOBAL(int) |
| 859 | jsimd_can_idct_12x12 (void) |
| 860 | { |
| 861 | init_simd(); |
| 862 | |
| 863 | if (BITS_IN_JSAMPLE != 8) |
| 864 | return 0; |
| 865 | if (DCTSIZE != 8) |
| 866 | return 0; |
| 867 | if (sizeof(JCOEF) != 2) |
| 868 | return 0; |
| 869 | if (sizeof(JDIMENSION) != 4) |
| 870 | return 0; |
| 871 | if (sizeof(ISLOW_MULT_TYPE) != 2) |
| 872 | return 0; |
| 873 | |
| 874 | if (simd_support & JSIMD_MIPS_DSPR2) |
| 875 | return 1; |
| 876 | |
| 877 | return 0; |
| 878 | } |
| 879 | |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 880 | GLOBAL(void) |
| 881 | jsimd_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
| 882 | JCOEFPTR coef_block, JSAMPARRAY output_buf, |
| 883 | JDIMENSION output_col) |
| 884 | { |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 885 | if (simd_support & JSIMD_MIPS_DSPR2) |
| 886 | jsimd_idct_2x2_mips_dspr2(compptr->dct_table, coef_block, output_buf, |
| 887 | output_col); |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 888 | } |
| 889 | |
| 890 | GLOBAL(void) |
| 891 | jsimd_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
| 892 | JCOEFPTR coef_block, JSAMPARRAY output_buf, |
| 893 | JDIMENSION output_col) |
| 894 | { |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 895 | if (simd_support & JSIMD_MIPS_DSPR2) { |
DRC | 2ccf4d1 | 2013-09-27 17:43:23 +0000 | [diff] [blame] | 896 | int workspace[DCTSIZE*4]; /* buffers data between passes */ |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 897 | jsimd_idct_4x4_mips_dspr2(compptr->dct_table, coef_block, output_buf, |
| 898 | output_col, workspace); |
DRC | 2ccf4d1 | 2013-09-27 17:43:23 +0000 | [diff] [blame] | 899 | } |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 900 | } |
DRC | a6b7fbd | 2013-09-30 18:13:27 +0000 | [diff] [blame] | 901 | |
DRC | e500591 | 2013-09-27 17:51:08 +0000 | [diff] [blame] | 902 | GLOBAL(void) |
| 903 | jsimd_idct_6x6 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
| 904 | JCOEFPTR coef_block, JSAMPARRAY output_buf, |
| 905 | JDIMENSION output_col) |
| 906 | { |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 907 | if (simd_support & JSIMD_MIPS_DSPR2) |
| 908 | jsimd_idct_6x6_mips_dspr2(compptr->dct_table, coef_block, output_buf, |
| 909 | output_col); |
DRC | e500591 | 2013-09-27 17:51:08 +0000 | [diff] [blame] | 910 | } |
| 911 | |
| 912 | GLOBAL(void) |
| 913 | jsimd_idct_12x12 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
| 914 | JCOEFPTR coef_block, |
| 915 | JSAMPARRAY output_buf, JDIMENSION output_col) |
| 916 | { |
| 917 | if (simd_support & JSIMD_MIPS_DSPR2) { |
| 918 | int workspace[96]; |
| 919 | int output[12] = { |
| 920 | (int)(output_buf[0] + output_col), |
| 921 | (int)(output_buf[1] + output_col), |
| 922 | (int)(output_buf[2] + output_col), |
| 923 | (int)(output_buf[3] + output_col), |
| 924 | (int)(output_buf[4] + output_col), |
| 925 | (int)(output_buf[5] + output_col), |
| 926 | (int)(output_buf[6] + output_col), |
| 927 | (int)(output_buf[7] + output_col), |
| 928 | (int)(output_buf[8] + output_col), |
| 929 | (int)(output_buf[9] + output_col), |
| 930 | (int)(output_buf[10] + output_col), |
| 931 | (int)(output_buf[11] + output_col), |
| 932 | }; |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 933 | jsimd_idct_12x12_pass1_mips_dspr2(coef_block, compptr->dct_table, |
| 934 | workspace); |
DRC | e500591 | 2013-09-27 17:51:08 +0000 | [diff] [blame] | 935 | jsimd_idct_12x12_pass2_mips_dspr2(workspace, output); |
| 936 | } |
| 937 | } |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 938 | |
| 939 | GLOBAL(int) |
| 940 | jsimd_can_idct_islow (void) |
| 941 | { |
DRC | 3434786 | 2014-05-06 09:53:21 +0000 | [diff] [blame] | 942 | init_simd(); |
| 943 | |
| 944 | /* The code is optimised for these values only */ |
| 945 | if (DCTSIZE != 8) |
| 946 | return 0; |
| 947 | if (sizeof(JCOEF) != 2) |
| 948 | return 0; |
| 949 | if (BITS_IN_JSAMPLE != 8) |
| 950 | return 0; |
| 951 | if (sizeof(JDIMENSION) != 4) |
| 952 | return 0; |
| 953 | if (sizeof(ISLOW_MULT_TYPE) != 2) |
| 954 | return 0; |
| 955 | |
| 956 | if (simd_support & JSIMD_MIPS_DSPR2) |
| 957 | return 1; |
| 958 | |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 959 | return 0; |
| 960 | } |
| 961 | |
| 962 | GLOBAL(int) |
| 963 | jsimd_can_idct_ifast (void) |
| 964 | { |
DRC | d3131c1 | 2013-10-08 02:18:59 +0000 | [diff] [blame] | 965 | init_simd(); |
| 966 | |
| 967 | /* The code is optimised for these values only */ |
| 968 | if (DCTSIZE != 8) |
| 969 | return 0; |
| 970 | if (sizeof(JCOEF) != 2) |
| 971 | return 0; |
| 972 | if (BITS_IN_JSAMPLE != 8) |
| 973 | return 0; |
| 974 | if (sizeof(JDIMENSION) != 4) |
| 975 | return 0; |
| 976 | if (sizeof(IFAST_MULT_TYPE) != 2) |
| 977 | return 0; |
| 978 | if (IFAST_SCALE_BITS != 2) |
| 979 | return 0; |
| 980 | |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 981 | if (simd_support & JSIMD_MIPS_DSPR2) |
DRC | d3131c1 | 2013-10-08 02:18:59 +0000 | [diff] [blame] | 982 | return 1; |
| 983 | |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 984 | return 0; |
| 985 | } |
| 986 | |
| 987 | GLOBAL(int) |
| 988 | jsimd_can_idct_float (void) |
| 989 | { |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 990 | init_simd(); |
| 991 | |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 992 | return 0; |
| 993 | } |
| 994 | |
| 995 | GLOBAL(void) |
| 996 | jsimd_idct_islow (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 997 | JCOEFPTR coef_block, JSAMPARRAY output_buf, |
| 998 | JDIMENSION output_col) |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 999 | { |
DRC | 3434786 | 2014-05-06 09:53:21 +0000 | [diff] [blame] | 1000 | if (simd_support & JSIMD_MIPS_DSPR2) { |
| 1001 | int output[8] = { |
| 1002 | (int)(output_buf[0] + output_col), |
| 1003 | (int)(output_buf[1] + output_col), |
| 1004 | (int)(output_buf[2] + output_col), |
| 1005 | (int)(output_buf[3] + output_col), |
| 1006 | (int)(output_buf[4] + output_col), |
| 1007 | (int)(output_buf[5] + output_col), |
| 1008 | (int)(output_buf[6] + output_col), |
| 1009 | (int)(output_buf[7] + output_col), |
| 1010 | }; |
| 1011 | |
| 1012 | jsimd_idct_islow_mips_dspr2(coef_block, compptr->dct_table, |
| 1013 | output, IDCT_range_limit(cinfo)); |
| 1014 | } |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 1015 | } |
| 1016 | |
| 1017 | GLOBAL(void) |
| 1018 | jsimd_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
DRC | d3131c1 | 2013-10-08 02:18:59 +0000 | [diff] [blame] | 1019 | JCOEFPTR coef_block, JSAMPARRAY output_buf, |
| 1020 | JDIMENSION output_col) |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 1021 | { |
DRC | d3131c1 | 2013-10-08 02:18:59 +0000 | [diff] [blame] | 1022 | if (simd_support & JSIMD_MIPS_DSPR2) { |
| 1023 | JCOEFPTR inptr; |
| 1024 | IFAST_MULT_TYPE * quantptr; |
| 1025 | DCTELEM workspace[DCTSIZE2]; /* buffers data between passes */ |
| 1026 | |
| 1027 | /* Pass 1: process columns from input, store into work array. */ |
| 1028 | |
| 1029 | inptr = coef_block; |
| 1030 | quantptr = (IFAST_MULT_TYPE *) compptr->dct_table; |
| 1031 | |
| 1032 | jsimd_idct_ifast_cols_mips_dspr2(inptr, quantptr, |
| 1033 | workspace, mips_idct_ifast_coefs); |
| 1034 | |
| 1035 | /* Pass 2: process rows from work array, store into output array. */ |
| 1036 | /* Note that we must descale the results by a factor of 8 == 2**3, */ |
| 1037 | /* and also undo the PASS1_BITS scaling. */ |
| 1038 | |
| 1039 | jsimd_idct_ifast_rows_mips_dspr2(workspace, output_buf, |
| 1040 | output_col, mips_idct_ifast_coefs); |
| 1041 | } |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 1042 | } |
| 1043 | |
| 1044 | GLOBAL(void) |
| 1045 | jsimd_idct_float (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 1046 | JCOEFPTR coef_block, JSAMPARRAY output_buf, |
| 1047 | JDIMENSION output_col) |
DRC | 0be9fa5 | 2013-07-24 21:50:20 +0000 | [diff] [blame] | 1048 | { |
| 1049 | } |