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_  // NOLINT
12#define INCLUDE_LIBYUV_SCALE_H_
13
14#include "libyuv/basic_types.h"
15
16#ifdef __cplusplus
17namespace libyuv {
18extern "C" {
19#endif
20
21// Supported filtering
22enum FilterMode {
23  kFilterNone = 0,  // Point sample; Fastest.
24  kFilterBilinear = 1,  // Faster than box, but lower quality scaling down.
25  kFilterBox = 2  // Highest quality.
26};
27
28// Scale a YUV plane.
29LIBYUV_API
30void ScalePlane(const uint8* src, int src_stride,
31                int src_width, int src_height,
32                uint8* dst, int dst_stride,
33                int dst_width, int dst_height,
34                FilterMode filtering);
35
36// Scales a YUV 4:2:0 image from the src width and height to the
37// dst width and height.
38// If filtering is kFilterNone, a simple nearest-neighbor algorithm is
39// used. This produces basic (blocky) quality at the fastest speed.
40// If filtering is kFilterBilinear, interpolation is used to produce a better
41// quality image, at the expense of speed.
42// If filtering is kFilterBox, averaging is used to produce ever better
43// quality image, at further expense of speed.
44// Returns 0 if successful.
45
46LIBYUV_API
47int I420Scale(const uint8* src_y, int src_stride_y,
48              const uint8* src_u, int src_stride_u,
49              const uint8* src_v, int src_stride_v,
50              int src_width, int src_height,
51              uint8* dst_y, int dst_stride_y,
52              uint8* dst_u, int dst_stride_u,
53              uint8* dst_v, int dst_stride_v,
54              int dst_width, int dst_height,
55              FilterMode filtering);
56
57// Legacy API.  Deprecated.
58LIBYUV_API
59int Scale(const uint8* src_y, const uint8* src_u, const uint8* src_v,
60          int src_stride_y, int src_stride_u, int src_stride_v,
61          int src_width, int src_height,
62          uint8* dst_y, uint8* dst_u, uint8* dst_v,
63          int dst_stride_y, int dst_stride_u, int dst_stride_v,
64          int dst_width, int dst_height,
65          bool interpolate);
66
67// Legacy API.  Deprecated.
68LIBYUV_API
69int ScaleOffset(const uint8* src, int src_width, int src_height,
70                uint8* dst, int dst_width, int dst_height, int dst_yoffset,
71                bool interpolate);
72
73// For testing, allow disabling of specialized scalers.
74LIBYUV_API
75void SetUseReferenceImpl(bool use);
76
77#ifdef __cplusplus
78}  // extern "C"
79}  // namespace libyuv
80#endif
81
82#endif  // INCLUDE_LIBYUV_SCALE_H_  NOLINT
83