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

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

Issue 2309743002: Move the QP scaling thresholds to the relevant encoders (Closed)
Patch Set: rebase Created 4 years, 3 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
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 "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();
26 void Init(int low_qp_threshold, 27 void Init(VideoCodecType codec_type,
27 int high_qp_threshold,
28 int initial_bitrate_kbps, 28 int initial_bitrate_kbps,
29 int width, 29 int width,
30 int height, 30 int height,
31 int fps); 31 int fps);
32 void Init(VideoCodecType codec_type,
33 int initial_bitrate_kbps,
34 int width,
35 int height,
36 int fps,
37 int highQpThreshold,
pbos-webrtc 2016/09/19 14:06:57 hiqh_qp_threshold, low_qp_threshold
38 int lowQpThreshold);
32 void ReportFramerate(int framerate); 39 void ReportFramerate(int framerate);
33 void ReportQP(int qp); 40 void ReportQP(int qp);
34 void ReportDroppedFrame(); 41 void ReportDroppedFrame();
35 void OnEncodeFrame(int width, int height); 42 void OnEncodeFrame(int width, int height);
36 Resolution GetScaledResolution() const; 43 Resolution GetScaledResolution() const;
37 rtc::scoped_refptr<VideoFrameBuffer> GetScaledBuffer( 44 rtc::scoped_refptr<VideoFrameBuffer> GetScaledBuffer(
38 const rtc::scoped_refptr<VideoFrameBuffer>& frame); 45 const rtc::scoped_refptr<VideoFrameBuffer>& frame);
39 int downscale_shift() const { return downscale_shift_; } 46 int downscale_shift() const { return downscale_shift_; }
40 47
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: 48 private:
51 void ClearSamples(); 49 void ClearSamples();
52 void ScaleUp(); 50 void ScaleUp();
53 void ScaleDown(); 51 void ScaleDown();
54 void UpdateTargetResolution(int width, int height); 52 void UpdateTargetResolution(int width, int height);
55 53
56 I420BufferPool pool_; 54 I420BufferPool pool_;
57 55
58 size_t num_samples_downscale_; 56 size_t num_samples_downscale_;
59 size_t num_samples_upscale_; 57 size_t num_samples_upscale_;
60 bool fast_rampup_; 58 bool fast_rampup_;
61 MovingAverage average_qp_; 59 MovingAverage average_qp_;
62 MovingAverage framedrop_percent_; 60 MovingAverage framedrop_percent_;
63 61
64 int low_qp_threshold_; 62 int low_qp_threshold_;
65 int high_qp_threshold_; 63 int high_qp_threshold_;
66 Resolution target_res_; 64 Resolution target_res_;
67 65
68 int downscale_shift_; 66 int downscale_shift_;
69 int maximum_shift_; 67 int maximum_shift_;
70 }; 68 };
71 69
72 } // namespace webrtc 70 } // namespace webrtc
73 71
74 #endif // WEBRTC_MODULES_VIDEO_CODING_UTILITY_QUALITY_SCALER_H_ 72 #endif // WEBRTC_MODULES_VIDEO_CODING_UTILITY_QUALITY_SCALER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698