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 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* src, int src_stride, 32 int src_width, int src_height, 33 uint8* dst, int dst_stride, 34 int dst_width, int dst_height, 35 enum FilterMode filtering); 36 37 void ScalePlane_16(const uint16* src, int src_stride, 38 int src_width, int src_height, 39 uint16* dst, int dst_stride, 40 int dst_width, int dst_height, 41 enum FilterMode filtering); 42 43 // Scales a YUV 4:2:0 image from the src width and height to the 44 // dst width and height. 45 // If filtering is kFilterNone, a simple nearest-neighbor algorithm is 46 // used. This produces basic (blocky) quality at the fastest speed. 47 // If filtering is kFilterBilinear, interpolation is used to produce a better 48 // quality image, at the expense of speed. 49 // If filtering is kFilterBox, averaging is used to produce ever better 50 // quality image, at further expense of speed. 51 // Returns 0 if successful. 52 53 LIBYUV_API 54 int I420Scale(const uint8* src_y, int src_stride_y, 55 const uint8* src_u, int src_stride_u, 56 const uint8* src_v, int src_stride_v, 57 int src_width, int src_height, 58 uint8* dst_y, int dst_stride_y, 59 uint8* dst_u, int dst_stride_u, 60 uint8* dst_v, int dst_stride_v, 61 int dst_width, int dst_height, 62 enum FilterMode filtering); 63 64 LIBYUV_API 65 int I420Scale_16(const uint16* src_y, int src_stride_y, 66 const uint16* src_u, int src_stride_u, 67 const uint16* src_v, int src_stride_v, 68 int src_width, int src_height, 69 uint16* dst_y, int dst_stride_y, 70 uint16* dst_u, int dst_stride_u, 71 uint16* dst_v, int dst_stride_v, 72 int dst_width, int dst_height, 73 enum FilterMode filtering); 74 75 #ifdef __cplusplus 76 // Legacy API. Deprecated. 77 LIBYUV_API 78 int Scale(const uint8* src_y, const uint8* src_u, const uint8* src_v, 79 int src_stride_y, int src_stride_u, int src_stride_v, 80 int src_width, int src_height, 81 uint8* dst_y, uint8* dst_u, uint8* dst_v, 82 int dst_stride_y, int dst_stride_u, int dst_stride_v, 83 int dst_width, int dst_height, 84 LIBYUV_BOOL interpolate); 85 86 // Legacy API. Deprecated. 87 LIBYUV_API 88 int ScaleOffset(const uint8* src_i420, int src_width, int src_height, 89 uint8* dst_i420, int dst_width, int dst_height, int dst_yoffset, 90 LIBYUV_BOOL interpolate); 91 92 // For testing, allow disabling of specialized scalers. 93 LIBYUV_API 94 void SetUseReferenceImpl(LIBYUV_BOOL use); 95 #endif // __cplusplus 96 97 #ifdef __cplusplus 98 } // extern "C" 99 } // namespace libyuv 100 #endif 101 102 #endif // INCLUDE_LIBYUV_SCALE_H_ NOLINT 103