| 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/moving_average.h" | 15 #include "webrtc/modules/video_coding/utility/moving_average.h" |
| 16 | 16 |
| 17 namespace webrtc { | 17 namespace webrtc { |
| 18 class QualityScaler { | 18 class QualityScaler { |
| 19 public: | 19 public: |
| 20 struct Resolution { | 20 struct Resolution { |
| 21 int width; | 21 int width; |
| 22 int height; | 22 int height; |
| 23 }; | 23 }; |
| 24 | 24 |
| 25 QualityScaler(); | 25 QualityScaler(); |
| 26 void Init(int low_qp_threshold, | 26 void Init(int low_qp_threshold, |
| 27 int high_qp_threshold, | 27 int high_qp_threshold, |
| 28 bool use_framerate_reduction, | |
| 29 int initial_bitrate_kbps, | 28 int initial_bitrate_kbps, |
| 30 int width, | 29 int width, |
| 31 int height, | 30 int height, |
| 32 int fps); | 31 int fps); |
| 33 void ReportFramerate(int framerate); | 32 void ReportFramerate(int framerate); |
| 34 void ReportQP(int qp); | 33 void ReportQP(int qp); |
| 35 void ReportDroppedFrame(); | 34 void ReportDroppedFrame(); |
| 36 void Reset(int framerate, int bitrate, int width, int height); | |
| 37 void OnEncodeFrame(const VideoFrame& frame); | 35 void OnEncodeFrame(const VideoFrame& frame); |
| 38 Resolution GetScaledResolution() const; | 36 Resolution GetScaledResolution() const; |
| 39 const VideoFrame& GetScaledFrame(const VideoFrame& frame); | 37 const VideoFrame& GetScaledFrame(const VideoFrame& frame); |
| 40 int GetTargetFramerate() const; | |
| 41 int downscale_shift() const { return downscale_shift_; } | 38 int downscale_shift() const { return downscale_shift_; } |
| 42 | 39 |
| 43 private: | 40 private: |
| 44 void AdjustScale(bool up); | 41 void AdjustScale(bool up); |
| 45 void UpdateTargetResolution(int frame_width, int frame_height); | 42 void UpdateTargetResolution(int frame_width, int frame_height); |
| 46 void ClearSamples(); | 43 void ClearSamples(); |
| 47 void UpdateSampleCounts(); | 44 void UpdateSampleCounts(); |
| 48 | 45 |
| 49 Scaler scaler_; | 46 Scaler scaler_; |
| 50 VideoFrame scaled_frame_; | 47 VideoFrame scaled_frame_; |
| 51 | 48 |
| 52 size_t num_samples_downscale_; | 49 size_t num_samples_downscale_; |
| 53 size_t num_samples_upscale_; | 50 size_t num_samples_upscale_; |
| 54 int measure_seconds_upscale_; | 51 int measure_seconds_upscale_; |
| 55 MovingAverage<int> average_qp_upscale_; | 52 MovingAverage<int> average_qp_upscale_; |
| 56 MovingAverage<int> average_qp_downscale_; | 53 MovingAverage<int> average_qp_downscale_; |
| 57 | 54 |
| 58 int framerate_; | 55 int framerate_; |
| 59 int target_framerate_; | |
| 60 int low_qp_threshold_; | 56 int low_qp_threshold_; |
| 61 int high_qp_threshold_; | 57 int high_qp_threshold_; |
| 62 MovingAverage<int> framedrop_percent_; | 58 MovingAverage<int> framedrop_percent_; |
| 63 Resolution res_; | 59 Resolution res_; |
| 64 | 60 |
| 65 int downscale_shift_; | 61 int downscale_shift_; |
| 66 int framerate_down_; | |
| 67 bool use_framerate_reduction_; | |
| 68 }; | 62 }; |
| 69 | 63 |
| 70 } // namespace webrtc | 64 } // namespace webrtc |
| 71 | 65 |
| 72 #endif // WEBRTC_MODULES_VIDEO_CODING_UTILITY_QUALITY_SCALER_H_ | 66 #endif // WEBRTC_MODULES_VIDEO_CODING_UTILITY_QUALITY_SCALER_H_ |
| OLD | NEW |