blob: 6ad1bd36f363740e7cae6ecdda3f30d338f87e1f [file] [log] [blame]
Prajakta Gudadhe6a3be8d2012-06-11 14:08:27 -07001/* 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#include <machine/cpu-features.h>
33
34
35#if defined(NV_ARM_NEON) && defined(__ARM_HAVE_NEON)
36
37EXTERN(void) jsimd_ycc_rgba8888_convert_neon
38 JPP((JDIMENSION out_width,
39 JSAMPIMAGE input_buf, JDIMENSION input_row,
40 JSAMPARRAY output_buf, int num_rows));
41EXTERN(void) jsimd_ycc_rgb565_convert_neon
42 JPP((JDIMENSION out_width,
43 JSAMPIMAGE input_buf, JDIMENSION input_row,
44 JSAMPARRAY output_buf, int num_rows));
45
46EXTERN(void) jsimd_idct_ifast_neon JPP((void * dct_table,
47 JCOEFPTR coef_block,
48 JSAMPARRAY output_buf,
49 JDIMENSION output_col));
50
51EXTERN(void) jsimd_idct_2x2_neon JPP((void * dct_table,
52 JCOEFPTR coef_block,
53 JSAMPARRAY output_buf,
54 JDIMENSION output_col));
55
56EXTERN(void) jsimd_idct_4x4_neon JPP((void * dct_table,
57 JCOEFPTR coef_block,
58 JSAMPARRAY output_buf,
59 JDIMENSION output_col));
60
61GLOBAL(void)
62jsimd_ycc_rgba8888_convert (j_decompress_ptr cinfo,
63 JSAMPIMAGE input_buf, JDIMENSION input_row,
64 JSAMPARRAY output_buf, int num_rows)
65{
66 void (*neonfct)(JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY, int);
67
68 neonfct=jsimd_ycc_rgba8888_convert_neon;
69
70 neonfct(cinfo->output_width, input_buf,
71 input_row, output_buf, num_rows);
72}
73
74GLOBAL(void)
75jsimd_ycc_rgb565_convert (j_decompress_ptr cinfo,
76 JSAMPIMAGE input_buf, JDIMENSION input_row,
77 JSAMPARRAY output_buf, int num_rows)
78{
79 void (*neonfct)(JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY, int);
80
81 neonfct=jsimd_ycc_rgb565_convert_neon;
82
83 neonfct(cinfo->output_width, input_buf,
84 input_row, output_buf, num_rows);
85}
86
87GLOBAL(void)
88jsimd_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr,
89 JCOEFPTR coef_block, JSAMPARRAY output_buf,
90 JDIMENSION output_col)
91{
92 jsimd_idct_ifast_neon(compptr->dct_table, coef_block, output_buf, output_col);
93}
94
95
96GLOBAL(void)
97jsimd_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
98 JCOEFPTR coef_block, JSAMPARRAY output_buf,
99 JDIMENSION output_col)
100{
101 jsimd_idct_2x2_neon(compptr->dct_table, coef_block, output_buf, output_col);
102}
103
104GLOBAL(void)
105jsimd_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
106 JCOEFPTR coef_block, JSAMPARRAY output_buf,
107 JDIMENSION output_col)
108{
109 jsimd_idct_4x4_neon(compptr->dct_table, coef_block, output_buf, output_col);
110}
111
112
113GLOBAL(int)
114cap_neon_idct_2x2 (void)
115{
116 if ( (DCTSIZE != 8) ||
117 (sizeof(JCOEF) != 2) ||
118 (BITS_IN_JSAMPLE != 8) ||
119 (sizeof(JDIMENSION) != 4) ||
120 (sizeof(ISLOW_MULT_TYPE) != 2))
121 return 0;
122
123 return 1;
124}
125
126GLOBAL(int)
127cap_neon_idct_4x4 (void)
128{
129
130 if ( (DCTSIZE != 8) ||
131 (sizeof(JCOEF) != 2) ||
132 (BITS_IN_JSAMPLE != 8) ||
133 (sizeof(JDIMENSION) != 4) ||
134 (sizeof(ISLOW_MULT_TYPE) != 2))
135 return 0;
136
137 return 1;
138}
139
140GLOBAL(int)
141cap_neon_idct_ifast (void)
142{
143
144 if ( (DCTSIZE != 8) ||
145 (sizeof(JCOEF) != 2) ||
146 (BITS_IN_JSAMPLE != 8) ||
147 (sizeof(JDIMENSION) != 4) ||
148 (sizeof(IFAST_MULT_TYPE) != 2) ||
149 (IFAST_SCALE_BITS != 2))
150 return 0;
151
152 return 1;
153
154}
155
156GLOBAL(int)
157cap_neon_ycc_rgb (void)
158{
159
160 if( (BITS_IN_JSAMPLE != 8) ||
161 (sizeof(JDIMENSION) != 4) ||
162 ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4)))
163 return 0;
164
165 return 1;
166}
167
168#endif
169
170