OLD | NEW |
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 <vector> |
13 | |
14 #include "vpx/vpx_encoder.h" | |
15 | 13 |
16 #include "webrtc/base/timeutils.h" | 14 #include "webrtc/base/timeutils.h" |
17 #include "webrtc/modules/video_coding/codecs/vp8/temporal_layers.h" | 15 #include "webrtc/modules/video_coding/codecs/vp8/temporal_layers.h" |
18 #include "webrtc/modules/video_coding/utility/frame_dropper.h" | 16 #include "webrtc/modules/video_coding/utility/frame_dropper.h" |
19 #include "webrtc/typedefs.h" | 17 #include "webrtc/typedefs.h" |
20 | 18 |
21 namespace webrtc { | 19 namespace webrtc { |
22 | 20 |
23 struct CodecSpecificInfoVP8; | 21 struct CodecSpecificInfoVP8; |
24 class Clock; | 22 class Clock; |
25 | 23 |
26 class ScreenshareLayers : public TemporalLayers { | 24 class ScreenshareLayers : public TemporalLayers { |
27 public: | 25 public: |
28 static const double kMaxTL0FpsReduction; | 26 static const double kMaxTL0FpsReduction; |
29 static const double kAcceptableTargetOvershoot; | 27 static const double kAcceptableTargetOvershoot; |
30 static const int kTl0Flags; | 28 static const int kTl0Flags; |
31 static const int kTl1Flags; | 29 static const int kTl1Flags; |
32 static const int kTl1SyncFlags; | 30 static const int kTl1SyncFlags; |
33 static const int kMaxFrameIntervalMs; | 31 static const int kMaxFrameIntervalMs; |
34 | 32 |
35 ScreenshareLayers(int num_temporal_layers, | 33 ScreenshareLayers(int num_temporal_layers, |
36 uint8_t initial_tl0_pic_idx, | 34 uint8_t initial_tl0_pic_idx, |
37 Clock* clock); | 35 Clock* clock); |
38 virtual ~ScreenshareLayers(); | 36 virtual ~ScreenshareLayers(); |
39 | 37 |
40 // Returns the recommended VP8 encode flags needed. May refresh the decoder | 38 // Returns the recommended VP8 encode flags needed. May refresh the decoder |
41 // and/or update the reference buffers. | 39 // and/or update the reference buffers. |
42 int EncodeFlags(uint32_t timestamp) override; | 40 int EncodeFlags(uint32_t timestamp) override; |
43 | 41 |
44 bool ConfigureBitrates(int bitrate_kbps, | 42 // Update state based on new bitrate target and incoming framerate. |
45 int max_bitrate_kbps, | 43 // Returns the bitrate allocation for the active temporal layers. |
46 int framerate, | 44 std::vector<uint32_t> OnRatesUpdated(int bitrate_kbit, |
47 vpx_codec_enc_cfg_t* cfg) override; | 45 int max_bitrate_kbit, |
| 46 int framerate) override; |
| 47 |
| 48 // Update the encoder configuration with target bitrates or other parameters. |
| 49 // Returns true iff the configuration was actually modified. |
| 50 bool UpdateConfiguration(vpx_codec_enc_cfg_t* cfg) override; |
48 | 51 |
49 void PopulateCodecSpecific(bool base_layer_sync, | 52 void PopulateCodecSpecific(bool base_layer_sync, |
50 CodecSpecificInfoVP8* vp8_info, | 53 CodecSpecificInfoVP8* vp8_info, |
51 uint32_t timestamp) override; | 54 uint32_t timestamp) override; |
52 | 55 |
53 void FrameEncoded(unsigned int size, uint32_t timestamp, int qp) override; | 56 void FrameEncoded(unsigned int size, uint32_t timestamp, int qp) override; |
54 | 57 |
55 int CurrentLayerId() const override; | 58 int CurrentLayerId() const override; |
56 | 59 |
57 // Allows the layers adapter to update the encoder configuration prior to a | |
58 // frame being encoded. Return true if the configuration should be updated | |
59 // and false if now change is needed. | |
60 bool UpdateConfiguration(vpx_codec_enc_cfg_t* cfg) override; | |
61 | |
62 private: | 60 private: |
63 bool TimeToSync(int64_t timestamp) const; | 61 bool TimeToSync(int64_t timestamp) const; |
64 | 62 |
65 Clock* const clock_; | 63 Clock* const clock_; |
66 | 64 |
67 int number_of_temporal_layers_; | 65 int number_of_temporal_layers_; |
68 bool last_base_layer_sync_; | 66 bool last_base_layer_sync_; |
69 uint8_t tl0_pic_idx_; | 67 uint8_t tl0_pic_idx_; |
70 int active_layer_; | 68 int active_layer_; |
71 int64_t last_timestamp_; | 69 int64_t last_timestamp_; |
72 int64_t last_sync_timestamp_; | 70 int64_t last_sync_timestamp_; |
73 int64_t last_emitted_tl0_timestamp_; | 71 int64_t last_emitted_tl0_timestamp_; |
74 rtc::TimestampWrapAroundHandler time_wrap_handler_; | 72 rtc::TimestampWrapAroundHandler time_wrap_handler_; |
75 int min_qp_; | 73 int min_qp_; |
76 int max_qp_; | 74 int max_qp_; |
77 uint32_t max_debt_bytes_; | 75 uint32_t max_debt_bytes_; |
78 int frame_rate_; | 76 int frame_rate_; |
| 77 bool bitrate_updated_; |
79 | 78 |
80 static const int kMaxNumTemporalLayers = 2; | 79 static const int kMaxNumTemporalLayers = 2; |
81 struct TemporalLayer { | 80 struct TemporalLayer { |
82 TemporalLayer() | 81 TemporalLayer() |
83 : state(State::kNormal), | 82 : state(State::kNormal), |
84 enhanced_max_qp(-1), | 83 enhanced_max_qp(-1), |
85 last_qp(-1), | 84 last_qp(-1), |
86 debt_bytes_(0), | 85 debt_bytes_(0), |
87 target_rate_kbps_(0) {} | 86 target_rate_kbps_(0) {} |
88 | 87 |
(...skipping 22 matching lines...) Expand all Loading... |
111 int64_t num_overshoots_ = 0; | 110 int64_t num_overshoots_ = 0; |
112 int64_t tl0_qp_sum_ = 0; | 111 int64_t tl0_qp_sum_ = 0; |
113 int64_t tl1_qp_sum_ = 0; | 112 int64_t tl1_qp_sum_ = 0; |
114 int64_t tl0_target_bitrate_sum_ = 0; | 113 int64_t tl0_target_bitrate_sum_ = 0; |
115 int64_t tl1_target_bitrate_sum_ = 0; | 114 int64_t tl1_target_bitrate_sum_ = 0; |
116 } stats_; | 115 } stats_; |
117 }; | 116 }; |
118 } // namespace webrtc | 117 } // namespace webrtc |
119 | 118 |
120 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_SCREENSHARE_LAYERS_H_ | 119 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_SCREENSHARE_LAYERS_H_ |
OLD | NEW |