OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_MODULES_VIDEO_CODING_UTILITY_QUALITY_SCALER_H_ | 11 #ifndef WEBRTC_MODULES_VIDEO_CODING_UTILITY_QUALITY_SCALER_H_ |
12 #define WEBRTC_MODULES_VIDEO_CODING_UTILITY_QUALITY_SCALER_H_ | 12 #define WEBRTC_MODULES_VIDEO_CODING_UTILITY_QUALITY_SCALER_H_ |
13 | 13 |
14 #include "webrtc/common_video/libyuv/include/scaler.h" | 14 #include "webrtc/common_video/libyuv/include/scaler.h" |
15 #include "webrtc/modules/video_coding/utility/include/moving_average.h" | 15 #include "webrtc/modules/video_coding/utility/include/moving_average.h" |
16 | 16 |
17 namespace webrtc { | 17 namespace webrtc { |
18 class QualityScaler { | 18 class QualityScaler { |
19 public: | 19 public: |
20 static const int kDefaultLowQpDenominator; | 20 static const int kDefaultLowQpDenominator; |
21 static const int kDefaultMinDownscaleDimension; | 21 static const int kDefaultMinDownscaleDimension; |
22 struct Resolution { | 22 struct Resolution { |
23 int width; | 23 int width; |
24 int height; | 24 int height; |
25 }; | 25 }; |
26 | 26 |
27 QualityScaler(); | 27 QualityScaler(); |
28 void Init(int low_qp_threshold, bool use_framerate_reduction); | 28 void Init(int low_qp_threshold, |
| 29 int high_qp_threshold, |
| 30 bool use_framerate_reduction); |
29 void SetMinResolution(int min_width, int min_height); | 31 void SetMinResolution(int min_width, int min_height); |
30 void ReportFramerate(int framerate); | 32 void ReportFramerate(int framerate); |
31 void ReportQP(int qp); | 33 void ReportQP(int qp); |
32 void ReportDroppedFrame(); | 34 void ReportDroppedFrame(); |
33 void Reset(int framerate, int bitrate, int width, int height); | 35 void Reset(int framerate, int bitrate, int width, int height); |
34 void OnEncodeFrame(const VideoFrame& frame); | 36 void OnEncodeFrame(const VideoFrame& frame); |
35 Resolution GetScaledResolution() const; | 37 Resolution GetScaledResolution() const; |
36 const VideoFrame& GetScaledFrame(const VideoFrame& frame); | 38 const VideoFrame& GetScaledFrame(const VideoFrame& frame); |
37 int GetTargetFramerate() const; | 39 int GetTargetFramerate() const; |
38 | 40 |
39 private: | 41 private: |
40 void AdjustScale(bool up); | 42 void AdjustScale(bool up); |
41 void ClearSamples(); | 43 void ClearSamples(); |
42 | 44 |
43 Scaler scaler_; | 45 Scaler scaler_; |
44 VideoFrame scaled_frame_; | 46 VideoFrame scaled_frame_; |
45 | 47 |
46 size_t num_samples_; | 48 size_t num_samples_; |
47 int framerate_; | 49 int framerate_; |
48 int target_framerate_; | 50 int target_framerate_; |
49 int low_qp_threshold_; | 51 int low_qp_threshold_; |
| 52 int high_qp_threshold_; |
50 MovingAverage<int> framedrop_percent_; | 53 MovingAverage<int> framedrop_percent_; |
51 MovingAverage<int> average_qp_; | 54 MovingAverage<int> average_qp_; |
52 Resolution res_; | 55 Resolution res_; |
53 | 56 |
54 int downscale_shift_; | 57 int downscale_shift_; |
55 int framerate_down_; | 58 int framerate_down_; |
56 bool use_framerate_reduction_; | 59 bool use_framerate_reduction_; |
57 int min_width_; | 60 int min_width_; |
58 int min_height_; | 61 int min_height_; |
59 }; | 62 }; |
60 | 63 |
61 } // namespace webrtc | 64 } // namespace webrtc |
62 | 65 |
63 #endif // WEBRTC_MODULES_VIDEO_CODING_UTILITY_QUALITY_SCALER_H_ | 66 #endif // WEBRTC_MODULES_VIDEO_CODING_UTILITY_QUALITY_SCALER_H_ |
OLD | NEW |