1/* 2 * Copyright (c) 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 16namespace libyuv { 17 18// Supported filtering 19enum FilterMode { 20 kFilterNone = 0, // Point sample; Fastest 21 kFilterBilinear = 1, // Faster than box, but lower quality scaling down. 22 kFilterBox = 2 // Highest quality 23}; 24 25// Scales a YUV 4:2:0 image from the src width and height to the 26// dst width and height. 27// If filtering is kFilterNone, a simple nearest-neighbor algorithm is 28// used. This produces basic (blocky) quality at the fastest speed. 29// If filtering is kFilterBilinear, interpolation is used to produce a better 30// quality image, at the expense of speed. 31// If filtering is kFilterBox, averaging is used to produce ever better 32// quality image, at further expense of speed. 33// Returns 0 if successful. 34 35int I420Scale(const uint8* src_y, int src_stride_y, 36 const uint8* src_u, int src_stride_u, 37 const uint8* src_v, int src_stride_v, 38 int src_width, int src_height, 39 uint8* dst_y, int dst_stride_y, 40 uint8* dst_u, int dst_stride_u, 41 uint8* dst_v, int dst_stride_v, 42 int dst_width, int dst_height, 43 FilterMode filtering); 44 45// Legacy API 46// If dst_height_offset is non-zero, the image is offset by that many pixels 47// and stretched to (dst_height - dst_height_offset * 2) pixels high, 48// instead of dst_height. 49int Scale(const uint8* src, int src_width, int src_height, 50 uint8* dst, int dst_width, int dst_height, int dst_height_offset, 51 bool interpolate); 52 53// Same, but specified src terms of each plane location and stride. 54int Scale(const uint8* src_y, const uint8* src_u, const uint8* src_v, 55 int src_stride_y, int src_stride_u, int src_stride_v, 56 int src_width, int src_height, 57 uint8* dst_y, uint8* dst_u, uint8* dst_v, 58 int dst_stride_y, int dst_stride_u, int dst_stride_v, 59 int dst_width, int dst_height, 60 bool interpolate); 61 62// For testing, allow disabling of optimizations. 63void SetUseReferenceImpl(bool use); 64 65} // namespace libyuv 66 67#endif // INCLUDE_LIBYUV_SCALE_H_ 68