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

Side by Side Diff: webrtc/modules/video_coding/codecs/vp8/screenshare_layers.h

Issue 1193513006: In screenshare mode, suppress VP8 bitrate overshoot and increase quality (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebase Created 5 years, 6 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 /* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 1 /* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
2 * 2 *
3 * Use of this source code is governed by a BSD-style license 3 * Use of this source code is governed by a BSD-style license
4 * that can be found in the LICENSE file in the root of the source 4 * that can be found in the LICENSE file in the root of the source
5 * tree. An additional intellectual property rights grant can be found 5 * tree. An additional intellectual property rights grant can be found
6 * in the file PATENTS. All contributing project authors may 6 * in the file PATENTS. All contributing project authors may
7 * be found in the AUTHORS file in the root of the source tree. 7 * be found in the AUTHORS file in the root of the source tree.
8 */ 8 */
9 #ifndef WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_SCREENSHARE_LAYERS_H_ 9 #ifndef WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_SCREENSHARE_LAYERS_H_
10 #define WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_SCREENSHARE_LAYERS_H_ 10 #define WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_SCREENSHARE_LAYERS_H_
11 11
12 #include <list> 12 #include <list>
13 13
14 #include "vpx/vpx_encoder.h" 14 #include "vpx/vpx_encoder.h"
15 15
16 #include "webrtc/base/timeutils.h"
16 #include "webrtc/modules/video_coding/codecs/vp8/temporal_layers.h" 17 #include "webrtc/modules/video_coding/codecs/vp8/temporal_layers.h"
17 #include "webrtc/modules/video_coding/utility/include/frame_dropper.h" 18 #include "webrtc/modules/video_coding/utility/include/frame_dropper.h"
18 #include "webrtc/typedefs.h" 19 #include "webrtc/typedefs.h"
19 20
20 namespace webrtc { 21 namespace webrtc {
21 22
22 struct CodecSpecificInfoVP8; 23 struct CodecSpecificInfoVP8;
23 24
24 class ScreenshareLayers : public TemporalLayers { 25 class ScreenshareLayers : public TemporalLayers {
25 public: 26 public:
26 static const double kMaxTL0FpsReduction; 27 static const double kMaxTL0FpsReduction;
27 static const double kAcceptableTargetOvershoot; 28 static const double kAcceptableTargetOvershoot;
29 static const int kTl0Flags;
30 static const int kTl1Flags;
31 static const int kTl1SyncFlags;
28 32
29 ScreenshareLayers(int num_temporal_layers, 33 ScreenshareLayers(int num_temporal_layers, uint8_t initial_tl0_pic_idx);
30 uint8_t initial_tl0_pic_idx,
31 FrameDropper* tl0_frame_dropper,
32 FrameDropper* tl1_frame_dropper);
33 virtual ~ScreenshareLayers() {} 34 virtual ~ScreenshareLayers() {}
34 35
35 // Returns the recommended VP8 encode flags needed. May refresh the decoder 36 // Returns the recommended VP8 encode flags needed. May refresh the decoder
36 // and/or update the reference buffers. 37 // and/or update the reference buffers.
37 virtual int EncodeFlags(uint32_t timestamp); 38 int EncodeFlags(uint32_t timestamp) override;
38 39
39 virtual bool ConfigureBitrates(int bitrate_kbit, 40 bool ConfigureBitrates(int bitrate_kbps,
40 int max_bitrate_kbit, 41 int max_bitrate_kbps,
41 int framerate, 42 int framerate,
42 vpx_codec_enc_cfg_t* cfg); 43 vpx_codec_enc_cfg_t* cfg) override;
43 44
44 virtual void PopulateCodecSpecific(bool base_layer_sync, 45 void PopulateCodecSpecific(bool base_layer_sync,
45 CodecSpecificInfoVP8 *vp8_info, 46 CodecSpecificInfoVP8* vp8_info,
46 uint32_t timestamp); 47 uint32_t timestamp) override;
47 48
48 virtual void FrameEncoded(unsigned int size, uint32_t timestamp); 49 void FrameEncoded(unsigned int size, uint32_t timestamp, int qp) override;
49 50
50 virtual int CurrentLayerId() const; 51 int CurrentLayerId() const override;
52
53 // Allows the layers adapter to update the encoder configuration prior to a
54 // frame being encoded. Return true if the configuration should be updated
55 // and false if now change is needed.
56 bool UpdateConfiguration(vpx_codec_enc_cfg_t* cfg) override;
51 57
52 private: 58 private:
53 void CalculateFramerate(uint32_t timestamp); 59 bool TimeToSync(int64_t timestamp) const;
54 bool TimeToSync(uint32_t timestamp) const;
55 60
56 FrameDropper* tl0_frame_dropper_;
57 FrameDropper* tl1_frame_dropper_;
58 int number_of_temporal_layers_; 61 int number_of_temporal_layers_;
59 bool last_base_layer_sync_; 62 bool last_base_layer_sync_;
60 uint8_t tl0_pic_idx_; 63 uint8_t tl0_pic_idx_;
61 int active_layer_; 64 int active_layer_;
62 std::list<uint32_t> timestamp_list_; 65 int64_t last_timestamp_;
63 int framerate_;
64 int64_t last_sync_timestamp_; 66 int64_t last_sync_timestamp_;
67 rtc::TimestampWrapAroundHandler time_wrap_handler_;
68 int min_qp_;
69 int max_qp_;
70 uint32_t max_debt_bytes_;
71 int frame_rate_;
72
73 static const int kMaxNumTemporalLayers = 2;
74 struct TemporalLayer {
75 TemporalLayer()
76 : state(State::kNormal),
77 enhanced_max_qp(-1),
78 last_qp(-1),
79 debt_bytes_(0),
80 target_rate_kbps_(0) {}
81
82 enum class State {
83 kNormal,
84 kDropped,
85 kReencoded,
86 kQualityBoost,
87 } state;
88
89 int enhanced_max_qp;
90 int last_qp;
91 uint32_t debt_bytes_;
92 uint32_t target_rate_kbps_;
93
94 void UpdateDebt(int64_t delta_ms);
95 } layers_[kMaxNumTemporalLayers];
65 }; 96 };
66 } // namespace webrtc 97 } // namespace webrtc
67 98
68 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_SCREENSHARE_LAYERS_H_ 99 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_SCREENSHARE_LAYERS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698