Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: webrtc/modules/video_coding/utility/quality_scaler.h

Issue 2652893015: Rename adaptation api methods, extended vie_encoder unit test. (Closed)
Patch Set: Rebase, again Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | webrtc/modules/video_coding/utility/quality_scaler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <utility> 14 #include <utility>
15 15
16 #include "webrtc/common_types.h" 16 #include "webrtc/common_types.h"
17 #include "webrtc/video_encoder.h" 17 #include "webrtc/video_encoder.h"
18 #include "webrtc/base/optional.h" 18 #include "webrtc/base/optional.h"
19 #include "webrtc/base/sequenced_task_checker.h" 19 #include "webrtc/base/sequenced_task_checker.h"
20 #include "webrtc/modules/video_coding/utility/moving_average.h" 20 #include "webrtc/modules/video_coding/utility/moving_average.h"
21 21
22 namespace webrtc { 22 namespace webrtc {
23 23
24 // An interface for a class that receives scale up/down requests. 24 // An interface for signaling requests to limit or increase the resolution or
25 class ScalingObserverInterface { 25 // framerate of the captured video stream.
26 class AdaptationObserverInterface {
26 public: 27 public:
27 enum ScaleReason : size_t { kQuality = 0, kCpu = 1 }; 28 // Indicates if the adaptation is due to overuse of the CPU resources, or if
29 // the quality of the encoded frames have dropped too low.
30 enum AdaptReason : size_t { kQuality = 0, kCpu = 1 };
28 static const size_t kScaleReasonSize = 2; 31 static const size_t kScaleReasonSize = 2;
29 // Called to signal that we can handle larger frames. 32 // Called to signal that we can handle larger or more frequent frames.
30 virtual void ScaleUp(ScaleReason reason) = 0; 33 virtual void AdaptUp(AdaptReason reason) = 0;
31 // Called to signal that encoder to scale down. 34 // Called to signal that the source should reduce the resolution or framerate.
32 virtual void ScaleDown(ScaleReason reason) = 0; 35 virtual void AdaptDown(AdaptReason reason) = 0;
33 36
34 protected: 37 protected:
35 virtual ~ScalingObserverInterface() {} 38 virtual ~AdaptationObserverInterface() {}
36 }; 39 };
37 40
38 // QualityScaler runs asynchronously and monitors QP values of encoded frames. 41 // QualityScaler runs asynchronously and monitors QP values of encoded frames.
39 // It holds a reference to a ScalingObserverInterface implementation to signal 42 // It holds a reference to a ScalingObserverInterface implementation to signal
40 // an intent to scale up or down. 43 // an intent to scale up or down.
41 class QualityScaler { 44 class QualityScaler {
42 public: 45 public:
43 // Construct a QualityScaler with a given |observer|. 46 // Construct a QualityScaler with a given |observer|.
44 // This starts the quality scaler periodically checking what the average QP 47 // This starts the quality scaler periodically checking what the average QP
45 // has been recently. 48 // has been recently.
46 QualityScaler(ScalingObserverInterface* observer, VideoCodecType codec_type); 49 QualityScaler(AdaptationObserverInterface* observer,
50 VideoCodecType codec_type);
47 // If specific thresholds are desired these can be supplied as |thresholds|. 51 // If specific thresholds are desired these can be supplied as |thresholds|.
48 QualityScaler(ScalingObserverInterface* observer, 52 QualityScaler(AdaptationObserverInterface* observer,
49 VideoEncoder::QpThresholds thresholds); 53 VideoEncoder::QpThresholds thresholds);
50 virtual ~QualityScaler(); 54 virtual ~QualityScaler();
51 // Should be called each time the encoder drops a frame 55 // Should be called each time the encoder drops a frame
52 void ReportDroppedFrame(); 56 void ReportDroppedFrame();
53 // Inform the QualityScaler of the last seen QP. 57 // Inform the QualityScaler of the last seen QP.
54 void ReportQP(int qp); 58 void ReportQP(int qp);
55 59
56 // The following members declared protected for testing purposes 60 // The following members declared protected for testing purposes
57 protected: 61 protected:
58 QualityScaler(ScalingObserverInterface* observer, 62 QualityScaler(AdaptationObserverInterface* observer,
59 VideoEncoder::QpThresholds thresholds, 63 VideoEncoder::QpThresholds thresholds,
60 int64_t sampling_period); 64 int64_t sampling_period);
61 65
62 private: 66 private:
63 class CheckQPTask; 67 class CheckQPTask;
64 void CheckQP(); 68 void CheckQP();
65 void ClearSamples(); 69 void ClearSamples();
66 void ReportQPLow(); 70 void ReportQPLow();
67 void ReportQPHigh(); 71 void ReportQPHigh();
68 int64_t GetSamplingPeriodMs() const; 72 int64_t GetSamplingPeriodMs() const;
69 73
70 CheckQPTask* check_qp_task_ GUARDED_BY(&task_checker_); 74 CheckQPTask* check_qp_task_ GUARDED_BY(&task_checker_);
71 ScalingObserverInterface* const observer_ GUARDED_BY(&task_checker_); 75 AdaptationObserverInterface* const observer_ GUARDED_BY(&task_checker_);
72 rtc::SequencedTaskChecker task_checker_; 76 rtc::SequencedTaskChecker task_checker_;
73 77
74 const int64_t sampling_period_ms_; 78 const int64_t sampling_period_ms_;
75 bool fast_rampup_ GUARDED_BY(&task_checker_); 79 bool fast_rampup_ GUARDED_BY(&task_checker_);
76 MovingAverage average_qp_ GUARDED_BY(&task_checker_); 80 MovingAverage average_qp_ GUARDED_BY(&task_checker_);
77 MovingAverage framedrop_percent_ GUARDED_BY(&task_checker_); 81 MovingAverage framedrop_percent_ GUARDED_BY(&task_checker_);
78 82
79 VideoEncoder::QpThresholds thresholds_ GUARDED_BY(&task_checker_); 83 VideoEncoder::QpThresholds thresholds_ GUARDED_BY(&task_checker_);
80 }; 84 };
81 } // namespace webrtc 85 } // namespace webrtc
82 86
83 #endif // WEBRTC_MODULES_VIDEO_CODING_UTILITY_QUALITY_SCALER_H_ 87 #endif // WEBRTC_MODULES_VIDEO_CODING_UTILITY_QUALITY_SCALER_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/video_coding/utility/quality_scaler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698