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 <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 | 28 |
29 ScreenshareLayers(int num_temporal_layers, | 29 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() {} | 30 virtual ~ScreenshareLayers() {} |
34 | 31 |
35 // Returns the recommended VP8 encode flags needed. May refresh the decoder | 32 // Returns the recommended VP8 encode flags needed. May refresh the decoder |
36 // and/or update the reference buffers. | 33 // and/or update the reference buffers. |
37 virtual int EncodeFlags(uint32_t timestamp); | 34 int EncodeFlags(uint32_t timestamp) override; |
38 | 35 |
39 virtual bool ConfigureBitrates(int bitrate_kbit, | 36 bool ConfigureBitrates(int bitrate_kbit, |
40 int max_bitrate_kbit, | 37 int max_bitrate_kbit, |
41 int framerate, | 38 int framerate, |
42 vpx_codec_enc_cfg_t* cfg); | 39 vpx_codec_enc_cfg_t* cfg) override; |
43 | 40 |
44 virtual void PopulateCodecSpecific(bool base_layer_sync, | 41 void PopulateCodecSpecific(bool base_layer_sync, |
45 CodecSpecificInfoVP8 *vp8_info, | 42 CodecSpecificInfoVP8* vp8_info, |
46 uint32_t timestamp); | 43 uint32_t timestamp) override; |
47 | 44 |
48 virtual void FrameEncoded(unsigned int size, uint32_t timestamp); | 45 void FrameEncoded(unsigned int size, uint32_t timestamp, int qp) override; |
49 | 46 |
50 virtual int CurrentLayerId() const; | 47 int CurrentLayerId() const override; |
| 48 |
| 49 bool UpdateConfiguration(vpx_codec_enc_cfg_t* cfg) override; |
51 | 50 |
52 private: | 51 private: |
53 void CalculateFramerate(uint32_t timestamp); | |
54 bool TimeToSync(uint32_t timestamp) const; | 52 bool TimeToSync(uint32_t timestamp) const; |
55 | 53 |
56 FrameDropper* tl0_frame_dropper_; | |
57 FrameDropper* tl1_frame_dropper_; | |
58 int number_of_temporal_layers_; | 54 int number_of_temporal_layers_; |
59 bool last_base_layer_sync_; | 55 bool last_base_layer_sync_; |
60 uint8_t tl0_pic_idx_; | 56 uint8_t tl0_pic_idx_; |
61 int active_layer_; | 57 int active_layer_; |
62 std::list<uint32_t> timestamp_list_; | 58 uint32_t last_timestamp_; |
63 int framerate_; | 59 uint32_t last_sync_timestamp_; |
64 int64_t last_sync_timestamp_; | 60 int min_qp_; |
| 61 int max_qp_; |
| 62 uint32_t max_debt_bytes_; |
| 63 |
| 64 struct TemporalLayer { |
| 65 TemporalLayer() |
| 66 : state(State::kNormal), |
| 67 enhanced_max_qp(-1), |
| 68 last_qp(-1), |
| 69 debt_bytes_(0), |
| 70 target_rate_kbps_(0) {} |
| 71 |
| 72 enum class State { |
| 73 kNormal, |
| 74 kDropped, |
| 75 kReencoded, |
| 76 kQualityBoost, |
| 77 } state; |
| 78 |
| 79 int enhanced_max_qp; |
| 80 int last_qp; |
| 81 uint32_t debt_bytes_; |
| 82 uint32_t target_rate_kbps_; |
| 83 |
| 84 void UpdateDebt(int64_t delta_ms); |
| 85 } layers_[2]; |
65 }; | 86 }; |
66 } // namespace webrtc | 87 } // namespace webrtc |
67 | 88 |
68 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_SCREENSHARE_LAYERS_H_ | 89 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_SCREENSHARE_LAYERS_H_ |
OLD | NEW |