Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / libvpx / source / libvpx / third_party / libyuv / include / libyuv / scale_row.h
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  */
10
11 #ifndef INCLUDE_LIBYUV_SCALE_ROW_H_  // NOLINT
12 #define INCLUDE_LIBYUV_SCALE_ROW_H_
13
14 #include "libyuv/basic_types.h"
15
16 #ifdef __cplusplus
17 namespace libyuv {
18 extern "C" {
19 #endif
20
21 #if defined(__pnacl__) || defined(__CLR_VER) || defined(COVERAGE_ENABLED) || \
22     defined(TARGET_IPHONE_SIMULATOR)
23 #define LIBYUV_DISABLE_X86
24 #endif
25
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
44
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 #elif !defined(LIBYUV_DISABLE_NEON) && !defined(__native_client__) && \
55     (defined(__aarch64__) || defined(LIBYUV_NEON))
56 /* #define HAS_SCALEROWDOWN2_NEON */
57 /* #define HAS_SCALEROWDOWN4_NEON */
58 /* #define HAS_SCALEROWDOWN34_NEON */
59 /* #define HAS_SCALEROWDOWN38_NEON */
60 /* #define HAS_SCALEARGBROWDOWNEVEN_NEON */
61 /* #define HAS_SCALEARGBROWDOWN2_NEON */
62 #endif
63
64 // The following are available on Mips platforms:
65 #if !defined(LIBYUV_DISABLE_MIPS) && !defined(__native_client__) && \
66     defined(__mips__) && defined(__mips_dsp) && (__mips_dsp_rev >= 2)
67 #define HAS_SCALEROWDOWN2_MIPS_DSPR2
68 #define HAS_SCALEROWDOWN4_MIPS_DSPR2
69 #define HAS_SCALEROWDOWN34_MIPS_DSPR2
70 #define HAS_SCALEROWDOWN38_MIPS_DSPR2
71 #endif
72
73 // Scale ARGB vertically with bilinear interpolation.
74 void ScalePlaneVertical(int src_height,
75                         int dst_width, int dst_height,
76                         int src_stride, int dst_stride,
77                         const uint8* src_argb, uint8* dst_argb,
78                         int x, int y, int dy,
79                         int bpp, enum FilterMode filtering);
80
81 void ScalePlaneVertical_16(int src_height,
82                            int dst_width, int dst_height,
83                            int src_stride, int dst_stride,
84                            const uint16* src_argb, uint16* dst_argb,
85                            int x, int y, int dy,
86                            int wpp, enum FilterMode filtering);
87
88 // Simplify the filtering based on scale factors.
89 enum FilterMode ScaleFilterReduce(int src_width, int src_height,
90                                   int dst_width, int dst_height,
91                                   enum FilterMode filtering);
92
93 // Divide num by div and return as 16.16 fixed point result.
94 int FixedDiv_C(int num, int div);
95 int FixedDiv_X86(int num, int div);
96 // Divide num - 1 by div - 1 and return as 16.16 fixed point result.
97 int FixedDiv1_C(int num, int div);
98 int FixedDiv1_X86(int num, int div);
99 #ifdef HAS_FIXEDDIV_X86
100 #define FixedDiv FixedDiv_X86
101 #define FixedDiv1 FixedDiv1_X86
102 #else
103 #define FixedDiv FixedDiv_C
104 #define FixedDiv1 FixedDiv1_C
105 #endif
106
107 // Compute slope values for stepping.
108 void ScaleSlope(int src_width, int src_height,
109                 int dst_width, int dst_height,
110                 enum FilterMode filtering,
111                 int* x, int* y, int* dx, int* dy);
112
113 void ScaleRowDown2_C(const uint8* src_ptr, ptrdiff_t src_stride,
114                      uint8* dst, int dst_width);
115 void ScaleRowDown2_16_C(const uint16* src_ptr, ptrdiff_t src_stride,
116                         uint16* dst, int dst_width);
117 void ScaleRowDown2Linear_C(const uint8* src_ptr, ptrdiff_t src_stride,
118                            uint8* dst, int dst_width);
119 void ScaleRowDown2Linear_16_C(const uint16* src_ptr, ptrdiff_t src_stride,
120                               uint16* dst, int dst_width);
121 void ScaleRowDown2Box_C(const uint8* src_ptr, ptrdiff_t src_stride,
122                         uint8* dst, int dst_width);
123 void ScaleRowDown2Box_16_C(const uint16* src_ptr, ptrdiff_t src_stride,
124                            uint16* dst, int dst_width);
125 void ScaleRowDown4_C(const uint8* src_ptr, ptrdiff_t src_stride,
126                      uint8* dst, int dst_width);
127 void ScaleRowDown4_16_C(const uint16* src_ptr, ptrdiff_t src_stride,
128                         uint16* dst, int dst_width);
129 void ScaleRowDown4Box_C(const uint8* src_ptr, ptrdiff_t src_stride,
130                         uint8* dst, int dst_width);
131 void ScaleRowDown4Box_16_C(const uint16* src_ptr, ptrdiff_t src_stride,
132                            uint16* dst, int dst_width);
133 void ScaleRowDown34_C(const uint8* src_ptr, ptrdiff_t src_stride,
134                       uint8* dst, int dst_width);
135 void ScaleRowDown34_16_C(const uint16* src_ptr, ptrdiff_t src_stride,
136                          uint16* dst, int dst_width);
137 void ScaleRowDown34_0_Box_C(const uint8* src_ptr, ptrdiff_t src_stride,
138                             uint8* d, int dst_width);
139 void ScaleRowDown34_0_Box_16_C(const uint16* src_ptr, ptrdiff_t src_stride,
140                                uint16* d, int dst_width);
141 void ScaleRowDown34_1_Box_C(const uint8* src_ptr, ptrdiff_t src_stride,
142                             uint8* d, int dst_width);
143 void ScaleRowDown34_1_Box_16_C(const uint16* src_ptr, ptrdiff_t src_stride,
144                                uint16* d, int dst_width);
145 void ScaleCols_C(uint8* dst_ptr, const uint8* src_ptr,
146                  int dst_width, int x, int dx);
147 void ScaleCols_16_C(uint16* dst_ptr, const uint16* src_ptr,
148                     int dst_width, int x, int dx);
149 void ScaleColsUp2_C(uint8* dst_ptr, const uint8* src_ptr,
150                     int dst_width, int, int);
151 void ScaleColsUp2_16_C(uint16* dst_ptr, const uint16* src_ptr,
152                        int dst_width, int, int);
153 void ScaleFilterCols_C(uint8* dst_ptr, const uint8* src_ptr,
154                        int dst_width, int x, int dx);
155 void ScaleFilterCols_16_C(uint16* dst_ptr, const uint16* src_ptr,
156                           int dst_width, int x, int dx);
157 void ScaleFilterCols64_C(uint8* dst_ptr, const uint8* src_ptr,
158                          int dst_width, int x, int dx);
159 void ScaleFilterCols64_16_C(uint16* dst_ptr, const uint16* src_ptr,
160                             int dst_width, int x, int dx);
161 void ScaleRowDown38_C(const uint8* src_ptr, ptrdiff_t src_stride,
162                       uint8* dst, int dst_width);
163 void ScaleRowDown38_16_C(const uint16* src_ptr, ptrdiff_t src_stride,
164                          uint16* dst, int dst_width);
165 void ScaleRowDown38_3_Box_C(const uint8* src_ptr,
166                             ptrdiff_t src_stride,
167                             uint8* dst_ptr, int dst_width);
168 void ScaleRowDown38_3_Box_16_C(const uint16* src_ptr,
169                                ptrdiff_t src_stride,
170                                uint16* dst_ptr, int dst_width);
171 void ScaleRowDown38_2_Box_C(const uint8* src_ptr, ptrdiff_t src_stride,
172                             uint8* dst_ptr, int dst_width);
173 void ScaleRowDown38_2_Box_16_C(const uint16* src_ptr, ptrdiff_t src_stride,
174                                uint16* dst_ptr, int dst_width);
175 void ScaleAddRows_C(const uint8* src_ptr, ptrdiff_t src_stride,
176                     uint16* dst_ptr, int src_width, int src_height);
177 void ScaleAddRows_16_C(const uint16* src_ptr, ptrdiff_t src_stride,
178                        uint32* dst_ptr, int src_width, int src_height);
179 void ScaleARGBRowDown2_C(const uint8* src_argb,
180                          ptrdiff_t src_stride,
181                          uint8* dst_argb, int dst_width);
182 void ScaleARGBRowDown2Linear_C(const uint8* src_argb,
183                                ptrdiff_t src_stride,
184                                uint8* dst_argb, int dst_width);
185 void ScaleARGBRowDown2Box_C(const uint8* src_argb, ptrdiff_t src_stride,
186                             uint8* dst_argb, int dst_width);
187 void ScaleARGBRowDownEven_C(const uint8* src_argb, ptrdiff_t src_stride,
188                             int src_stepx,
189                             uint8* dst_argb, int dst_width);
190 void ScaleARGBRowDownEvenBox_C(const uint8* src_argb,
191                                ptrdiff_t src_stride,
192                                int src_stepx,
193                                uint8* dst_argb, int dst_width);
194 void ScaleARGBCols_C(uint8* dst_argb, const uint8* src_argb,
195                      int dst_width, int x, int dx);
196 void ScaleARGBCols64_C(uint8* dst_argb, const uint8* src_argb,
197                        int dst_width, int x, int dx);
198 void ScaleARGBColsUp2_C(uint8* dst_argb, const uint8* src_argb,
199                         int dst_width, int, int);
200 void ScaleARGBFilterCols_C(uint8* dst_argb, const uint8* src_argb,
201                            int dst_width, int x, int dx);
202 void ScaleARGBFilterCols64_C(uint8* dst_argb, const uint8* src_argb,
203                              int dst_width, int x, int dx);
204
205 void ScaleRowDown2_SSE2(const uint8* src_ptr, ptrdiff_t src_stride,
206                         uint8* dst_ptr, int dst_width);
207 void ScaleRowDown2Linear_SSE2(const uint8* src_ptr, ptrdiff_t src_stride,
208                               uint8* dst_ptr, int dst_width);
209 void ScaleRowDown2Box_SSE2(const uint8* src_ptr, ptrdiff_t src_stride,
210                            uint8* dst_ptr, int dst_width);
211 void ScaleRowDown2_Unaligned_SSE2(const uint8* src_ptr,
212                                   ptrdiff_t src_stride,
213                                   uint8* dst_ptr, int dst_width);
214 void ScaleRowDown2Linear_Unaligned_SSE2(const uint8* src_ptr,
215                                         ptrdiff_t src_stride,
216                                         uint8* dst_ptr, int dst_width);
217 void ScaleRowDown2Box_Unaligned_SSE2(const uint8* src_ptr,
218                                      ptrdiff_t src_stride,
219                                      uint8* dst_ptr, int dst_width);
220 void ScaleRowDown4_SSE2(const uint8* src_ptr, ptrdiff_t src_stride,
221                         uint8* dst_ptr, int dst_width);
222 void ScaleRowDown4Box_SSE2(const uint8* src_ptr, ptrdiff_t src_stride,
223                            uint8* dst_ptr, int dst_width);
224 void ScaleRowDown34_SSSE3(const uint8* src_ptr, ptrdiff_t src_stride,
225                           uint8* dst_ptr, int dst_width);
226 void ScaleRowDown34_1_Box_SSSE3(const uint8* src_ptr,
227                                 ptrdiff_t src_stride,
228                                 uint8* dst_ptr, int dst_width);
229 void ScaleRowDown34_0_Box_SSSE3(const uint8* src_ptr,
230                                 ptrdiff_t src_stride,
231                                 uint8* dst_ptr, int dst_width);
232 void ScaleRowDown38_SSSE3(const uint8* src_ptr, ptrdiff_t src_stride,
233                           uint8* dst_ptr, int dst_width);
234 void ScaleRowDown38_3_Box_SSSE3(const uint8* src_ptr,
235                                 ptrdiff_t src_stride,
236                                 uint8* dst_ptr, int dst_width);
237 void ScaleRowDown38_2_Box_SSSE3(const uint8* src_ptr,
238                                 ptrdiff_t src_stride,
239                                 uint8* dst_ptr, int dst_width);
240 void ScaleAddRows_SSE2(const uint8* src_ptr, ptrdiff_t src_stride,
241                        uint16* dst_ptr, int src_width,
242                        int src_height);
243 void ScaleFilterCols_SSSE3(uint8* dst_ptr, const uint8* src_ptr,
244                            int dst_width, int x, int dx);
245 void ScaleColsUp2_SSE2(uint8* dst_ptr, const uint8* src_ptr,
246                        int dst_width, int x, int dx);
247 void ScaleARGBRowDown2_SSE2(const uint8* src_argb,
248                             ptrdiff_t src_stride,
249                             uint8* dst_argb, int dst_width);
250 void ScaleARGBRowDown2Linear_SSE2(const uint8* src_argb,
251                                   ptrdiff_t src_stride,
252                                   uint8* dst_argb, int dst_width);
253 void ScaleARGBRowDown2Box_SSE2(const uint8* src_argb,
254                                ptrdiff_t src_stride,
255                                uint8* dst_argb, int dst_width);
256 void ScaleARGBRowDownEven_SSE2(const uint8* src_argb, ptrdiff_t src_stride,
257                                int src_stepx,
258                                uint8* dst_argb, int dst_width);
259 void ScaleARGBRowDownEvenBox_SSE2(const uint8* src_argb,
260                                   ptrdiff_t src_stride,
261                                   int src_stepx,
262                                   uint8* dst_argb, int dst_width);
263 void ScaleARGBCols_SSE2(uint8* dst_argb, const uint8* src_argb,
264                         int dst_width, int x, int dx);
265 void ScaleARGBFilterCols_SSSE3(uint8* dst_argb, const uint8* src_argb,
266                                int dst_width, int x, int dx);
267 void ScaleARGBColsUp2_SSE2(uint8* dst_argb, const uint8* src_argb,
268                            int dst_width, int x, int dx);
269 // Row functions.
270 void ScaleARGBRowDownEven_NEON(const uint8* src_argb, int src_stride,
271                                int src_stepx,
272                                uint8* dst_argb, int dst_width);
273 void ScaleARGBRowDownEvenBox_NEON(const uint8* src_argb, int src_stride,
274                                   int src_stepx,
275                                   uint8* dst_argb, int dst_width);
276 void ScaleARGBRowDown2_NEON(const uint8* src_ptr, ptrdiff_t src_stride,
277                             uint8* dst, int dst_width);
278 void ScaleARGBRowDown2Box_NEON(const uint8* src_ptr, ptrdiff_t src_stride,
279                                uint8* dst, int dst_width);
280
281 // ScaleRowDown2Box also used by planar functions
282 // NEON downscalers with interpolation.
283
284 // Note - not static due to reuse in convert for 444 to 420.
285 void ScaleRowDown2_NEON(const uint8* src_ptr, ptrdiff_t src_stride,
286                         uint8* dst, int dst_width);
287
288 void ScaleRowDown2Box_NEON(const uint8* src_ptr, ptrdiff_t src_stride,
289                            uint8* dst, int dst_width);
290
291 void ScaleRowDown4_NEON(const uint8* src_ptr, ptrdiff_t src_stride,
292                         uint8* dst_ptr, int dst_width);
293 void ScaleRowDown4Box_NEON(const uint8* src_ptr, ptrdiff_t src_stride,
294                            uint8* dst_ptr, int dst_width);
295
296 // Down scale from 4 to 3 pixels. Use the neon multilane read/write
297 //  to load up the every 4th pixel into a 4 different registers.
298 // Point samples 32 pixels to 24 pixels.
299 void ScaleRowDown34_NEON(const uint8* src_ptr,
300                          ptrdiff_t src_stride,
301                          uint8* dst_ptr, int dst_width);
302 void ScaleRowDown34_0_Box_NEON(const uint8* src_ptr,
303                                ptrdiff_t src_stride,
304                                uint8* dst_ptr, int dst_width);
305 void ScaleRowDown34_1_Box_NEON(const uint8* src_ptr,
306                                ptrdiff_t src_stride,
307                                uint8* dst_ptr, int dst_width);
308
309 // 32 -> 12
310 void ScaleRowDown38_NEON(const uint8* src_ptr,
311                          ptrdiff_t src_stride,
312                          uint8* dst_ptr, int dst_width);
313 // 32x3 -> 12x1
314 void ScaleRowDown38_3_Box_NEON(const uint8* src_ptr,
315                                ptrdiff_t src_stride,
316                                uint8* dst_ptr, int dst_width);
317 // 32x2 -> 12x1
318 void ScaleRowDown38_2_Box_NEON(const uint8* src_ptr,
319                                ptrdiff_t src_stride,
320                                uint8* dst_ptr, int dst_width);
321
322 void ScaleRowDown2_MIPS_DSPR2(const uint8* src_ptr, ptrdiff_t src_stride,
323                               uint8* dst, int dst_width);
324 void ScaleRowDown2Box_MIPS_DSPR2(const uint8* src_ptr, ptrdiff_t src_stride,
325                                  uint8* dst, int dst_width);
326 void ScaleRowDown4_MIPS_DSPR2(const uint8* src_ptr, ptrdiff_t src_stride,
327                               uint8* dst, int dst_width);
328 void ScaleRowDown4Box_MIPS_DSPR2(const uint8* src_ptr, ptrdiff_t src_stride,
329                                  uint8* dst, int dst_width);
330 void ScaleRowDown34_MIPS_DSPR2(const uint8* src_ptr, ptrdiff_t src_stride,
331                                uint8* dst, int dst_width);
332 void ScaleRowDown34_0_Box_MIPS_DSPR2(const uint8* src_ptr, ptrdiff_t src_stride,
333                                      uint8* d, int dst_width);
334 void ScaleRowDown34_1_Box_MIPS_DSPR2(const uint8* src_ptr, ptrdiff_t src_stride,
335                                      uint8* d, int dst_width);
336 void ScaleRowDown38_MIPS_DSPR2(const uint8* src_ptr, ptrdiff_t src_stride,
337                                uint8* dst, int dst_width);
338 void ScaleRowDown38_2_Box_MIPS_DSPR2(const uint8* src_ptr, ptrdiff_t src_stride,
339                                      uint8* dst_ptr, int dst_width);
340 void ScaleRowDown38_3_Box_MIPS_DSPR2(const uint8* src_ptr,
341                                      ptrdiff_t src_stride,
342                                      uint8* dst_ptr, int dst_width);
343
344 #ifdef __cplusplus
345 }  // extern "C"
346 }  // namespace libyuv
347 #endif
348
349 #endif  // INCLUDE_LIBYUV_SCALE_ROW_H_  NOLINT