Index: simd/jsimd_arm.c |
diff --git a/simd/jsimd_arm.c b/simd/jsimd_arm.c |
index 72fa1fc4ce21c6a2d3d32d3ae844e3d598fedfdb..197eb61dc3aa919f65dd083ff3217cc740fd74e1 100644 |
--- a/simd/jsimd_arm.c |
+++ b/simd/jsimd_arm.c |
@@ -2,17 +2,16 @@ |
* jsimd_arm.c |
* |
* Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB |
- * Copyright 2009-2011, 2013-2014D. R. Commander |
+ * Copyright 2009-2011, 2013-2014, 2016 D. R. Commander |
+ * Copyright 2015-2016 Matthieu Darbois |
* |
* Based on the x86 SIMD extension for IJG JPEG library, |
* Copyright (C) 1999-2006, MIYASAKA Masaru. |
* For conditions of distribution and use, see copyright notice in jsimdext.inc |
* |
* This file contains the interface between the "normal" portions |
- * of the library and the SIMD implementations when running on |
- * ARM architecture. |
- * |
- * Based on the stubs from 'jsimd_none.c' |
+ * of the library and the SIMD implementations when running on a |
+ * 32-bit ARM architecture. |
*/ |
#define JPEG_INTERNALS |
@@ -28,6 +27,7 @@ |
#include <ctype.h> |
static unsigned int simd_support = ~0; |
+static unsigned int simd_huffman = 1; |
#if !defined(__ARM_NEON__) && (defined(__linux__) || defined(ANDROID) || defined(__ANDROID__)) |
@@ -123,12 +123,15 @@ init_simd (void) |
#endif |
/* Force different settings through environment variables */ |
- env = getenv("JSIMD_FORCE_ARM_NEON"); |
+ env = getenv("JSIMD_FORCENEON"); |
if ((env != NULL) && (strcmp(env, "1") == 0)) |
simd_support &= JSIMD_ARM_NEON; |
- env = getenv("JSIMD_FORCE_NO_SIMD"); |
+ env = getenv("JSIMD_FORCENONE"); |
if ((env != NULL) && (strcmp(env, "1") == 0)) |
simd_support = 0; |
+ env = getenv("JSIMD_NOHUFFENC"); |
+ if ((env != NULL) && (strcmp(env, "1") == 0)) |
+ simd_huffman = 0; |
} |
GLOBAL(int) |
@@ -170,6 +173,7 @@ jsimd_can_ycc_rgb (void) |
return 0; |
if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4)) |
return 0; |
+ |
if (simd_support & JSIMD_ARM_NEON) |
return 1; |
@@ -200,8 +204,7 @@ jsimd_rgb_ycc_convert (j_compress_ptr cinfo, |
{ |
void (*neonfct)(JDIMENSION, JSAMPARRAY, JSAMPIMAGE, JDIMENSION, int); |
- switch(cinfo->in_color_space) |
- { |
+ switch(cinfo->in_color_space) { |
case JCS_EXT_RGB: |
neonfct=jsimd_extrgb_ycc_convert_neon; |
break; |
@@ -229,9 +232,7 @@ jsimd_rgb_ycc_convert (j_compress_ptr cinfo, |
break; |
} |
- if (simd_support & JSIMD_ARM_NEON) |
- neonfct(cinfo->image_width, input_buf, |
- output_buf, output_row, num_rows); |
+ neonfct(cinfo->image_width, input_buf, output_buf, output_row, num_rows); |
} |
GLOBAL(void) |
@@ -248,8 +249,7 @@ jsimd_ycc_rgb_convert (j_decompress_ptr cinfo, |
{ |
void (*neonfct)(JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY, int); |
- switch(cinfo->out_color_space) |
- { |
+ switch(cinfo->out_color_space) { |
case JCS_EXT_RGB: |
neonfct=jsimd_ycc_extrgb_convert_neon; |
break; |
@@ -277,9 +277,7 @@ jsimd_ycc_rgb_convert (j_decompress_ptr cinfo, |
break; |
} |
- if (simd_support & JSIMD_ARM_NEON) |
- neonfct(cinfo->output_width, input_buf, |
- input_row, output_buf, num_rows); |
+ neonfct(cinfo->output_width, input_buf, input_row, output_buf, num_rows); |
} |
GLOBAL(void) |
@@ -287,9 +285,8 @@ jsimd_ycc_rgb565_convert (j_decompress_ptr cinfo, |
JSAMPIMAGE input_buf, JDIMENSION input_row, |
JSAMPARRAY output_buf, int num_rows) |
{ |
- if (simd_support & JSIMD_ARM_NEON) |
- jsimd_ycc_rgb565_convert_neon(cinfo->output_width, input_buf, input_row, |
- output_buf, num_rows); |
+ jsimd_ycc_rgb565_convert_neon(cinfo->output_width, input_buf, input_row, |
+ output_buf, num_rows); |
} |
GLOBAL(int) |
@@ -309,13 +306,13 @@ jsimd_can_h2v1_downsample (void) |
} |
GLOBAL(void) |
-jsimd_h2v2_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, |
+jsimd_h2v2_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr, |
JSAMPARRAY input_data, JSAMPARRAY output_data) |
{ |
} |
GLOBAL(void) |
-jsimd_h2v1_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, |
+jsimd_h2v1_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr, |
JSAMPARRAY input_data, JSAMPARRAY output_data) |
{ |
} |
@@ -338,17 +335,17 @@ jsimd_can_h2v1_upsample (void) |
GLOBAL(void) |
jsimd_h2v2_upsample (j_decompress_ptr cinfo, |
- jpeg_component_info * compptr, |
+ jpeg_component_info *compptr, |
JSAMPARRAY input_data, |
- JSAMPARRAY * output_data_ptr) |
+ JSAMPARRAY *output_data_ptr) |
{ |
} |
GLOBAL(void) |
jsimd_h2v1_upsample (j_decompress_ptr cinfo, |
- jpeg_component_info * compptr, |
+ jpeg_component_info *compptr, |
JSAMPARRAY input_data, |
- JSAMPARRAY * output_data_ptr) |
+ JSAMPARRAY *output_data_ptr) |
{ |
} |
@@ -379,21 +376,21 @@ jsimd_can_h2v1_fancy_upsample (void) |
GLOBAL(void) |
jsimd_h2v2_fancy_upsample (j_decompress_ptr cinfo, |
- jpeg_component_info * compptr, |
+ jpeg_component_info *compptr, |
JSAMPARRAY input_data, |
- JSAMPARRAY * output_data_ptr) |
+ JSAMPARRAY *output_data_ptr) |
{ |
} |
GLOBAL(void) |
jsimd_h2v1_fancy_upsample (j_decompress_ptr cinfo, |
- jpeg_component_info * compptr, |
+ jpeg_component_info *compptr, |
JSAMPARRAY input_data, |
- JSAMPARRAY * output_data_ptr) |
+ JSAMPARRAY *output_data_ptr) |
{ |
- if (simd_support & JSIMD_ARM_NEON) |
- jsimd_h2v1_fancy_upsample_neon(cinfo->max_v_samp_factor, |
- compptr->downsampled_width, input_data, output_data_ptr); |
+ jsimd_h2v1_fancy_upsample_neon(cinfo->max_v_samp_factor, |
+ compptr->downsampled_width, input_data, |
+ output_data_ptr); |
} |
GLOBAL(int) |
@@ -459,15 +456,14 @@ jsimd_can_convsamp_float (void) |
GLOBAL(void) |
jsimd_convsamp (JSAMPARRAY sample_data, JDIMENSION start_col, |
- DCTELEM * workspace) |
+ DCTELEM *workspace) |
{ |
- if (simd_support & JSIMD_ARM_NEON) |
- jsimd_convsamp_neon(sample_data, start_col, workspace); |
+ jsimd_convsamp_neon(sample_data, start_col, workspace); |
} |
GLOBAL(void) |
jsimd_convsamp_float (JSAMPARRAY sample_data, JDIMENSION start_col, |
- FAST_FLOAT * workspace) |
+ FAST_FLOAT *workspace) |
{ |
} |
@@ -505,19 +501,18 @@ jsimd_can_fdct_float (void) |
} |
GLOBAL(void) |
-jsimd_fdct_islow (DCTELEM * data) |
+jsimd_fdct_islow (DCTELEM *data) |
{ |
} |
GLOBAL(void) |
-jsimd_fdct_ifast (DCTELEM * data) |
+jsimd_fdct_ifast (DCTELEM *data) |
{ |
- if (simd_support & JSIMD_ARM_NEON) |
- jsimd_fdct_ifast_neon(data); |
+ jsimd_fdct_ifast_neon(data); |
} |
GLOBAL(void) |
-jsimd_fdct_float (FAST_FLOAT * data) |
+jsimd_fdct_float (FAST_FLOAT *data) |
{ |
} |
@@ -549,16 +544,15 @@ jsimd_can_quantize_float (void) |
} |
GLOBAL(void) |
-jsimd_quantize (JCOEFPTR coef_block, DCTELEM * divisors, |
- DCTELEM * workspace) |
+jsimd_quantize (JCOEFPTR coef_block, DCTELEM *divisors, |
+ DCTELEM *workspace) |
{ |
- if (simd_support & JSIMD_ARM_NEON) |
- jsimd_quantize_neon(coef_block, divisors, workspace); |
+ jsimd_quantize_neon(coef_block, divisors, workspace); |
} |
GLOBAL(void) |
-jsimd_quantize_float (JCOEFPTR coef_block, FAST_FLOAT * divisors, |
- FAST_FLOAT * workspace) |
+jsimd_quantize_float (JCOEFPTR coef_block, FAST_FLOAT *divisors, |
+ FAST_FLOAT *workspace) |
{ |
} |
@@ -579,7 +573,7 @@ jsimd_can_idct_2x2 (void) |
if (sizeof(ISLOW_MULT_TYPE) != 2) |
return 0; |
- if ((simd_support & JSIMD_ARM_NEON)) |
+ if (simd_support & JSIMD_ARM_NEON) |
return 1; |
return 0; |
@@ -602,28 +596,28 @@ jsimd_can_idct_4x4 (void) |
if (sizeof(ISLOW_MULT_TYPE) != 2) |
return 0; |
- if ((simd_support & JSIMD_ARM_NEON)) |
+ if (simd_support & JSIMD_ARM_NEON) |
return 1; |
return 0; |
} |
GLOBAL(void) |
-jsimd_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
+jsimd_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info *compptr, |
JCOEFPTR coef_block, JSAMPARRAY output_buf, |
JDIMENSION output_col) |
{ |
- if ((simd_support & JSIMD_ARM_NEON)) |
- jsimd_idct_2x2_neon(compptr->dct_table, coef_block, output_buf, output_col); |
+ jsimd_idct_2x2_neon(compptr->dct_table, coef_block, output_buf, |
+ output_col); |
} |
GLOBAL(void) |
-jsimd_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
+jsimd_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info *compptr, |
JCOEFPTR coef_block, JSAMPARRAY output_buf, |
JDIMENSION output_col) |
{ |
- if ((simd_support & JSIMD_ARM_NEON)) |
- jsimd_idct_4x4_neon(compptr->dct_table, coef_block, output_buf, output_col); |
+ jsimd_idct_4x4_neon(compptr->dct_table, coef_block, output_buf, |
+ output_col); |
} |
GLOBAL(int) |
@@ -668,7 +662,7 @@ jsimd_can_idct_ifast (void) |
if (IFAST_SCALE_BITS != 2) |
return 0; |
- if ((simd_support & JSIMD_ARM_NEON)) |
+ if (simd_support & JSIMD_ARM_NEON) |
return 1; |
return 0; |
@@ -683,27 +677,51 @@ jsimd_can_idct_float (void) |
} |
GLOBAL(void) |
-jsimd_idct_islow (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
- JCOEFPTR coef_block, JSAMPARRAY output_buf, |
- JDIMENSION output_col) |
+jsimd_idct_islow (j_decompress_ptr cinfo, jpeg_component_info *compptr, |
+ JCOEFPTR coef_block, JSAMPARRAY output_buf, |
+ JDIMENSION output_col) |
{ |
- if ((simd_support & JSIMD_ARM_NEON)) |
- jsimd_idct_islow_neon(compptr->dct_table, coef_block, output_buf, output_col); |
+ jsimd_idct_islow_neon(compptr->dct_table, coef_block, output_buf, |
+ output_col); |
} |
GLOBAL(void) |
-jsimd_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
- JCOEFPTR coef_block, JSAMPARRAY output_buf, |
- JDIMENSION output_col) |
+jsimd_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info *compptr, |
+ JCOEFPTR coef_block, JSAMPARRAY output_buf, |
+ JDIMENSION output_col) |
{ |
- if ((simd_support & JSIMD_ARM_NEON)) |
- jsimd_idct_ifast_neon(compptr->dct_table, coef_block, output_buf, output_col); |
+ jsimd_idct_ifast_neon(compptr->dct_table, coef_block, output_buf, |
+ output_col); |
} |
GLOBAL(void) |
-jsimd_idct_float (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
- JCOEFPTR coef_block, JSAMPARRAY output_buf, |
- JDIMENSION output_col) |
+jsimd_idct_float (j_decompress_ptr cinfo, jpeg_component_info *compptr, |
+ JCOEFPTR coef_block, JSAMPARRAY output_buf, |
+ JDIMENSION output_col) |
{ |
} |
+GLOBAL(int) |
+jsimd_can_huff_encode_one_block (void) |
+{ |
+ init_simd(); |
+ |
+ if (DCTSIZE != 8) |
+ return 0; |
+ if (sizeof(JCOEF) != 2) |
+ return 0; |
+ |
+ if (simd_support & JSIMD_ARM_NEON && simd_huffman) |
+ return 1; |
+ |
+ return 0; |
+} |
+ |
+GLOBAL(JOCTET*) |
+jsimd_huff_encode_one_block (void *state, JOCTET *buffer, JCOEFPTR block, |
+ int last_dc_val, c_derived_tbl *dctbl, |
+ c_derived_tbl *actbl) |
+{ |
+ return jsimd_huff_encode_one_block_neon(state, buffer, block, last_dc_val, |
+ dctbl, actbl); |
+} |