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_types.h" |
14 #include "webrtc/common_video/include/i420_buffer_pool.h" | 15 #include "webrtc/common_video/include/i420_buffer_pool.h" |
15 #include "webrtc/modules/video_coding/utility/moving_average.h" | 16 #include "webrtc/modules/video_coding/utility/moving_average.h" |
16 | 17 |
17 namespace webrtc { | 18 namespace webrtc { |
18 class QualityScaler { | 19 class QualityScaler { |
19 public: | 20 public: |
20 struct Resolution { | 21 struct Resolution { |
21 int width; | 22 int width; |
22 int height; | 23 int height; |
23 }; | 24 }; |
24 | 25 |
25 QualityScaler(); | 26 QualityScaler(); |
| 27 void Init(VideoCodecType codec_type, |
| 28 int initial_bitrate_kbps, |
| 29 int width, |
| 30 int height, |
| 31 int fps); |
26 void Init(int low_qp_threshold, | 32 void Init(int low_qp_threshold, |
27 int high_qp_threshold, | 33 int high_qp_threshold, |
28 int initial_bitrate_kbps, | 34 int initial_bitrate_kbps, |
29 int width, | 35 int width, |
30 int height, | 36 int height, |
31 int fps); | 37 int fps); |
32 void ReportFramerate(int framerate); | 38 void ReportFramerate(int framerate); |
33 void ReportQP(int qp); | 39 void ReportQP(int qp); |
34 void ReportDroppedFrame(); | 40 void ReportDroppedFrame(); |
35 void OnEncodeFrame(int width, int height); | 41 void OnEncodeFrame(int width, int height); |
36 Resolution GetScaledResolution() const; | 42 Resolution GetScaledResolution() const; |
37 rtc::scoped_refptr<VideoFrameBuffer> GetScaledBuffer( | 43 rtc::scoped_refptr<VideoFrameBuffer> GetScaledBuffer( |
38 const rtc::scoped_refptr<VideoFrameBuffer>& frame); | 44 const rtc::scoped_refptr<VideoFrameBuffer>& frame); |
39 int downscale_shift() const { return downscale_shift_; } | 45 int downscale_shift() const { return downscale_shift_; } |
40 | 46 |
41 // QP is obtained from VP8-bitstream for HW, so the QP corresponds to the | |
42 // bitstream range of [0, 127] and not the user-level range of [0,63]. | |
43 static const int kLowVp8QpThreshold; | |
44 static const int kBadVp8QpThreshold; | |
45 | |
46 // H264 QP is in the range [0, 51]. | |
47 static const int kLowH264QpThreshold; | |
48 static const int kBadH264QpThreshold; | |
49 | |
50 private: | 47 private: |
51 void ClearSamples(); | 48 void ClearSamples(); |
52 void ScaleUp(); | 49 void ScaleUp(); |
53 void ScaleDown(); | 50 void ScaleDown(); |
54 void UpdateTargetResolution(int width, int height); | 51 void UpdateTargetResolution(int width, int height); |
55 | 52 |
56 I420BufferPool pool_; | 53 I420BufferPool pool_; |
57 | 54 |
58 size_t num_samples_downscale_; | 55 size_t num_samples_downscale_; |
59 size_t num_samples_upscale_; | 56 size_t num_samples_upscale_; |
60 bool fast_rampup_; | 57 bool fast_rampup_; |
61 MovingAverage average_qp_; | 58 MovingAverage average_qp_; |
62 MovingAverage framedrop_percent_; | 59 MovingAverage framedrop_percent_; |
63 | 60 |
64 int low_qp_threshold_; | 61 int low_qp_threshold_; |
65 int high_qp_threshold_; | 62 int high_qp_threshold_; |
66 Resolution target_res_; | 63 Resolution target_res_; |
67 | 64 |
68 int downscale_shift_; | 65 int downscale_shift_; |
69 int maximum_shift_; | 66 int maximum_shift_; |
70 }; | 67 }; |
71 | 68 |
72 } // namespace webrtc | 69 } // namespace webrtc |
73 | 70 |
74 #endif // WEBRTC_MODULES_VIDEO_CODING_UTILITY_QUALITY_SCALER_H_ | 71 #endif // WEBRTC_MODULES_VIDEO_CODING_UTILITY_QUALITY_SCALER_H_ |
OLD | NEW |