• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/interface/i420_video_frame.h"
19 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
20 #include "webrtc/typedefs.h"
21 
22 namespace webrtc {
23 
24 // Supported scaling types
25 enum ScaleMethod {
26   kScalePoint,  // no interpolation
27   kScaleBilinear,
28   kScaleBox
29 };
30 
31 class Scaler {
32  public:
33   Scaler();
34   ~Scaler();
35 
36   // Set interpolation properties:
37   //
38   // Return value: 0 - OK
39   //              -1 - parameter error
40   int Set(int src_width, int src_height,
41           int dst_width, int dst_height,
42           VideoType src_video_type, VideoType dst_video_type,
43           ScaleMethod method);
44 
45   // Scale frame
46   // Memory is allocated by user. If dst_frame is not of sufficient size,
47   // the frame will be reallocated to the appropriate size.
48   // Return value: 0 - OK,
49   //               -1 - parameter error
50   //               -2 - scaler not set
51   int Scale(const I420VideoFrame& src_frame,
52             I420VideoFrame* dst_frame);
53 
54  private:
55   // Determine if the VideoTypes are currently supported.
56   bool SupportedVideoType(VideoType src_video_type,
57                           VideoType dst_video_type);
58 
59   ScaleMethod   method_;
60   int           src_width_;
61   int           src_height_;
62   int           dst_width_;
63   int           dst_height_;
64   bool          set_;
65 };
66 
67 }  // namespace webrtc
68 
69 #endif  // WEBRTC_COMMON_VIDEO_LIBYUV_INCLUDE_SCALER_H_
70