2 * Copyright 2013 The LibYuv Project Authors. All rights reserved.
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.
11 #ifndef INCLUDE_LIBYUV_SCALE_ROW_H_ // NOLINT
12 #define INCLUDE_LIBYUV_SCALE_ROW_H_
14 #include "libyuv/basic_types.h"
21 #if defined(__pnacl__) || defined(__CLR_VER) || defined(COVERAGE_ENABLED) || \
22 defined(TARGET_IPHONE_SIMULATOR)
23 #define LIBYUV_DISABLE_X86
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
45 // The following are available on Neon platforms:
46 #if !defined(LIBYUV_DISABLE_NEON) && !defined(__native_client__) && \
47 (defined(__ARM_NEON__) || defined(LIBYUV_NEON) || defined(__aarch64__))
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
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
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,
71 int bpp, enum FilterMode filtering);
73 void ScalePlaneVertical_16(int src_height,
74 int dst_width, int dst_height,
75 int src_stride, int dst_stride,
76 const uint16* src_argb, uint16* dst_argb,
78 int wpp, enum FilterMode filtering);
80 // Simplify the filtering based on scale factors.
81 enum FilterMode ScaleFilterReduce(int src_width, int src_height,
82 int dst_width, int dst_height,
83 enum FilterMode filtering);
85 // Divide num by div and return as 16.16 fixed point result.
86 int FixedDiv_C(int num, int div);
87 int FixedDiv_X86(int num, int div);
88 // Divide num - 1 by div - 1 and return as 16.16 fixed point result.
89 int FixedDiv1_C(int num, int div);
90 int FixedDiv1_X86(int num, int div);
91 #ifdef HAS_FIXEDDIV_X86
92 #define FixedDiv FixedDiv_X86
93 #define FixedDiv1 FixedDiv1_X86
95 #define FixedDiv FixedDiv_C
96 #define FixedDiv1 FixedDiv1_C
99 // Compute slope values for stepping.
100 void ScaleSlope(int src_width, int src_height,
101 int dst_width, int dst_height,
102 enum FilterMode filtering,
103 int* x, int* y, int* dx, int* dy);
105 void ScaleRowDown2_C(const uint8* src_ptr, ptrdiff_t src_stride,
106 uint8* dst, int dst_width);
107 void ScaleRowDown2_16_C(const uint16* src_ptr, ptrdiff_t src_stride,
108 uint16* dst, int dst_width);
109 void ScaleRowDown2Linear_C(const uint8* src_ptr, ptrdiff_t src_stride,
110 uint8* dst, int dst_width);
111 void ScaleRowDown2Linear_16_C(const uint16* src_ptr, ptrdiff_t src_stride,
112 uint16* dst, int dst_width);
113 void ScaleRowDown2Box_C(const uint8* src_ptr, ptrdiff_t src_stride,
114 uint8* dst, int dst_width);
115 void ScaleRowDown2Box_16_C(const uint16* src_ptr, ptrdiff_t src_stride,
116 uint16* dst, int dst_width);
117 void ScaleRowDown4_C(const uint8* src_ptr, ptrdiff_t src_stride,
118 uint8* dst, int dst_width);
119 void ScaleRowDown4_16_C(const uint16* src_ptr, ptrdiff_t src_stride,
120 uint16* dst, int dst_width);
121 void ScaleRowDown4Box_C(const uint8* src_ptr, ptrdiff_t src_stride,
122 uint8* dst, int dst_width);
123 void ScaleRowDown4Box_16_C(const uint16* src_ptr, ptrdiff_t src_stride,
124 uint16* dst, int dst_width);
125 void ScaleRowDown34_C(const uint8* src_ptr, ptrdiff_t src_stride,
126 uint8* dst, int dst_width);
127 void ScaleRowDown34_16_C(const uint16* src_ptr, ptrdiff_t src_stride,
128 uint16* dst, int dst_width);
129 void ScaleRowDown34_0_Box_C(const uint8* src_ptr, ptrdiff_t src_stride,
130 uint8* d, int dst_width);
131 void ScaleRowDown34_0_Box_16_C(const uint16* src_ptr, ptrdiff_t src_stride,
132 uint16* d, int dst_width);
133 void ScaleRowDown34_1_Box_C(const uint8* src_ptr, ptrdiff_t src_stride,
134 uint8* d, int dst_width);
135 void ScaleRowDown34_1_Box_16_C(const uint16* src_ptr, ptrdiff_t src_stride,
136 uint16* d, int dst_width);
137 void ScaleCols_C(uint8* dst_ptr, const uint8* src_ptr,
138 int dst_width, int x, int dx);
139 void ScaleCols_16_C(uint16* dst_ptr, const uint16* src_ptr,
140 int dst_width, int x, int dx);
141 void ScaleColsUp2_C(uint8* dst_ptr, const uint8* src_ptr,
142 int dst_width, int, int);
143 void ScaleColsUp2_16_C(uint16* dst_ptr, const uint16* src_ptr,
144 int dst_width, int, int);
145 void ScaleFilterCols_C(uint8* dst_ptr, const uint8* src_ptr,
146 int dst_width, int x, int dx);
147 void ScaleFilterCols_16_C(uint16* dst_ptr, const uint16* src_ptr,
148 int dst_width, int x, int dx);
149 void ScaleFilterCols64_C(uint8* dst_ptr, const uint8* src_ptr,
150 int dst_width, int x, int dx);
151 void ScaleFilterCols64_16_C(uint16* dst_ptr, const uint16* src_ptr,
152 int dst_width, int x, int dx);
153 void ScaleRowDown38_C(const uint8* src_ptr, ptrdiff_t src_stride,
154 uint8* dst, int dst_width);
155 void ScaleRowDown38_16_C(const uint16* src_ptr, ptrdiff_t src_stride,
156 uint16* dst, int dst_width);
157 void ScaleRowDown38_3_Box_C(const uint8* src_ptr,
158 ptrdiff_t src_stride,
159 uint8* dst_ptr, int dst_width);
160 void ScaleRowDown38_3_Box_16_C(const uint16* src_ptr,
161 ptrdiff_t src_stride,
162 uint16* dst_ptr, int dst_width);
163 void ScaleRowDown38_2_Box_C(const uint8* src_ptr, ptrdiff_t src_stride,
164 uint8* dst_ptr, int dst_width);
165 void ScaleRowDown38_2_Box_16_C(const uint16* src_ptr, ptrdiff_t src_stride,
166 uint16* dst_ptr, int dst_width);
167 void ScaleAddRows_C(const uint8* src_ptr, ptrdiff_t src_stride,
168 uint16* dst_ptr, int src_width, int src_height);
169 void ScaleAddRows_16_C(const uint16* src_ptr, ptrdiff_t src_stride,
170 uint32* dst_ptr, int src_width, int src_height);
171 void ScaleARGBRowDown2_C(const uint8* src_argb,
172 ptrdiff_t src_stride,
173 uint8* dst_argb, int dst_width);
174 void ScaleARGBRowDown2Linear_C(const uint8* src_argb,
175 ptrdiff_t src_stride,
176 uint8* dst_argb, int dst_width);
177 void ScaleARGBRowDown2Box_C(const uint8* src_argb, ptrdiff_t src_stride,
178 uint8* dst_argb, int dst_width);
179 void ScaleARGBRowDownEven_C(const uint8* src_argb, ptrdiff_t src_stride,
181 uint8* dst_argb, int dst_width);
182 void ScaleARGBRowDownEvenBox_C(const uint8* src_argb,
183 ptrdiff_t src_stride,
185 uint8* dst_argb, int dst_width);
186 void ScaleARGBCols_C(uint8* dst_argb, const uint8* src_argb,
187 int dst_width, int x, int dx);
188 void ScaleARGBCols64_C(uint8* dst_argb, const uint8* src_argb,
189 int dst_width, int x, int dx);
190 void ScaleARGBColsUp2_C(uint8* dst_argb, const uint8* src_argb,
191 int dst_width, int, int);
192 void ScaleARGBFilterCols_C(uint8* dst_argb, const uint8* src_argb,
193 int dst_width, int x, int dx);
194 void ScaleARGBFilterCols64_C(uint8* dst_argb, const uint8* src_argb,
195 int dst_width, int x, int dx);
197 void ScaleRowDown2_SSE2(const uint8* src_ptr, ptrdiff_t src_stride,
198 uint8* dst_ptr, int dst_width);
199 void ScaleRowDown2Linear_SSE2(const uint8* src_ptr, ptrdiff_t src_stride,
200 uint8* dst_ptr, int dst_width);
201 void ScaleRowDown2Box_SSE2(const uint8* src_ptr, ptrdiff_t src_stride,
202 uint8* dst_ptr, int dst_width);
203 void ScaleRowDown4_SSE2(const uint8* src_ptr, ptrdiff_t src_stride,
204 uint8* dst_ptr, int dst_width);
205 void ScaleRowDown4Box_SSE2(const uint8* src_ptr, ptrdiff_t src_stride,
206 uint8* dst_ptr, int dst_width);
207 void ScaleRowDown34_SSSE3(const uint8* src_ptr, ptrdiff_t src_stride,
208 uint8* dst_ptr, int dst_width);
209 void ScaleRowDown34_1_Box_SSSE3(const uint8* src_ptr,
210 ptrdiff_t src_stride,
211 uint8* dst_ptr, int dst_width);
212 void ScaleRowDown34_0_Box_SSSE3(const uint8* src_ptr,
213 ptrdiff_t src_stride,
214 uint8* dst_ptr, int dst_width);
215 void ScaleRowDown38_SSSE3(const uint8* src_ptr, ptrdiff_t src_stride,
216 uint8* dst_ptr, int dst_width);
217 void ScaleRowDown38_3_Box_SSSE3(const uint8* src_ptr,
218 ptrdiff_t src_stride,
219 uint8* dst_ptr, int dst_width);
220 void ScaleRowDown38_2_Box_SSSE3(const uint8* src_ptr,
221 ptrdiff_t src_stride,
222 uint8* dst_ptr, int dst_width);
223 void ScaleAddRows_SSE2(const uint8* src_ptr, ptrdiff_t src_stride,
224 uint16* dst_ptr, int src_width,
226 void ScaleFilterCols_SSSE3(uint8* dst_ptr, const uint8* src_ptr,
227 int dst_width, int x, int dx);
228 void ScaleColsUp2_SSE2(uint8* dst_ptr, const uint8* src_ptr,
229 int dst_width, int x, int dx);
230 void ScaleARGBRowDown2_SSE2(const uint8* src_argb,
231 ptrdiff_t src_stride,
232 uint8* dst_argb, int dst_width);
233 void ScaleARGBRowDown2Linear_SSE2(const uint8* src_argb,
234 ptrdiff_t src_stride,
235 uint8* dst_argb, int dst_width);
236 void ScaleARGBRowDown2Box_SSE2(const uint8* src_argb,
237 ptrdiff_t src_stride,
238 uint8* dst_argb, int dst_width);
239 void ScaleARGBRowDownEven_SSE2(const uint8* src_argb, ptrdiff_t src_stride,
241 uint8* dst_argb, int dst_width);
242 void ScaleARGBRowDownEvenBox_SSE2(const uint8* src_argb,
243 ptrdiff_t src_stride,
245 uint8* dst_argb, int dst_width);
246 void ScaleARGBCols_SSE2(uint8* dst_argb, const uint8* src_argb,
247 int dst_width, int x, int dx);
248 void ScaleARGBFilterCols_SSSE3(uint8* dst_argb, const uint8* src_argb,
249 int dst_width, int x, int dx);
250 void ScaleARGBColsUp2_SSE2(uint8* dst_argb, const uint8* src_argb,
251 int dst_width, int x, int dx);
253 void ScaleARGBRowDownEven_NEON(const uint8* src_argb, ptrdiff_t src_stride,
255 uint8* dst_argb, int dst_width);
256 void ScaleARGBRowDownEvenBox_NEON(const uint8* src_argb, ptrdiff_t src_stride,
258 uint8* dst_argb, int dst_width);
259 void ScaleARGBRowDown2_NEON(const uint8* src_ptr, ptrdiff_t src_stride,
260 uint8* dst, int dst_width);
261 void ScaleARGBRowDown2Box_NEON(const uint8* src_ptr, ptrdiff_t src_stride,
262 uint8* dst, int dst_width);
264 // ScaleRowDown2Box also used by planar functions
265 // NEON downscalers with interpolation.
267 // Note - not static due to reuse in convert for 444 to 420.
268 void ScaleRowDown2_NEON(const uint8* src_ptr, ptrdiff_t src_stride,
269 uint8* dst, int dst_width);
271 void ScaleRowDown2Box_NEON(const uint8* src_ptr, ptrdiff_t src_stride,
272 uint8* dst, int dst_width);
274 void ScaleRowDown4_NEON(const uint8* src_ptr, ptrdiff_t src_stride,
275 uint8* dst_ptr, int dst_width);
276 void ScaleRowDown4Box_NEON(const uint8* src_ptr, ptrdiff_t src_stride,
277 uint8* dst_ptr, int dst_width);
279 // Down scale from 4 to 3 pixels. Use the neon multilane read/write
280 // to load up the every 4th pixel into a 4 different registers.
281 // Point samples 32 pixels to 24 pixels.
282 void ScaleRowDown34_NEON(const uint8* src_ptr,
283 ptrdiff_t src_stride,
284 uint8* dst_ptr, int dst_width);
285 void ScaleRowDown34_0_Box_NEON(const uint8* src_ptr,
286 ptrdiff_t src_stride,
287 uint8* dst_ptr, int dst_width);
288 void ScaleRowDown34_1_Box_NEON(const uint8* src_ptr,
289 ptrdiff_t src_stride,
290 uint8* dst_ptr, int dst_width);
293 void ScaleRowDown38_NEON(const uint8* src_ptr,
294 ptrdiff_t src_stride,
295 uint8* dst_ptr, int dst_width);
297 void ScaleRowDown38_3_Box_NEON(const uint8* src_ptr,
298 ptrdiff_t src_stride,
299 uint8* dst_ptr, int dst_width);
301 void ScaleRowDown38_2_Box_NEON(const uint8* src_ptr,
302 ptrdiff_t src_stride,
303 uint8* dst_ptr, int dst_width);
305 void ScaleRowDown2_MIPS_DSPR2(const uint8* src_ptr, ptrdiff_t src_stride,
306 uint8* dst, int dst_width);
307 void ScaleRowDown2Box_MIPS_DSPR2(const uint8* src_ptr, ptrdiff_t src_stride,
308 uint8* dst, int dst_width);
309 void ScaleRowDown4_MIPS_DSPR2(const uint8* src_ptr, ptrdiff_t src_stride,
310 uint8* dst, int dst_width);
311 void ScaleRowDown4Box_MIPS_DSPR2(const uint8* src_ptr, ptrdiff_t src_stride,
312 uint8* dst, int dst_width);
313 void ScaleRowDown34_MIPS_DSPR2(const uint8* src_ptr, ptrdiff_t src_stride,
314 uint8* dst, int dst_width);
315 void ScaleRowDown34_0_Box_MIPS_DSPR2(const uint8* src_ptr, ptrdiff_t src_stride,
316 uint8* d, int dst_width);
317 void ScaleRowDown34_1_Box_MIPS_DSPR2(const uint8* src_ptr, ptrdiff_t src_stride,
318 uint8* d, int dst_width);
319 void ScaleRowDown38_MIPS_DSPR2(const uint8* src_ptr, ptrdiff_t src_stride,
320 uint8* dst, int dst_width);
321 void ScaleRowDown38_2_Box_MIPS_DSPR2(const uint8* src_ptr, ptrdiff_t src_stride,
322 uint8* dst_ptr, int dst_width);
323 void ScaleRowDown38_3_Box_MIPS_DSPR2(const uint8* src_ptr,
324 ptrdiff_t src_stride,
325 uint8* dst_ptr, int dst_width);
329 } // namespace libyuv
332 #endif // INCLUDE_LIBYUV_SCALE_ROW_H_ NOLINT