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 // Scales a YUV 4:2:0 image from the src width and height to the 53 // dst width and height. 54 // If filtering is kFilterNone, a simple nearest-neighbor algorithm is 55 // used. This produces basic (blocky) quality at the fastest speed. 56 // If filtering is kFilterBilinear, interpolation is used to produce a better 57 // quality image, at the expense of speed. 58 // If filtering is kFilterBox, averaging is used to produce ever better 59 // quality image, at further expense of speed. 60 // Returns 0 if successful. 61 62 LIBYUV_API 63 int I420Scale(const uint8_t* src_y, 64 int src_stride_y, 65 const uint8_t* src_u, 66 int src_stride_u, 67 const uint8_t* src_v, 68 int src_stride_v, 69 int src_width, 70 int src_height, 71 uint8_t* dst_y, 72 int dst_stride_y, 73 uint8_t* dst_u, 74 int dst_stride_u, 75 uint8_t* dst_v, 76 int dst_stride_v, 77 int dst_width, 78 int dst_height, 79 enum FilterMode filtering); 80 81 LIBYUV_API 82 int I420Scale_16(const uint16_t* src_y, 83 int src_stride_y, 84 const uint16_t* src_u, 85 int src_stride_u, 86 const uint16_t* src_v, 87 int src_stride_v, 88 int src_width, 89 int src_height, 90 uint16_t* dst_y, 91 int dst_stride_y, 92 uint16_t* dst_u, 93 int dst_stride_u, 94 uint16_t* dst_v, 95 int dst_stride_v, 96 int dst_width, 97 int dst_height, 98 enum FilterMode filtering); 99 100 // Scales a YUV 4:4:4 image from the src width and height to the 101 // dst width and height. 102 // If filtering is kFilterNone, a simple nearest-neighbor algorithm is 103 // used. This produces basic (blocky) quality at the fastest speed. 104 // If filtering is kFilterBilinear, interpolation is used to produce a better 105 // quality image, at the expense of speed. 106 // If filtering is kFilterBox, averaging is used to produce ever better 107 // quality image, at further expense of speed. 108 // Returns 0 if successful. 109 110 LIBYUV_API 111 int I444Scale(const uint8_t* src_y, 112 int src_stride_y, 113 const uint8_t* src_u, 114 int src_stride_u, 115 const uint8_t* src_v, 116 int src_stride_v, 117 int src_width, 118 int src_height, 119 uint8_t* dst_y, 120 int dst_stride_y, 121 uint8_t* dst_u, 122 int dst_stride_u, 123 uint8_t* dst_v, 124 int dst_stride_v, 125 int dst_width, 126 int dst_height, 127 enum FilterMode filtering); 128 129 LIBYUV_API 130 int I444Scale_16(const uint16_t* src_y, 131 int src_stride_y, 132 const uint16_t* src_u, 133 int src_stride_u, 134 const uint16_t* src_v, 135 int src_stride_v, 136 int src_width, 137 int src_height, 138 uint16_t* dst_y, 139 int dst_stride_y, 140 uint16_t* dst_u, 141 int dst_stride_u, 142 uint16_t* dst_v, 143 int dst_stride_v, 144 int dst_width, 145 int dst_height, 146 enum FilterMode filtering); 147 148 #ifdef __cplusplus 149 // Legacy API. Deprecated. 150 LIBYUV_API 151 int Scale(const uint8_t* src_y, 152 const uint8_t* src_u, 153 const uint8_t* src_v, 154 int src_stride_y, 155 int src_stride_u, 156 int src_stride_v, 157 int src_width, 158 int src_height, 159 uint8_t* dst_y, 160 uint8_t* dst_u, 161 uint8_t* dst_v, 162 int dst_stride_y, 163 int dst_stride_u, 164 int dst_stride_v, 165 int dst_width, 166 int dst_height, 167 LIBYUV_BOOL interpolate); 168 169 // For testing, allow disabling of specialized scalers. 170 LIBYUV_API 171 void SetUseReferenceImpl(LIBYUV_BOOL use); 172 #endif // __cplusplus 173 174 #ifdef __cplusplus 175 } // extern "C" 176 } // namespace libyuv 177 #endif 178 179 #endif // INCLUDE_LIBYUV_SCALE_H_ 180