1 /* Copyright (c) 2011, NVIDIA CORPORATION. All rights reserved.
2 *
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions
5 * are met:
6 *
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the NVIDIA CORPORATION nor the names of its
13 * contributors may be used to endorse or promote products derived
14 * from this software without specific prior written permission.
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
25 * THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28 #define JPEG_INTERNALS
29 #include "jinclude.h"
30 #include "jpeglib.h"
31 #include "jdct.h"
32
33
34 #if defined(NV_ARM_NEON) && defined(__ARM_HAVE_NEON)
35
36 EXTERN(void) jsimd_ycc_rgba8888_convert_neon
37 JPP((JDIMENSION out_width,
38 JSAMPIMAGE input_buf, JDIMENSION input_row,
39 JSAMPARRAY output_buf, int num_rows));
40 EXTERN(void) jsimd_ycc_rgb565_convert_neon
41 JPP((JDIMENSION out_width,
42 JSAMPIMAGE input_buf, JDIMENSION input_row,
43 JSAMPARRAY output_buf, int num_rows));
44
45 EXTERN(void) jsimd_idct_ifast_neon JPP((void * dct_table,
46 JCOEFPTR coef_block,
47 JSAMPARRAY output_buf,
48 JDIMENSION output_col));
49
50 EXTERN(void) jsimd_idct_2x2_neon JPP((void * dct_table,
51 JCOEFPTR coef_block,
52 JSAMPARRAY output_buf,
53 JDIMENSION output_col));
54
55 EXTERN(void) jsimd_idct_4x4_neon JPP((void * dct_table,
56 JCOEFPTR coef_block,
57 JSAMPARRAY output_buf,
58 JDIMENSION output_col));
59
60 GLOBAL(void)
jsimd_ycc_rgba8888_convert(j_decompress_ptr cinfo,JSAMPIMAGE input_buf,JDIMENSION input_row,JSAMPARRAY output_buf,int num_rows)61 jsimd_ycc_rgba8888_convert (j_decompress_ptr cinfo,
62 JSAMPIMAGE input_buf, JDIMENSION input_row,
63 JSAMPARRAY output_buf, int num_rows)
64 {
65 void (*neonfct)(JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY, int);
66
67 neonfct=jsimd_ycc_rgba8888_convert_neon;
68
69 neonfct(cinfo->output_width, input_buf,
70 input_row, output_buf, num_rows);
71 }
72
73 GLOBAL(void)
jsimd_ycc_rgb565_convert(j_decompress_ptr cinfo,JSAMPIMAGE input_buf,JDIMENSION input_row,JSAMPARRAY output_buf,int num_rows)74 jsimd_ycc_rgb565_convert (j_decompress_ptr cinfo,
75 JSAMPIMAGE input_buf, JDIMENSION input_row,
76 JSAMPARRAY output_buf, int num_rows)
77 {
78 void (*neonfct)(JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY, int);
79
80 neonfct=jsimd_ycc_rgb565_convert_neon;
81
82 neonfct(cinfo->output_width, input_buf,
83 input_row, output_buf, num_rows);
84 }
85
86 GLOBAL(void)
jsimd_idct_ifast(j_decompress_ptr cinfo,jpeg_component_info * compptr,JCOEFPTR coef_block,JSAMPARRAY output_buf,JDIMENSION output_col)87 jsimd_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr,
88 JCOEFPTR coef_block, JSAMPARRAY output_buf,
89 JDIMENSION output_col)
90 {
91 jsimd_idct_ifast_neon(compptr->dct_table, coef_block, output_buf, output_col);
92 }
93
94
95 GLOBAL(void)
jsimd_idct_2x2(j_decompress_ptr cinfo,jpeg_component_info * compptr,JCOEFPTR coef_block,JSAMPARRAY output_buf,JDIMENSION output_col)96 jsimd_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
97 JCOEFPTR coef_block, JSAMPARRAY output_buf,
98 JDIMENSION output_col)
99 {
100 jsimd_idct_2x2_neon(compptr->dct_table, coef_block, output_buf, output_col);
101 }
102
103 GLOBAL(void)
jsimd_idct_4x4(j_decompress_ptr cinfo,jpeg_component_info * compptr,JCOEFPTR coef_block,JSAMPARRAY output_buf,JDIMENSION output_col)104 jsimd_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
105 JCOEFPTR coef_block, JSAMPARRAY output_buf,
106 JDIMENSION output_col)
107 {
108 jsimd_idct_4x4_neon(compptr->dct_table, coef_block, output_buf, output_col);
109 }
110
111
112 GLOBAL(int)
cap_neon_idct_2x2(void)113 cap_neon_idct_2x2 (void)
114 {
115 if ( (DCTSIZE != 8) ||
116 (sizeof(JCOEF) != 2) ||
117 (BITS_IN_JSAMPLE != 8) ||
118 (sizeof(JDIMENSION) != 4) ||
119 (sizeof(ISLOW_MULT_TYPE) != 2))
120 return 0;
121
122 return 1;
123 }
124
125 GLOBAL(int)
cap_neon_idct_4x4(void)126 cap_neon_idct_4x4 (void)
127 {
128
129 if ( (DCTSIZE != 8) ||
130 (sizeof(JCOEF) != 2) ||
131 (BITS_IN_JSAMPLE != 8) ||
132 (sizeof(JDIMENSION) != 4) ||
133 (sizeof(ISLOW_MULT_TYPE) != 2))
134 return 0;
135
136 return 1;
137 }
138
139 GLOBAL(int)
cap_neon_idct_ifast(void)140 cap_neon_idct_ifast (void)
141 {
142
143 if ( (DCTSIZE != 8) ||
144 (sizeof(JCOEF) != 2) ||
145 (BITS_IN_JSAMPLE != 8) ||
146 (sizeof(JDIMENSION) != 4) ||
147 (sizeof(IFAST_MULT_TYPE) != 2) ||
148 (IFAST_SCALE_BITS != 2))
149 return 0;
150
151 return 1;
152
153 }
154
155 GLOBAL(int)
cap_neon_ycc_rgb(void)156 cap_neon_ycc_rgb (void)
157 {
158
159 if( (BITS_IN_JSAMPLE != 8) ||
160 (sizeof(JDIMENSION) != 4) ||
161 ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4)))
162 return 0;
163
164 return 1;
165 }
166
167 #endif
168
169
170