DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 1 | /* |
| 2 | * jsimd_arm.c |
| 3 | * |
| 4 | * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB |
DRC | 499c470 | 2016-01-13 03:13:20 -0600 | [diff] [blame] | 5 | * Copyright 2009-2011, 2013-2014, 2016 D. R. Commander |
| 6 | * Copyright 2015-2016 Matthieu Darbois |
DRC | e189ec7 | 2014-02-06 19:15:03 +0000 | [diff] [blame] | 7 | * |
DRC | 321e068 | 2011-05-03 08:47:43 +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 |
| 14 | * 32-bit ARM architecture. |
DRC | 321e068 | 2011-05-03 08:47:43 +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; |
DRC | e8aa5fa | 2016-01-15 13:15:54 -0600 | [diff] [blame] | 30 | static unsigned int simd_huffman = 1; |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 31 | |
DRC | 4346f91 | 2011-06-14 22:16:50 +0000 | [diff] [blame] | 32 | #if defined(__linux__) || defined(ANDROID) || defined(__ANDROID__) |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 33 | |
| 34 | #define SOMEWHAT_SANE_PROC_CPUINFO_SIZE_LIMIT (1024 * 1024) |
| 35 | |
| 36 | LOCAL(int) |
| 37 | check_feature (char *buffer, char *feature) |
| 38 | { |
| 39 | char *p; |
| 40 | if (*feature == 0) |
| 41 | return 0; |
| 42 | if (strncmp(buffer, "Features", 8) != 0) |
| 43 | return 0; |
| 44 | buffer += 8; |
| 45 | while (isspace(*buffer)) |
| 46 | buffer++; |
| 47 | |
| 48 | /* Check if 'feature' is present in the buffer as a separate word */ |
| 49 | while ((p = strstr(buffer, feature))) { |
| 50 | if (p > buffer && !isspace(*(p - 1))) { |
| 51 | buffer++; |
| 52 | continue; |
| 53 | } |
| 54 | p += strlen(feature); |
| 55 | if (*p != 0 && !isspace(*p)) { |
| 56 | buffer++; |
| 57 | continue; |
| 58 | } |
| 59 | return 1; |
| 60 | } |
| 61 | return 0; |
| 62 | } |
| 63 | |
| 64 | LOCAL(int) |
| 65 | parse_proc_cpuinfo (int bufsize) |
| 66 | { |
| 67 | char *buffer = (char *)malloc(bufsize); |
| 68 | FILE *fd; |
| 69 | simd_support = 0; |
| 70 | |
| 71 | if (!buffer) |
| 72 | return 0; |
| 73 | |
| 74 | fd = fopen("/proc/cpuinfo", "r"); |
| 75 | if (fd) { |
| 76 | while (fgets(buffer, bufsize, fd)) { |
| 77 | if (!strchr(buffer, '\n') && !feof(fd)) { |
| 78 | /* "impossible" happened - insufficient size of the buffer! */ |
| 79 | fclose(fd); |
| 80 | free(buffer); |
| 81 | return 0; |
| 82 | } |
| 83 | if (check_feature(buffer, "neon")) |
| 84 | simd_support |= JSIMD_ARM_NEON; |
| 85 | } |
| 86 | fclose(fd); |
| 87 | } |
| 88 | free(buffer); |
| 89 | return 1; |
| 90 | } |
| 91 | |
| 92 | #endif |
| 93 | |
| 94 | /* |
| 95 | * Check what SIMD accelerations are supported. |
| 96 | * |
| 97 | * FIXME: This code is racy under a multi-threaded environment. |
| 98 | */ |
| 99 | LOCAL(void) |
| 100 | init_simd (void) |
| 101 | { |
| 102 | char *env = NULL; |
DRC | 4346f91 | 2011-06-14 22:16:50 +0000 | [diff] [blame] | 103 | #if !defined(__ARM_NEON__) && defined(__linux__) || defined(ANDROID) || defined(__ANDROID__) |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 104 | int bufsize = 1024; /* an initial guess for the line buffer size limit */ |
DRC | 4346f91 | 2011-06-14 22:16:50 +0000 | [diff] [blame] | 105 | #endif |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 106 | |
DRC | d65d99a | 2012-01-31 03:39:23 +0000 | [diff] [blame] | 107 | if (simd_support != ~0U) |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 108 | return; |
| 109 | |
| 110 | simd_support = 0; |
| 111 | |
DRC | 4346f91 | 2011-06-14 22:16:50 +0000 | [diff] [blame] | 112 | #if defined(__ARM_NEON__) |
| 113 | simd_support |= JSIMD_ARM_NEON; |
| 114 | #elif defined(__linux__) || defined(ANDROID) || defined(__ANDROID__) |
| 115 | /* We still have a chance to use NEON regardless of globally used |
| 116 | * -mcpu/-mfpu options passed to gcc by performing runtime detection via |
| 117 | * /proc/cpuinfo parsing on linux/android */ |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 118 | while (!parse_proc_cpuinfo(bufsize)) { |
| 119 | bufsize *= 2; |
| 120 | if (bufsize > SOMEWHAT_SANE_PROC_CPUINFO_SIZE_LIMIT) |
| 121 | break; |
| 122 | } |
| 123 | #endif |
| 124 | |
| 125 | /* Force different settings through environment variables */ |
DRC | 19eeaa7 | 2013-10-31 07:40:24 +0000 | [diff] [blame] | 126 | env = getenv("JSIMD_FORCENEON"); |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 127 | if ((env != NULL) && (strcmp(env, "1") == 0)) |
| 128 | simd_support &= JSIMD_ARM_NEON; |
DRC | 19eeaa7 | 2013-10-31 07:40:24 +0000 | [diff] [blame] | 129 | env = getenv("JSIMD_FORCENONE"); |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 130 | if ((env != NULL) && (strcmp(env, "1") == 0)) |
| 131 | simd_support = 0; |
DRC | e8aa5fa | 2016-01-15 13:15:54 -0600 | [diff] [blame] | 132 | env = getenv("JSIMD_NOHUFFENC"); |
| 133 | if ((env != NULL) && (strcmp(env, "1") == 0)) |
| 134 | simd_huffman = 0; |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 135 | } |
| 136 | |
| 137 | GLOBAL(int) |
| 138 | jsimd_can_rgb_ycc (void) |
| 139 | { |
| 140 | init_simd(); |
| 141 | |
DRC | 7a9376c | 2011-08-12 19:27:20 +0000 | [diff] [blame] | 142 | /* The code is optimised for these values only */ |
| 143 | if (BITS_IN_JSAMPLE != 8) |
| 144 | return 0; |
| 145 | if (sizeof(JDIMENSION) != 4) |
| 146 | return 0; |
| 147 | if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4)) |
| 148 | return 0; |
| 149 | |
| 150 | if (simd_support & JSIMD_ARM_NEON) |
| 151 | return 1; |
| 152 | |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 153 | return 0; |
| 154 | } |
| 155 | |
| 156 | GLOBAL(int) |
| 157 | jsimd_can_rgb_gray (void) |
| 158 | { |
| 159 | init_simd(); |
| 160 | |
| 161 | return 0; |
| 162 | } |
| 163 | |
| 164 | GLOBAL(int) |
| 165 | jsimd_can_ycc_rgb (void) |
| 166 | { |
| 167 | init_simd(); |
| 168 | |
| 169 | /* The code is optimised for these values only */ |
| 170 | if (BITS_IN_JSAMPLE != 8) |
| 171 | return 0; |
| 172 | if (sizeof(JDIMENSION) != 4) |
| 173 | return 0; |
| 174 | if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4)) |
| 175 | return 0; |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 176 | |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 177 | if (simd_support & JSIMD_ARM_NEON) |
| 178 | return 1; |
| 179 | |
| 180 | return 0; |
| 181 | } |
| 182 | |
DRC | d729f4d | 2014-08-23 15:47:51 +0000 | [diff] [blame] | 183 | GLOBAL(int) |
| 184 | jsimd_can_ycc_rgb565 (void) |
| 185 | { |
| 186 | init_simd(); |
| 187 | |
| 188 | /* The code is optimised for these values only */ |
| 189 | if (BITS_IN_JSAMPLE != 8) |
| 190 | return 0; |
| 191 | if (sizeof(JDIMENSION) != 4) |
| 192 | return 0; |
| 193 | |
| 194 | if (simd_support & JSIMD_ARM_NEON) |
| 195 | return 1; |
| 196 | |
| 197 | return 0; |
| 198 | } |
| 199 | |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 200 | GLOBAL(void) |
| 201 | jsimd_rgb_ycc_convert (j_compress_ptr cinfo, |
| 202 | JSAMPARRAY input_buf, JSAMPIMAGE output_buf, |
| 203 | JDIMENSION output_row, int num_rows) |
| 204 | { |
DRC | 7a9376c | 2011-08-12 19:27:20 +0000 | [diff] [blame] | 205 | void (*neonfct)(JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JDIMENSION, int); |
| 206 | |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 207 | switch(cinfo->in_color_space) { |
DRC | 7a9376c | 2011-08-12 19:27:20 +0000 | [diff] [blame] | 208 | case JCS_EXT_RGB: |
| 209 | neonfct=jsimd_extrgb_ycc_convert_neon; |
| 210 | break; |
| 211 | case JCS_EXT_RGBX: |
DRC | 67ce3b2 | 2011-12-19 02:21:03 +0000 | [diff] [blame] | 212 | case JCS_EXT_RGBA: |
DRC | 7a9376c | 2011-08-12 19:27:20 +0000 | [diff] [blame] | 213 | neonfct=jsimd_extrgbx_ycc_convert_neon; |
| 214 | break; |
| 215 | case JCS_EXT_BGR: |
| 216 | neonfct=jsimd_extbgr_ycc_convert_neon; |
| 217 | break; |
| 218 | case JCS_EXT_BGRX: |
DRC | 67ce3b2 | 2011-12-19 02:21:03 +0000 | [diff] [blame] | 219 | case JCS_EXT_BGRA: |
DRC | 7a9376c | 2011-08-12 19:27:20 +0000 | [diff] [blame] | 220 | neonfct=jsimd_extbgrx_ycc_convert_neon; |
| 221 | break; |
| 222 | case JCS_EXT_XBGR: |
DRC | 67ce3b2 | 2011-12-19 02:21:03 +0000 | [diff] [blame] | 223 | case JCS_EXT_ABGR: |
DRC | 7a9376c | 2011-08-12 19:27:20 +0000 | [diff] [blame] | 224 | neonfct=jsimd_extxbgr_ycc_convert_neon; |
| 225 | break; |
| 226 | case JCS_EXT_XRGB: |
DRC | 67ce3b2 | 2011-12-19 02:21:03 +0000 | [diff] [blame] | 227 | case JCS_EXT_ARGB: |
DRC | 7a9376c | 2011-08-12 19:27:20 +0000 | [diff] [blame] | 228 | neonfct=jsimd_extxrgb_ycc_convert_neon; |
| 229 | break; |
| 230 | default: |
| 231 | neonfct=jsimd_extrgb_ycc_convert_neon; |
| 232 | break; |
| 233 | } |
| 234 | |
DRC | 499c470 | 2016-01-13 03:13:20 -0600 | [diff] [blame] | 235 | neonfct(cinfo->image_width, input_buf, output_buf, output_row, num_rows); |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 236 | } |
| 237 | |
| 238 | GLOBAL(void) |
| 239 | jsimd_rgb_gray_convert (j_compress_ptr cinfo, |
| 240 | JSAMPARRAY input_buf, JSAMPIMAGE output_buf, |
| 241 | JDIMENSION output_row, int num_rows) |
| 242 | { |
| 243 | } |
| 244 | |
| 245 | GLOBAL(void) |
| 246 | jsimd_ycc_rgb_convert (j_decompress_ptr cinfo, |
| 247 | JSAMPIMAGE input_buf, JDIMENSION input_row, |
| 248 | JSAMPARRAY output_buf, int num_rows) |
| 249 | { |
| 250 | void (*neonfct)(JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY, int); |
| 251 | |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 252 | switch(cinfo->out_color_space) { |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 253 | case JCS_EXT_RGB: |
| 254 | neonfct=jsimd_ycc_extrgb_convert_neon; |
| 255 | break; |
| 256 | case JCS_EXT_RGBX: |
DRC | 67ce3b2 | 2011-12-19 02:21:03 +0000 | [diff] [blame] | 257 | case JCS_EXT_RGBA: |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 258 | neonfct=jsimd_ycc_extrgbx_convert_neon; |
| 259 | break; |
| 260 | case JCS_EXT_BGR: |
| 261 | neonfct=jsimd_ycc_extbgr_convert_neon; |
| 262 | break; |
| 263 | case JCS_EXT_BGRX: |
DRC | 67ce3b2 | 2011-12-19 02:21:03 +0000 | [diff] [blame] | 264 | case JCS_EXT_BGRA: |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 265 | neonfct=jsimd_ycc_extbgrx_convert_neon; |
| 266 | break; |
| 267 | case JCS_EXT_XBGR: |
DRC | 67ce3b2 | 2011-12-19 02:21:03 +0000 | [diff] [blame] | 268 | case JCS_EXT_ABGR: |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 269 | neonfct=jsimd_ycc_extxbgr_convert_neon; |
| 270 | break; |
| 271 | case JCS_EXT_XRGB: |
DRC | 67ce3b2 | 2011-12-19 02:21:03 +0000 | [diff] [blame] | 272 | case JCS_EXT_ARGB: |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 273 | neonfct=jsimd_ycc_extxrgb_convert_neon; |
| 274 | break; |
DRC | d729f4d | 2014-08-23 15:47:51 +0000 | [diff] [blame] | 275 | default: |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 276 | neonfct=jsimd_ycc_extrgb_convert_neon; |
| 277 | break; |
| 278 | } |
| 279 | |
DRC | 499c470 | 2016-01-13 03:13:20 -0600 | [diff] [blame] | 280 | neonfct(cinfo->output_width, input_buf, input_row, output_buf, num_rows); |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 281 | } |
| 282 | |
DRC | d729f4d | 2014-08-23 15:47:51 +0000 | [diff] [blame] | 283 | GLOBAL(void) |
| 284 | jsimd_ycc_rgb565_convert (j_decompress_ptr cinfo, |
| 285 | JSAMPIMAGE input_buf, JDIMENSION input_row, |
| 286 | JSAMPARRAY output_buf, int num_rows) |
| 287 | { |
DRC | 499c470 | 2016-01-13 03:13:20 -0600 | [diff] [blame] | 288 | jsimd_ycc_rgb565_convert_neon(cinfo->output_width, input_buf, input_row, |
| 289 | output_buf, num_rows); |
DRC | d729f4d | 2014-08-23 15:47:51 +0000 | [diff] [blame] | 290 | } |
| 291 | |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 292 | GLOBAL(int) |
| 293 | jsimd_can_h2v2_downsample (void) |
| 294 | { |
| 295 | init_simd(); |
| 296 | |
| 297 | return 0; |
| 298 | } |
| 299 | |
| 300 | GLOBAL(int) |
| 301 | jsimd_can_h2v1_downsample (void) |
| 302 | { |
| 303 | init_simd(); |
| 304 | |
| 305 | return 0; |
| 306 | } |
| 307 | |
| 308 | GLOBAL(void) |
DRC | bd49803 | 2016-02-19 08:53:33 -0600 | [diff] [blame] | 309 | jsimd_h2v2_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr, |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 310 | JSAMPARRAY input_data, JSAMPARRAY output_data) |
| 311 | { |
| 312 | } |
| 313 | |
| 314 | GLOBAL(void) |
DRC | bd49803 | 2016-02-19 08:53:33 -0600 | [diff] [blame] | 315 | jsimd_h2v1_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr, |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 316 | JSAMPARRAY input_data, JSAMPARRAY output_data) |
| 317 | { |
| 318 | } |
| 319 | |
| 320 | GLOBAL(int) |
| 321 | jsimd_can_h2v2_upsample (void) |
| 322 | { |
| 323 | init_simd(); |
| 324 | |
| 325 | return 0; |
| 326 | } |
| 327 | |
| 328 | GLOBAL(int) |
| 329 | jsimd_can_h2v1_upsample (void) |
| 330 | { |
| 331 | init_simd(); |
| 332 | |
| 333 | return 0; |
| 334 | } |
| 335 | |
| 336 | GLOBAL(void) |
| 337 | jsimd_h2v2_upsample (j_decompress_ptr cinfo, |
DRC | bd49803 | 2016-02-19 08:53:33 -0600 | [diff] [blame] | 338 | jpeg_component_info *compptr, |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 339 | JSAMPARRAY input_data, |
DRC | bd49803 | 2016-02-19 08:53:33 -0600 | [diff] [blame] | 340 | JSAMPARRAY *output_data_ptr) |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 341 | { |
| 342 | } |
| 343 | |
| 344 | GLOBAL(void) |
| 345 | jsimd_h2v1_upsample (j_decompress_ptr cinfo, |
DRC | bd49803 | 2016-02-19 08:53:33 -0600 | [diff] [blame] | 346 | jpeg_component_info *compptr, |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 347 | JSAMPARRAY input_data, |
DRC | bd49803 | 2016-02-19 08:53:33 -0600 | [diff] [blame] | 348 | JSAMPARRAY *output_data_ptr) |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 349 | { |
| 350 | } |
| 351 | |
| 352 | GLOBAL(int) |
| 353 | jsimd_can_h2v2_fancy_upsample (void) |
| 354 | { |
| 355 | init_simd(); |
| 356 | |
| 357 | return 0; |
| 358 | } |
| 359 | |
| 360 | GLOBAL(int) |
| 361 | jsimd_can_h2v1_fancy_upsample (void) |
| 362 | { |
| 363 | init_simd(); |
| 364 | |
DRC | 316617f | 2012-06-13 05:17:03 +0000 | [diff] [blame] | 365 | /* The code is optimised for these values only */ |
| 366 | if (BITS_IN_JSAMPLE != 8) |
| 367 | return 0; |
| 368 | if (sizeof(JDIMENSION) != 4) |
| 369 | return 0; |
| 370 | |
| 371 | if (simd_support & JSIMD_ARM_NEON) |
| 372 | return 1; |
| 373 | |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 374 | return 0; |
| 375 | } |
| 376 | |
| 377 | GLOBAL(void) |
| 378 | jsimd_h2v2_fancy_upsample (j_decompress_ptr cinfo, |
DRC | bd49803 | 2016-02-19 08:53:33 -0600 | [diff] [blame] | 379 | jpeg_component_info *compptr, |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 380 | JSAMPARRAY input_data, |
DRC | bd49803 | 2016-02-19 08:53:33 -0600 | [diff] [blame] | 381 | JSAMPARRAY *output_data_ptr) |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 382 | { |
| 383 | } |
| 384 | |
| 385 | GLOBAL(void) |
| 386 | jsimd_h2v1_fancy_upsample (j_decompress_ptr cinfo, |
DRC | bd49803 | 2016-02-19 08:53:33 -0600 | [diff] [blame] | 387 | jpeg_component_info *compptr, |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 388 | JSAMPARRAY input_data, |
DRC | bd49803 | 2016-02-19 08:53:33 -0600 | [diff] [blame] | 389 | JSAMPARRAY *output_data_ptr) |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 390 | { |
DRC | 499c470 | 2016-01-13 03:13:20 -0600 | [diff] [blame] | 391 | jsimd_h2v1_fancy_upsample_neon(cinfo->max_v_samp_factor, |
| 392 | compptr->downsampled_width, input_data, |
| 393 | output_data_ptr); |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 394 | } |
| 395 | |
| 396 | GLOBAL(int) |
| 397 | jsimd_can_h2v2_merged_upsample (void) |
| 398 | { |
| 399 | init_simd(); |
| 400 | |
| 401 | return 0; |
| 402 | } |
| 403 | |
| 404 | GLOBAL(int) |
| 405 | jsimd_can_h2v1_merged_upsample (void) |
| 406 | { |
| 407 | init_simd(); |
| 408 | |
| 409 | return 0; |
| 410 | } |
| 411 | |
| 412 | GLOBAL(void) |
| 413 | jsimd_h2v2_merged_upsample (j_decompress_ptr cinfo, |
| 414 | JSAMPIMAGE input_buf, |
| 415 | JDIMENSION in_row_group_ctr, |
| 416 | JSAMPARRAY output_buf) |
| 417 | { |
| 418 | } |
| 419 | |
| 420 | GLOBAL(void) |
| 421 | jsimd_h2v1_merged_upsample (j_decompress_ptr cinfo, |
| 422 | JSAMPIMAGE input_buf, |
| 423 | JDIMENSION in_row_group_ctr, |
| 424 | JSAMPARRAY output_buf) |
| 425 | { |
| 426 | } |
| 427 | |
| 428 | GLOBAL(int) |
| 429 | jsimd_can_convsamp (void) |
| 430 | { |
| 431 | init_simd(); |
| 432 | |
DRC | b740054 | 2011-08-10 23:31:13 +0000 | [diff] [blame] | 433 | /* The code is optimised for these values only */ |
| 434 | if (DCTSIZE != 8) |
| 435 | return 0; |
| 436 | if (BITS_IN_JSAMPLE != 8) |
| 437 | return 0; |
| 438 | if (sizeof(JDIMENSION) != 4) |
| 439 | return 0; |
| 440 | if (sizeof(DCTELEM) != 2) |
| 441 | return 0; |
| 442 | |
| 443 | if (simd_support & JSIMD_ARM_NEON) |
| 444 | return 1; |
| 445 | |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 446 | return 0; |
| 447 | } |
| 448 | |
| 449 | GLOBAL(int) |
| 450 | jsimd_can_convsamp_float (void) |
| 451 | { |
| 452 | init_simd(); |
| 453 | |
| 454 | return 0; |
| 455 | } |
| 456 | |
| 457 | GLOBAL(void) |
| 458 | jsimd_convsamp (JSAMPARRAY sample_data, JDIMENSION start_col, |
DRC | bd49803 | 2016-02-19 08:53:33 -0600 | [diff] [blame] | 459 | DCTELEM *workspace) |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 460 | { |
DRC | 499c470 | 2016-01-13 03:13:20 -0600 | [diff] [blame] | 461 | jsimd_convsamp_neon(sample_data, start_col, workspace); |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 462 | } |
| 463 | |
| 464 | GLOBAL(void) |
| 465 | jsimd_convsamp_float (JSAMPARRAY sample_data, JDIMENSION start_col, |
DRC | bd49803 | 2016-02-19 08:53:33 -0600 | [diff] [blame] | 466 | FAST_FLOAT *workspace) |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 467 | { |
| 468 | } |
| 469 | |
| 470 | GLOBAL(int) |
| 471 | jsimd_can_fdct_islow (void) |
| 472 | { |
| 473 | init_simd(); |
| 474 | |
| 475 | return 0; |
| 476 | } |
| 477 | |
| 478 | GLOBAL(int) |
| 479 | jsimd_can_fdct_ifast (void) |
| 480 | { |
| 481 | init_simd(); |
| 482 | |
DRC | b740054 | 2011-08-10 23:31:13 +0000 | [diff] [blame] | 483 | /* The code is optimised for these values only */ |
| 484 | if (DCTSIZE != 8) |
| 485 | return 0; |
| 486 | if (sizeof(DCTELEM) != 2) |
| 487 | return 0; |
| 488 | |
| 489 | if (simd_support & JSIMD_ARM_NEON) |
| 490 | return 1; |
| 491 | |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 492 | return 0; |
| 493 | } |
| 494 | |
| 495 | GLOBAL(int) |
| 496 | jsimd_can_fdct_float (void) |
| 497 | { |
| 498 | init_simd(); |
| 499 | |
| 500 | return 0; |
| 501 | } |
| 502 | |
| 503 | GLOBAL(void) |
DRC | bd49803 | 2016-02-19 08:53:33 -0600 | [diff] [blame] | 504 | jsimd_fdct_islow (DCTELEM *data) |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 505 | { |
| 506 | } |
| 507 | |
| 508 | GLOBAL(void) |
DRC | bd49803 | 2016-02-19 08:53:33 -0600 | [diff] [blame] | 509 | jsimd_fdct_ifast (DCTELEM *data) |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 510 | { |
DRC | 499c470 | 2016-01-13 03:13:20 -0600 | [diff] [blame] | 511 | jsimd_fdct_ifast_neon(data); |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 512 | } |
| 513 | |
| 514 | GLOBAL(void) |
DRC | bd49803 | 2016-02-19 08:53:33 -0600 | [diff] [blame] | 515 | jsimd_fdct_float (FAST_FLOAT *data) |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 516 | { |
| 517 | } |
| 518 | |
| 519 | GLOBAL(int) |
| 520 | jsimd_can_quantize (void) |
| 521 | { |
| 522 | init_simd(); |
| 523 | |
DRC | 82bd521 | 2011-08-17 21:00:59 +0000 | [diff] [blame] | 524 | /* The code is optimised for these values only */ |
| 525 | if (DCTSIZE != 8) |
| 526 | return 0; |
| 527 | if (sizeof(JCOEF) != 2) |
| 528 | return 0; |
| 529 | if (sizeof(DCTELEM) != 2) |
| 530 | return 0; |
| 531 | |
| 532 | if (simd_support & JSIMD_ARM_NEON) |
| 533 | return 1; |
| 534 | |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 535 | return 0; |
| 536 | } |
| 537 | |
| 538 | GLOBAL(int) |
| 539 | jsimd_can_quantize_float (void) |
| 540 | { |
| 541 | init_simd(); |
| 542 | |
| 543 | return 0; |
| 544 | } |
| 545 | |
| 546 | GLOBAL(void) |
DRC | bd49803 | 2016-02-19 08:53:33 -0600 | [diff] [blame] | 547 | jsimd_quantize (JCOEFPTR coef_block, DCTELEM *divisors, |
| 548 | DCTELEM *workspace) |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 549 | { |
DRC | 499c470 | 2016-01-13 03:13:20 -0600 | [diff] [blame] | 550 | jsimd_quantize_neon(coef_block, divisors, workspace); |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 551 | } |
| 552 | |
| 553 | GLOBAL(void) |
DRC | bd49803 | 2016-02-19 08:53:33 -0600 | [diff] [blame] | 554 | jsimd_quantize_float (JCOEFPTR coef_block, FAST_FLOAT *divisors, |
| 555 | FAST_FLOAT *workspace) |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 556 | { |
| 557 | } |
| 558 | |
| 559 | GLOBAL(int) |
| 560 | jsimd_can_idct_2x2 (void) |
| 561 | { |
| 562 | init_simd(); |
| 563 | |
DRC | 8c60d22 | 2011-06-17 21:12:58 +0000 | [diff] [blame] | 564 | /* The code is optimised for these values only */ |
| 565 | if (DCTSIZE != 8) |
| 566 | return 0; |
| 567 | if (sizeof(JCOEF) != 2) |
| 568 | return 0; |
| 569 | if (BITS_IN_JSAMPLE != 8) |
| 570 | return 0; |
| 571 | if (sizeof(JDIMENSION) != 4) |
| 572 | return 0; |
| 573 | if (sizeof(ISLOW_MULT_TYPE) != 2) |
| 574 | return 0; |
| 575 | |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 576 | if (simd_support & JSIMD_ARM_NEON) |
DRC | 8c60d22 | 2011-06-17 21:12:58 +0000 | [diff] [blame] | 577 | return 1; |
| 578 | |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 579 | return 0; |
| 580 | } |
| 581 | |
| 582 | GLOBAL(int) |
| 583 | jsimd_can_idct_4x4 (void) |
| 584 | { |
| 585 | init_simd(); |
| 586 | |
DRC | 8c60d22 | 2011-06-17 21:12:58 +0000 | [diff] [blame] | 587 | /* The code is optimised for these values only */ |
| 588 | if (DCTSIZE != 8) |
| 589 | return 0; |
| 590 | if (sizeof(JCOEF) != 2) |
| 591 | return 0; |
| 592 | if (BITS_IN_JSAMPLE != 8) |
| 593 | return 0; |
| 594 | if (sizeof(JDIMENSION) != 4) |
| 595 | return 0; |
| 596 | if (sizeof(ISLOW_MULT_TYPE) != 2) |
| 597 | return 0; |
| 598 | |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 599 | if (simd_support & JSIMD_ARM_NEON) |
DRC | 8c60d22 | 2011-06-17 21:12:58 +0000 | [diff] [blame] | 600 | return 1; |
| 601 | |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 602 | return 0; |
| 603 | } |
| 604 | |
| 605 | GLOBAL(void) |
DRC | bd49803 | 2016-02-19 08:53:33 -0600 | [diff] [blame] | 606 | jsimd_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info *compptr, |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 607 | JCOEFPTR coef_block, JSAMPARRAY output_buf, |
| 608 | JDIMENSION output_col) |
| 609 | { |
DRC | 499c470 | 2016-01-13 03:13:20 -0600 | [diff] [blame] | 610 | jsimd_idct_2x2_neon(compptr->dct_table, coef_block, output_buf, |
| 611 | output_col); |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 612 | } |
| 613 | |
| 614 | GLOBAL(void) |
DRC | bd49803 | 2016-02-19 08:53:33 -0600 | [diff] [blame] | 615 | jsimd_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info *compptr, |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 616 | JCOEFPTR coef_block, JSAMPARRAY output_buf, |
| 617 | JDIMENSION output_col) |
| 618 | { |
DRC | 499c470 | 2016-01-13 03:13:20 -0600 | [diff] [blame] | 619 | jsimd_idct_4x4_neon(compptr->dct_table, coef_block, output_buf, |
| 620 | output_col); |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 621 | } |
| 622 | |
| 623 | GLOBAL(int) |
| 624 | jsimd_can_idct_islow (void) |
| 625 | { |
| 626 | init_simd(); |
| 627 | |
DRC | ce4e3e8 | 2011-08-22 13:48:01 +0000 | [diff] [blame] | 628 | /* The code is optimised for these values only */ |
| 629 | if (DCTSIZE != 8) |
| 630 | return 0; |
| 631 | if (sizeof(JCOEF) != 2) |
| 632 | return 0; |
| 633 | if (BITS_IN_JSAMPLE != 8) |
| 634 | return 0; |
| 635 | if (sizeof(JDIMENSION) != 4) |
| 636 | return 0; |
| 637 | if (sizeof(ISLOW_MULT_TYPE) != 2) |
| 638 | return 0; |
| 639 | |
| 640 | if (simd_support & JSIMD_ARM_NEON) |
| 641 | return 1; |
| 642 | |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 643 | return 0; |
| 644 | } |
| 645 | |
| 646 | GLOBAL(int) |
| 647 | jsimd_can_idct_ifast (void) |
| 648 | { |
| 649 | init_simd(); |
| 650 | |
| 651 | /* The code is optimised for these values only */ |
| 652 | if (DCTSIZE != 8) |
| 653 | return 0; |
| 654 | if (sizeof(JCOEF) != 2) |
| 655 | return 0; |
| 656 | if (BITS_IN_JSAMPLE != 8) |
| 657 | return 0; |
| 658 | if (sizeof(JDIMENSION) != 4) |
| 659 | return 0; |
| 660 | if (sizeof(IFAST_MULT_TYPE) != 2) |
| 661 | return 0; |
| 662 | if (IFAST_SCALE_BITS != 2) |
| 663 | return 0; |
| 664 | |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 665 | if (simd_support & JSIMD_ARM_NEON) |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 666 | return 1; |
| 667 | |
| 668 | return 0; |
| 669 | } |
| 670 | |
| 671 | GLOBAL(int) |
| 672 | jsimd_can_idct_float (void) |
| 673 | { |
| 674 | init_simd(); |
| 675 | |
| 676 | return 0; |
| 677 | } |
| 678 | |
| 679 | GLOBAL(void) |
DRC | bd49803 | 2016-02-19 08:53:33 -0600 | [diff] [blame] | 680 | jsimd_idct_islow (j_decompress_ptr cinfo, jpeg_component_info *compptr, |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 681 | JCOEFPTR coef_block, JSAMPARRAY output_buf, |
| 682 | JDIMENSION output_col) |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 683 | { |
DRC | 499c470 | 2016-01-13 03:13:20 -0600 | [diff] [blame] | 684 | jsimd_idct_islow_neon(compptr->dct_table, coef_block, output_buf, |
| 685 | output_col); |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 686 | } |
| 687 | |
| 688 | GLOBAL(void) |
DRC | bd49803 | 2016-02-19 08:53:33 -0600 | [diff] [blame] | 689 | jsimd_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info *compptr, |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 690 | JCOEFPTR coef_block, JSAMPARRAY output_buf, |
| 691 | JDIMENSION output_col) |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 692 | { |
DRC | 499c470 | 2016-01-13 03:13:20 -0600 | [diff] [blame] | 693 | jsimd_idct_ifast_neon(compptr->dct_table, coef_block, output_buf, |
| 694 | output_col); |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 695 | } |
| 696 | |
| 697 | GLOBAL(void) |
DRC | bd49803 | 2016-02-19 08:53:33 -0600 | [diff] [blame] | 698 | jsimd_idct_float (j_decompress_ptr cinfo, jpeg_component_info *compptr, |
DRC | 1419852 | 2014-05-15 19:45:11 +0000 | [diff] [blame] | 699 | JCOEFPTR coef_block, JSAMPARRAY output_buf, |
| 700 | JDIMENSION output_col) |
DRC | 321e068 | 2011-05-03 08:47:43 +0000 | [diff] [blame] | 701 | { |
| 702 | } |
DRC | f3a8684 | 2016-01-07 00:19:43 -0600 | [diff] [blame] | 703 | |
| 704 | GLOBAL(int) |
| 705 | jsimd_can_huff_encode_one_block (void) |
| 706 | { |
DRC | 499c470 | 2016-01-13 03:13:20 -0600 | [diff] [blame] | 707 | init_simd(); |
| 708 | |
| 709 | if (DCTSIZE != 8) |
| 710 | return 0; |
| 711 | if (sizeof(JCOEF) != 2) |
| 712 | return 0; |
| 713 | |
DRC | e8aa5fa | 2016-01-15 13:15:54 -0600 | [diff] [blame] | 714 | if (simd_support & JSIMD_ARM_NEON && simd_huffman) |
DRC | 499c470 | 2016-01-13 03:13:20 -0600 | [diff] [blame] | 715 | return 1; |
| 716 | |
DRC | f3a8684 | 2016-01-07 00:19:43 -0600 | [diff] [blame] | 717 | return 0; |
| 718 | } |
| 719 | |
| 720 | GLOBAL(JOCTET*) |
DRC | bd49803 | 2016-02-19 08:53:33 -0600 | [diff] [blame] | 721 | jsimd_huff_encode_one_block (void *state, JOCTET *buffer, JCOEFPTR block, |
DRC | f3a8684 | 2016-01-07 00:19:43 -0600 | [diff] [blame] | 722 | int last_dc_val, c_derived_tbl *dctbl, |
| 723 | c_derived_tbl *actbl) |
| 724 | { |
DRC | 499c470 | 2016-01-13 03:13:20 -0600 | [diff] [blame] | 725 | return jsimd_huff_encode_one_block_neon(state, buffer, block, last_dc_val, |
| 726 | dctbl, actbl); |
DRC | f3a8684 | 2016-01-07 00:19:43 -0600 | [diff] [blame] | 727 | } |