1 /*
2  *  Copyright (c) 2012 The WebRTC 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 /*
12  * Interface to the LibYuv scaling functionality
13  */
14 
15 #ifndef WEBRTC_COMMON_VIDEO_LIBYUV_INCLUDE_SCALER_H_
16 #define WEBRTC_COMMON_VIDEO_LIBYUV_INCLUDE_SCALER_H_
17 
18 #include "webrtc/common_video/include/i420_buffer_pool.h"
19 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
20 #include "webrtc/typedefs.h"
21 #include "webrtc/video_frame.h"
22 
23 namespace webrtc {
24 
25 // Supported scaling types
26 enum ScaleMethod {
27   kScalePoint,  // no interpolation
28   kScaleBilinear,
29   kScaleBox
30 };
31 
32 class Scaler {
33  public:
34   Scaler();
35   ~Scaler();
36 
37   // Set interpolation properties:
38   //
39   // Return value: 0 - OK
40   //              -1 - parameter error
41   int Set(int src_width, int src_height,
42           int dst_width, int dst_height,
43           VideoType src_video_type, VideoType dst_video_type,
44           ScaleMethod method);
45 
46   // Scale frame
47   // Memory is allocated by this object and recycled using |buffer_pool_|.
48   // Return value: 0 - OK,
49   //               -1 - parameter error
50   //               -2 - scaler not set
51   int Scale(const VideoFrame& src_frame, VideoFrame* dst_frame);
52 
53  private:
54   // Determine if the VideoTypes are currently supported.
55   bool SupportedVideoType(VideoType src_video_type,
56                           VideoType dst_video_type);
57 
58   ScaleMethod   method_;
59   int           src_width_;
60   int           src_height_;
61   int           dst_width_;
62   int           dst_height_;
63   bool          set_;
64   I420BufferPool buffer_pool_;
65 };
66 
67 }  // namespace webrtc
68 
69 #endif  // WEBRTC_COMMON_VIDEO_LIBYUV_INCLUDE_SCALER_H_
70