Wed, 31 Dec 2014 06:55:50 +0100
Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2
1 /*
2 * Copyright 2013 The LibYuv Project Authors. All rights reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
11 #ifndef INCLUDE_LIBYUV_SCALE_ROW_H_ // NOLINT
12 #define INCLUDE_LIBYUV_SCALE_ROW_H_
14 #include "libyuv/basic_types.h"
16 #ifdef __cplusplus
17 namespace libyuv {
18 extern "C" {
19 #endif
21 #if defined(__pnacl__) || defined(__CLR_VER) || defined(COVERAGE_ENABLED) || \
22 defined(TARGET_IPHONE_SIMULATOR)
23 #define LIBYUV_DISABLE_X86
24 #endif
26 // The following are available on all x86 platforms:
27 #if !defined(LIBYUV_DISABLE_X86) && \
28 (defined(_M_IX86) || defined(__x86_64__) || defined(__i386__))
29 #define HAS_SCALEROWDOWN2_SSE2
30 #define HAS_SCALEROWDOWN4_SSE2
31 #define HAS_SCALEROWDOWN34_SSSE3
32 #define HAS_SCALEROWDOWN38_SSSE3
33 #define HAS_SCALEADDROWS_SSE2
34 #define HAS_SCALEFILTERCOLS_SSSE3
35 #define HAS_SCALECOLSUP2_SSE2
36 #define HAS_SCALEARGBROWDOWN2_SSE2
37 #define HAS_SCALEARGBROWDOWNEVEN_SSE2
38 #define HAS_SCALEARGBCOLS_SSE2
39 #define HAS_SCALEARGBFILTERCOLS_SSSE3
40 #define HAS_SCALEARGBCOLSUP2_SSE2
41 #define HAS_FIXEDDIV_X86
42 #define HAS_FIXEDDIV1_X86
43 #endif
45 // The following are available on Neon platforms:
46 #if !defined(LIBYUV_DISABLE_NEON) && !defined(__native_client__) && \
47 (defined(__ARM_NEON__) || defined(LIBYUV_NEON))
48 #define HAS_SCALEROWDOWN2_NEON
49 #define HAS_SCALEROWDOWN4_NEON
50 #define HAS_SCALEROWDOWN34_NEON
51 #define HAS_SCALEROWDOWN38_NEON
52 #define HAS_SCALEARGBROWDOWNEVEN_NEON
53 #define HAS_SCALEARGBROWDOWN2_NEON
54 #endif
56 // The following are available on Mips platforms:
57 #if !defined(LIBYUV_DISABLE_MIPS) && !defined(__native_client__) && \
58 defined(__mips__) && defined(__mips_dsp) && (__mips_dsp_rev >= 2)
59 #define HAS_SCALEROWDOWN2_MIPS_DSPR2
60 #define HAS_SCALEROWDOWN4_MIPS_DSPR2
61 #define HAS_SCALEROWDOWN34_MIPS_DSPR2
62 #define HAS_SCALEROWDOWN38_MIPS_DSPR2
63 #endif
65 // Scale ARGB vertically with bilinear interpolation.
66 void ScalePlaneVertical(int src_height,
67 int dst_width, int dst_height,
68 int src_stride, int dst_stride,
69 const uint8* src_argb, uint8* dst_argb,
70 int x, int y, int dy,
71 int bpp, enum FilterMode filtering);
73 // Simplify the filtering based on scale factors.
74 enum FilterMode ScaleFilterReduce(int src_width, int src_height,
75 int dst_width, int dst_height,
76 enum FilterMode filtering);
78 // Divide num by div and return as 16.16 fixed point result.
79 int FixedDiv_C(int num, int div);
80 int FixedDiv_X86(int num, int div);
81 // Divide num - 1 by div - 1 and return as 16.16 fixed point result.
82 int FixedDiv1_C(int num, int div);
83 int FixedDiv1_X86(int num, int div);
84 #ifdef HAS_FIXEDDIV_X86
85 #define FixedDiv FixedDiv_X86
86 #define FixedDiv1 FixedDiv1_X86
87 #else
88 #define FixedDiv FixedDiv_C
89 #define FixedDiv1 FixedDiv1_C
90 #endif
92 // Compute slope values for stepping.
93 void ScaleSlope(int src_width, int src_height,
94 int dst_width, int dst_height,
95 enum FilterMode filtering,
96 int* x, int* y, int* dx, int* dy);
98 void ScaleRowDown2_C(const uint8* src_ptr, ptrdiff_t src_stride,
99 uint8* dst, int dst_width);
100 void ScaleRowDown2Linear_C(const uint8* src_ptr, ptrdiff_t src_stride,
101 uint8* dst, int dst_width);
102 void ScaleRowDown2Box_C(const uint8* src_ptr, ptrdiff_t src_stride,
103 uint8* dst, int dst_width);
104 void ScaleRowDown4_C(const uint8* src_ptr, ptrdiff_t src_stride,
105 uint8* dst, int dst_width);
106 void ScaleRowDown4Box_C(const uint8* src_ptr, ptrdiff_t src_stride,
107 uint8* dst, int dst_width);
108 void ScaleRowDown34_C(const uint8* src_ptr, ptrdiff_t src_stride,
109 uint8* dst, int dst_width);
110 void ScaleRowDown34_0_Box_C(const uint8* src_ptr, ptrdiff_t src_stride,
111 uint8* d, int dst_width);
112 void ScaleRowDown34_1_Box_C(const uint8* src_ptr, ptrdiff_t src_stride,
113 uint8* d, int dst_width);
114 void ScaleCols_C(uint8* dst_ptr, const uint8* src_ptr,
115 int dst_width, int x, int dx);
116 void ScaleColsUp2_C(uint8* dst_ptr, const uint8* src_ptr,
117 int dst_width, int, int);
118 void ScaleFilterCols_C(uint8* dst_ptr, const uint8* src_ptr,
119 int dst_width, int x, int dx);
120 void ScaleFilterCols64_C(uint8* dst_ptr, const uint8* src_ptr,
121 int dst_width, int x, int dx);
122 void ScaleRowDown38_C(const uint8* src_ptr, ptrdiff_t src_stride,
123 uint8* dst, int dst_width);
124 void ScaleRowDown38_3_Box_C(const uint8* src_ptr,
125 ptrdiff_t src_stride,
126 uint8* dst_ptr, int dst_width);
127 void ScaleRowDown38_2_Box_C(const uint8* src_ptr, ptrdiff_t src_stride,
128 uint8* dst_ptr, int dst_width);
129 void ScaleAddRows_C(const uint8* src_ptr, ptrdiff_t src_stride,
130 uint16* dst_ptr, int src_width, int src_height);
131 void ScaleARGBRowDown2_C(const uint8* src_argb,
132 ptrdiff_t src_stride,
133 uint8* dst_argb, int dst_width);
134 void ScaleARGBRowDown2Linear_C(const uint8* src_argb,
135 ptrdiff_t src_stride,
136 uint8* dst_argb, int dst_width);
137 void ScaleARGBRowDown2Box_C(const uint8* src_argb, ptrdiff_t src_stride,
138 uint8* dst_argb, int dst_width);
139 void ScaleARGBRowDownEven_C(const uint8* src_argb, ptrdiff_t src_stride,
140 int src_stepx,
141 uint8* dst_argb, int dst_width);
142 void ScaleARGBRowDownEvenBox_C(const uint8* src_argb,
143 ptrdiff_t src_stride,
144 int src_stepx,
145 uint8* dst_argb, int dst_width);
146 void ScaleARGBCols_C(uint8* dst_argb, const uint8* src_argb,
147 int dst_width, int x, int dx);
148 void ScaleARGBCols64_C(uint8* dst_argb, const uint8* src_argb,
149 int dst_width, int x, int dx);
150 void ScaleARGBColsUp2_C(uint8* dst_argb, const uint8* src_argb,
151 int dst_width, int, int);
152 void ScaleARGBFilterCols_C(uint8* dst_argb, const uint8* src_argb,
153 int dst_width, int x, int dx);
154 void ScaleARGBFilterCols64_C(uint8* dst_argb, const uint8* src_argb,
155 int dst_width, int x, int dx);
157 void ScaleRowDown2_SSE2(const uint8* src_ptr, ptrdiff_t src_stride,
158 uint8* dst_ptr, int dst_width);
159 void ScaleRowDown2Linear_SSE2(const uint8* src_ptr, ptrdiff_t src_stride,
160 uint8* dst_ptr, int dst_width);
161 void ScaleRowDown2Box_SSE2(const uint8* src_ptr, ptrdiff_t src_stride,
162 uint8* dst_ptr, int dst_width);
163 void ScaleRowDown2_Unaligned_SSE2(const uint8* src_ptr,
164 ptrdiff_t src_stride,
165 uint8* dst_ptr, int dst_width);
166 void ScaleRowDown2Linear_Unaligned_SSE2(const uint8* src_ptr,
167 ptrdiff_t src_stride,
168 uint8* dst_ptr, int dst_width);
169 void ScaleRowDown2Box_Unaligned_SSE2(const uint8* src_ptr,
170 ptrdiff_t src_stride,
171 uint8* dst_ptr, int dst_width);
172 void ScaleRowDown4_SSE2(const uint8* src_ptr, ptrdiff_t src_stride,
173 uint8* dst_ptr, int dst_width);
174 void ScaleRowDown4Box_SSE2(const uint8* src_ptr, ptrdiff_t src_stride,
175 uint8* dst_ptr, int dst_width);
176 void ScaleRowDown34_SSSE3(const uint8* src_ptr, ptrdiff_t src_stride,
177 uint8* dst_ptr, int dst_width);
178 void ScaleRowDown34_1_Box_SSSE3(const uint8* src_ptr,
179 ptrdiff_t src_stride,
180 uint8* dst_ptr, int dst_width);
181 void ScaleRowDown34_0_Box_SSSE3(const uint8* src_ptr,
182 ptrdiff_t src_stride,
183 uint8* dst_ptr, int dst_width);
184 void ScaleRowDown38_SSSE3(const uint8* src_ptr, ptrdiff_t src_stride,
185 uint8* dst_ptr, int dst_width);
186 void ScaleRowDown38_3_Box_SSSE3(const uint8* src_ptr,
187 ptrdiff_t src_stride,
188 uint8* dst_ptr, int dst_width);
189 void ScaleRowDown38_2_Box_SSSE3(const uint8* src_ptr,
190 ptrdiff_t src_stride,
191 uint8* dst_ptr, int dst_width);
192 void ScaleAddRows_SSE2(const uint8* src_ptr, ptrdiff_t src_stride,
193 uint16* dst_ptr, int src_width,
194 int src_height);
195 void ScaleFilterCols_SSSE3(uint8* dst_ptr, const uint8* src_ptr,
196 int dst_width, int x, int dx);
197 void ScaleColsUp2_SSE2(uint8* dst_ptr, const uint8* src_ptr,
198 int dst_width, int x, int dx);
199 void ScaleARGBRowDown2_SSE2(const uint8* src_argb,
200 ptrdiff_t src_stride,
201 uint8* dst_argb, int dst_width);
202 void ScaleARGBRowDown2Linear_SSE2(const uint8* src_argb,
203 ptrdiff_t src_stride,
204 uint8* dst_argb, int dst_width);
205 void ScaleARGBRowDown2Box_SSE2(const uint8* src_argb,
206 ptrdiff_t src_stride,
207 uint8* dst_argb, int dst_width);
208 void ScaleARGBRowDownEven_SSE2(const uint8* src_argb, ptrdiff_t src_stride,
209 int src_stepx,
210 uint8* dst_argb, int dst_width);
211 void ScaleARGBRowDownEvenBox_SSE2(const uint8* src_argb,
212 ptrdiff_t src_stride,
213 int src_stepx,
214 uint8* dst_argb, int dst_width);
215 void ScaleARGBCols_SSE2(uint8* dst_argb, const uint8* src_argb,
216 int dst_width, int x, int dx);
217 void ScaleARGBFilterCols_SSSE3(uint8* dst_argb, const uint8* src_argb,
218 int dst_width, int x, int dx);
219 void ScaleARGBColsUp2_SSE2(uint8* dst_argb, const uint8* src_argb,
220 int dst_width, int x, int dx);
221 // Row functions.
222 void ScaleARGBRowDownEven_NEON(const uint8* src_argb, int src_stride,
223 int src_stepx,
224 uint8* dst_argb, int dst_width);
225 void ScaleARGBRowDownEvenBox_NEON(const uint8* src_argb, int src_stride,
226 int src_stepx,
227 uint8* dst_argb, int dst_width);
228 void ScaleARGBRowDown2_NEON(const uint8* src_ptr, ptrdiff_t src_stride,
229 uint8* dst, int dst_width);
230 void ScaleARGBRowDown2Box_NEON(const uint8* src_ptr, ptrdiff_t src_stride,
231 uint8* dst, int dst_width);
233 // ScaleRowDown2Box also used by planar functions
234 // NEON downscalers with interpolation.
236 // Note - not static due to reuse in convert for 444 to 420.
237 void ScaleRowDown2_NEON(const uint8* src_ptr, ptrdiff_t src_stride,
238 uint8* dst, int dst_width);
240 void ScaleRowDown2Box_NEON(const uint8* src_ptr, ptrdiff_t src_stride,
241 uint8* dst, int dst_width);
243 void ScaleRowDown4_NEON(const uint8* src_ptr, ptrdiff_t src_stride,
244 uint8* dst_ptr, int dst_width);
245 void ScaleRowDown4Box_NEON(const uint8* src_ptr, ptrdiff_t src_stride,
246 uint8* dst_ptr, int dst_width);
248 // Down scale from 4 to 3 pixels. Use the neon multilane read/write
249 // to load up the every 4th pixel into a 4 different registers.
250 // Point samples 32 pixels to 24 pixels.
251 void ScaleRowDown34_NEON(const uint8* src_ptr,
252 ptrdiff_t src_stride,
253 uint8* dst_ptr, int dst_width);
254 void ScaleRowDown34_0_Box_NEON(const uint8* src_ptr,
255 ptrdiff_t src_stride,
256 uint8* dst_ptr, int dst_width);
257 void ScaleRowDown34_1_Box_NEON(const uint8* src_ptr,
258 ptrdiff_t src_stride,
259 uint8* dst_ptr, int dst_width);
261 // 32 -> 12
262 void ScaleRowDown38_NEON(const uint8* src_ptr,
263 ptrdiff_t src_stride,
264 uint8* dst_ptr, int dst_width);
265 // 32x3 -> 12x1
266 void ScaleRowDown38_3_Box_NEON(const uint8* src_ptr,
267 ptrdiff_t src_stride,
268 uint8* dst_ptr, int dst_width);
269 // 32x2 -> 12x1
270 void ScaleRowDown38_2_Box_NEON(const uint8* src_ptr,
271 ptrdiff_t src_stride,
272 uint8* dst_ptr, int dst_width);
274 void ScaleRowDown2_MIPS_DSPR2(const uint8* src_ptr, ptrdiff_t src_stride,
275 uint8* dst, int dst_width);
276 void ScaleRowDown2Box_MIPS_DSPR2(const uint8* src_ptr, ptrdiff_t src_stride,
277 uint8* dst, int dst_width);
278 void ScaleRowDown4_MIPS_DSPR2(const uint8* src_ptr, ptrdiff_t src_stride,
279 uint8* dst, int dst_width);
280 void ScaleRowDown4Box_MIPS_DSPR2(const uint8* src_ptr, ptrdiff_t src_stride,
281 uint8* dst, int dst_width);
282 void ScaleRowDown34_MIPS_DSPR2(const uint8* src_ptr, ptrdiff_t src_stride,
283 uint8* dst, int dst_width);
284 void ScaleRowDown34_0_Box_MIPS_DSPR2(const uint8* src_ptr, ptrdiff_t src_stride,
285 uint8* d, int dst_width);
286 void ScaleRowDown34_1_Box_MIPS_DSPR2(const uint8* src_ptr, ptrdiff_t src_stride,
287 uint8* d, int dst_width);
288 void ScaleRowDown38_MIPS_DSPR2(const uint8* src_ptr, ptrdiff_t src_stride,
289 uint8* dst, int dst_width);
290 void ScaleRowDown38_2_Box_MIPS_DSPR2(const uint8* src_ptr, ptrdiff_t src_stride,
291 uint8* dst_ptr, int dst_width);
292 void ScaleRowDown38_3_Box_MIPS_DSPR2(const uint8* src_ptr,
293 ptrdiff_t src_stride,
294 uint8* dst_ptr, int dst_width);
296 #ifdef __cplusplus
297 } // extern "C"
298 } // namespace libyuv
299 #endif
301 #endif // INCLUDE_LIBYUV_SCALE_ROW_H_ NOLINT