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

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: Tests done (?) 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/modules/video_coding/codecs/vp8/temporal_layers.h" 16 #include "webrtc/modules/video_coding/codecs/vp8/temporal_layers.h"
17 #include "webrtc/modules/video_coding/utility/include/frame_dropper.h" 17 #include "webrtc/modules/video_coding/utility/include/frame_dropper.h"
18 #include "webrtc/typedefs.h" 18 #include "webrtc/typedefs.h"
19 19
20 namespace webrtc { 20 namespace webrtc {
21 21
22 struct CodecSpecificInfoVP8; 22 struct CodecSpecificInfoVP8;
23 23
24 class ScreenshareLayers : public TemporalLayers { 24 class ScreenshareLayers : public TemporalLayers {
25 public: 25 public:
26 static const double kMaxTL0FpsReduction; 26 static const double kMaxTL0FpsReduction;
27 static const double kAcceptableTargetOvershoot; 27 static const double kAcceptableTargetOvershoot;
28 static const int kTl0Flags;
29 static const int kTl1Flags;
30 static const int kTl1SyncFlags;
28 31
29 ScreenshareLayers(int num_temporal_layers, 32 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() {} 33 virtual ~ScreenshareLayers() {}
34 34
35 // Returns the recommended VP8 encode flags needed. May refresh the decoder 35 // Returns the recommended VP8 encode flags needed. May refresh the decoder
36 // and/or update the reference buffers. 36 // and/or update the reference buffers.
37 virtual int EncodeFlags(uint32_t timestamp); 37 int EncodeFlags(uint32_t timestamp) override;
38 38
39 virtual bool ConfigureBitrates(int bitrate_kbit, 39 bool ConfigureBitrates(int bitrate_kbps,
40 int max_bitrate_kbit, 40 int max_bitrate_kbps,
41 int framerate, 41 int framerate,
42 vpx_codec_enc_cfg_t* cfg); 42 vpx_codec_enc_cfg_t* cfg) override;
43 43
44 virtual void PopulateCodecSpecific(bool base_layer_sync, 44 void PopulateCodecSpecific(bool base_layer_sync,
45 CodecSpecificInfoVP8 *vp8_info, 45 CodecSpecificInfoVP8* vp8_info,
46 uint32_t timestamp); 46 uint32_t timestamp) override;
47 47
48 virtual void FrameEncoded(unsigned int size, uint32_t timestamp); 48 void FrameEncoded(unsigned int size, uint32_t timestamp, int qp) override;
49 49
50 virtual int CurrentLayerId() const; 50 int CurrentLayerId() const override;
51
52 // Allows the layers adapter to update the encoder configuration prior to a
53 // frame being encoded. Return true if the configuration should be updated
54 // and false if now change is needed.
55 bool UpdateConfiguration(vpx_codec_enc_cfg_t* cfg) override;
51 56
52 private: 57 private:
53 void CalculateFramerate(uint32_t timestamp);
54 bool TimeToSync(uint32_t timestamp) const; 58 bool TimeToSync(uint32_t timestamp) const;
55 59
56 FrameDropper* tl0_frame_dropper_;
57 FrameDropper* tl1_frame_dropper_;
58 int number_of_temporal_layers_; 60 int number_of_temporal_layers_;
59 bool last_base_layer_sync_; 61 bool last_base_layer_sync_;
60 uint8_t tl0_pic_idx_; 62 uint8_t tl0_pic_idx_;
61 int active_layer_; 63 int active_layer_;
62 std::list<uint32_t> timestamp_list_; 64 uint32_t last_timestamp_;
63 int framerate_; 65 uint32_t last_sync_timestamp_;
64 int64_t last_sync_timestamp_; 66 int min_qp_;
67 int max_qp_;
68 uint32_t max_debt_bytes_;
69 int frame_rate_;
70
71 struct TemporalLayer {
72 TemporalLayer()
73 : state(State::kNormal),
74 enhanced_max_qp(-1),
75 last_qp(-1),
76 debt_bytes_(0),
77 target_rate_kbps_(0) {}
78
79 enum class State {
80 kNormal,
81 kDropped,
82 kReencoded,
83 kQualityBoost,
84 } state;
85
86 int enhanced_max_qp;
87 int last_qp;
88 uint32_t debt_bytes_;
89 uint32_t target_rate_kbps_;
90
91 void UpdateDebt(int64_t delta_ms);
92 } layers_[2];
stefan-webrtc 2015/06/23 14:28:33 We should name the constant 2 as it's used in more
sprang_webrtc 2015/06/23 15:07:31 Done.
65 }; 93 };
66 } // namespace webrtc 94 } // namespace webrtc
67 95
68 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_SCREENSHARE_LAYERS_H_ 96 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_SCREENSHARE_LAYERS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698