• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright 2011 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_H_
12 #define INCLUDE_LIBYUV_SCALE_H_
13 
14 #include "libyuv/basic_types.h"
15 
16 #ifdef __cplusplus
17 namespace libyuv {
18 extern "C" {
19 #endif
20 
21 // Supported filtering.
22 typedef enum FilterMode {
23   kFilterNone = 0,      // Point sample; Fastest.
24   kFilterLinear = 1,    // Filter horizontally only.
25   kFilterBilinear = 2,  // Faster than box, but lower quality scaling down.
26   kFilterBox = 3        // Highest quality.
27 } FilterModeEnum;
28 
29 // Scale a YUV plane.
30 LIBYUV_API
31 void ScalePlane(const uint8_t* src,
32                 int src_stride,
33                 int src_width,
34                 int src_height,
35                 uint8_t* dst,
36                 int dst_stride,
37                 int dst_width,
38                 int dst_height,
39                 enum FilterMode filtering);
40 
41 LIBYUV_API
42 void ScalePlane_16(const uint16_t* src,
43                    int src_stride,
44                    int src_width,
45                    int src_height,
46                    uint16_t* dst,
47                    int dst_stride,
48                    int dst_width,
49                    int dst_height,
50                    enum FilterMode filtering);
51 
52 // Sample is expected to be in the low 12 bits.
53 LIBYUV_API
54 void ScalePlane_12(const uint16_t* src,
55                    int src_stride,
56                    int src_width,
57                    int src_height,
58                    uint16_t* dst,
59                    int dst_stride,
60                    int dst_width,
61                    int dst_height,
62                    enum FilterMode filtering);
63 
64 // Scales a YUV 4:2:0 image from the src width and height to the
65 // dst width and height.
66 // If filtering is kFilterNone, a simple nearest-neighbor algorithm is
67 // used. This produces basic (blocky) quality at the fastest speed.
68 // If filtering is kFilterBilinear, interpolation is used to produce a better
69 // quality image, at the expense of speed.
70 // If filtering is kFilterBox, averaging is used to produce ever better
71 // quality image, at further expense of speed.
72 // Returns 0 if successful.
73 
74 LIBYUV_API
75 int I420Scale(const uint8_t* src_y,
76               int src_stride_y,
77               const uint8_t* src_u,
78               int src_stride_u,
79               const uint8_t* src_v,
80               int src_stride_v,
81               int src_width,
82               int src_height,
83               uint8_t* dst_y,
84               int dst_stride_y,
85               uint8_t* dst_u,
86               int dst_stride_u,
87               uint8_t* dst_v,
88               int dst_stride_v,
89               int dst_width,
90               int dst_height,
91               enum FilterMode filtering);
92 
93 LIBYUV_API
94 int I420Scale_16(const uint16_t* src_y,
95                  int src_stride_y,
96                  const uint16_t* src_u,
97                  int src_stride_u,
98                  const uint16_t* src_v,
99                  int src_stride_v,
100                  int src_width,
101                  int src_height,
102                  uint16_t* dst_y,
103                  int dst_stride_y,
104                  uint16_t* dst_u,
105                  int dst_stride_u,
106                  uint16_t* dst_v,
107                  int dst_stride_v,
108                  int dst_width,
109                  int dst_height,
110                  enum FilterMode filtering);
111 
112 LIBYUV_API
113 int I420Scale_12(const uint16_t* src_y,
114                  int src_stride_y,
115                  const uint16_t* src_u,
116                  int src_stride_u,
117                  const uint16_t* src_v,
118                  int src_stride_v,
119                  int src_width,
120                  int src_height,
121                  uint16_t* dst_y,
122                  int dst_stride_y,
123                  uint16_t* dst_u,
124                  int dst_stride_u,
125                  uint16_t* dst_v,
126                  int dst_stride_v,
127                  int dst_width,
128                  int dst_height,
129                  enum FilterMode filtering);
130 
131 // Scales a YUV 4:4:4 image from the src width and height to the
132 // dst width and height.
133 // If filtering is kFilterNone, a simple nearest-neighbor algorithm is
134 // used. This produces basic (blocky) quality at the fastest speed.
135 // If filtering is kFilterBilinear, interpolation is used to produce a better
136 // quality image, at the expense of speed.
137 // If filtering is kFilterBox, averaging is used to produce ever better
138 // quality image, at further expense of speed.
139 // Returns 0 if successful.
140 
141 LIBYUV_API
142 int I444Scale(const uint8_t* src_y,
143               int src_stride_y,
144               const uint8_t* src_u,
145               int src_stride_u,
146               const uint8_t* src_v,
147               int src_stride_v,
148               int src_width,
149               int src_height,
150               uint8_t* dst_y,
151               int dst_stride_y,
152               uint8_t* dst_u,
153               int dst_stride_u,
154               uint8_t* dst_v,
155               int dst_stride_v,
156               int dst_width,
157               int dst_height,
158               enum FilterMode filtering);
159 
160 LIBYUV_API
161 int I444Scale_16(const uint16_t* src_y,
162                  int src_stride_y,
163                  const uint16_t* src_u,
164                  int src_stride_u,
165                  const uint16_t* src_v,
166                  int src_stride_v,
167                  int src_width,
168                  int src_height,
169                  uint16_t* dst_y,
170                  int dst_stride_y,
171                  uint16_t* dst_u,
172                  int dst_stride_u,
173                  uint16_t* dst_v,
174                  int dst_stride_v,
175                  int dst_width,
176                  int dst_height,
177                  enum FilterMode filtering);
178 
179 LIBYUV_API
180 int I444Scale_12(const uint16_t* src_y,
181                  int src_stride_y,
182                  const uint16_t* src_u,
183                  int src_stride_u,
184                  const uint16_t* src_v,
185                  int src_stride_v,
186                  int src_width,
187                  int src_height,
188                  uint16_t* dst_y,
189                  int dst_stride_y,
190                  uint16_t* dst_u,
191                  int dst_stride_u,
192                  uint16_t* dst_v,
193                  int dst_stride_v,
194                  int dst_width,
195                  int dst_height,
196                  enum FilterMode filtering);
197 
198 // Scales a YUV 4:2:2 image from the src width and height to the
199 // dst width and height.
200 // If filtering is kFilterNone, a simple nearest-neighbor algorithm is
201 // used. This produces basic (blocky) quality at the fastest speed.
202 // If filtering is kFilterBilinear, interpolation is used to produce a better
203 // quality image, at the expense of speed.
204 // If filtering is kFilterBox, averaging is used to produce ever better
205 // quality image, at further expense of speed.
206 // Returns 0 if successful.
207 LIBYUV_API
208 int I422Scale(const uint8_t* src_y,
209               int src_stride_y,
210               const uint8_t* src_u,
211               int src_stride_u,
212               const uint8_t* src_v,
213               int src_stride_v,
214               int src_width,
215               int src_height,
216               uint8_t* dst_y,
217               int dst_stride_y,
218               uint8_t* dst_u,
219               int dst_stride_u,
220               uint8_t* dst_v,
221               int dst_stride_v,
222               int dst_width,
223               int dst_height,
224               enum FilterMode filtering);
225 
226 LIBYUV_API
227 int I422Scale_16(const uint16_t* src_y,
228                  int src_stride_y,
229                  const uint16_t* src_u,
230                  int src_stride_u,
231                  const uint16_t* src_v,
232                  int src_stride_v,
233                  int src_width,
234                  int src_height,
235                  uint16_t* dst_y,
236                  int dst_stride_y,
237                  uint16_t* dst_u,
238                  int dst_stride_u,
239                  uint16_t* dst_v,
240                  int dst_stride_v,
241                  int dst_width,
242                  int dst_height,
243                  enum FilterMode filtering);
244 
245 LIBYUV_API
246 int I422Scale_12(const uint16_t* src_y,
247                  int src_stride_y,
248                  const uint16_t* src_u,
249                  int src_stride_u,
250                  const uint16_t* src_v,
251                  int src_stride_v,
252                  int src_width,
253                  int src_height,
254                  uint16_t* dst_y,
255                  int dst_stride_y,
256                  uint16_t* dst_u,
257                  int dst_stride_u,
258                  uint16_t* dst_v,
259                  int dst_stride_v,
260                  int dst_width,
261                  int dst_height,
262                  enum FilterMode filtering);
263 
264 // Scales an NV12 image from the src width and height to the
265 // dst width and height.
266 // If filtering is kFilterNone, a simple nearest-neighbor algorithm is
267 // used. This produces basic (blocky) quality at the fastest speed.
268 // If filtering is kFilterBilinear, interpolation is used to produce a better
269 // quality image, at the expense of speed.
270 // kFilterBox is not supported for the UV channel and will be treated as
271 // bilinear.
272 // Returns 0 if successful.
273 
274 LIBYUV_API
275 int NV12Scale(const uint8_t* src_y,
276               int src_stride_y,
277               const uint8_t* src_uv,
278               int src_stride_uv,
279               int src_width,
280               int src_height,
281               uint8_t* dst_y,
282               int dst_stride_y,
283               uint8_t* dst_uv,
284               int dst_stride_uv,
285               int dst_width,
286               int dst_height,
287               enum FilterMode filtering);
288 
289 #ifdef __cplusplus
290 // Legacy API.  Deprecated.
291 LIBYUV_API
292 int Scale(const uint8_t* src_y,
293           const uint8_t* src_u,
294           const uint8_t* src_v,
295           int src_stride_y,
296           int src_stride_u,
297           int src_stride_v,
298           int src_width,
299           int src_height,
300           uint8_t* dst_y,
301           uint8_t* dst_u,
302           uint8_t* dst_v,
303           int dst_stride_y,
304           int dst_stride_u,
305           int dst_stride_v,
306           int dst_width,
307           int dst_height,
308           LIBYUV_BOOL interpolate);
309 
310 // For testing, allow disabling of specialized scalers.
311 LIBYUV_API
312 void SetUseReferenceImpl(LIBYUV_BOOL use);
313 #endif  // __cplusplus
314 
315 #ifdef __cplusplus
316 }  // extern "C"
317 }  // namespace libyuv
318 #endif
319 
320 #endif  // INCLUDE_LIBYUV_SCALE_H_
321