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

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

Issue 2510583002: Reland #2 of Issue 2434073003: Extract bitrate allocation ... (Closed)
Patch Set: Addressed comments Created 4 years, 1 month 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 /* 9 /*
10 * This file defines classes for doing temporal layers with VP8. 10 * This file defines classes for doing temporal layers with VP8.
11 */ 11 */
12 #ifndef WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_DEFAULT_TEMPORAL_LAYERS_H_ 12 #ifndef WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_DEFAULT_TEMPORAL_LAYERS_H_
13 #define WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_DEFAULT_TEMPORAL_LAYERS_H_ 13 #define WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_DEFAULT_TEMPORAL_LAYERS_H_
14 14
15 #include <vector>
16
15 #include "webrtc/modules/video_coding/codecs/vp8/temporal_layers.h" 17 #include "webrtc/modules/video_coding/codecs/vp8/temporal_layers.h"
16 18
19 #include "webrtc/base/optional.h"
20
17 namespace webrtc { 21 namespace webrtc {
18 22
19 class DefaultTemporalLayers : public TemporalLayers { 23 class DefaultTemporalLayers : public TemporalLayers {
20 public: 24 public:
21 DefaultTemporalLayers(int number_of_temporal_layers, 25 DefaultTemporalLayers(int number_of_temporal_layers,
22 uint8_t initial_tl0_pic_idx); 26 uint8_t initial_tl0_pic_idx);
23 virtual ~DefaultTemporalLayers() {} 27 virtual ~DefaultTemporalLayers() {}
24 28
25 // Returns the recommended VP8 encode flags needed. May refresh the decoder 29 // Returns the recommended VP8 encode flags needed. May refresh the decoder
26 // and/or update the reference buffers. 30 // and/or update the reference buffers.
27 int EncodeFlags(uint32_t timestamp) override; 31 int EncodeFlags(uint32_t timestamp) override;
28 32
29 bool ConfigureBitrates(int bitrate_kbit, 33 // Update state based on new bitrate target and incoming framerate.
30 int max_bitrate_kbit, 34 // Returns the bitrate allocation for the active temporal layers.
31 int framerate, 35 std::vector<uint32_t> OnRatesUpdated(int bitrate_kbps,
32 vpx_codec_enc_cfg_t* cfg) override; 36 int max_bitrate_kbps,
37 int framerate) override;
38
39 bool UpdateConfiguration(vpx_codec_enc_cfg_t* cfg) override;
33 40
34 void PopulateCodecSpecific(bool base_layer_sync, 41 void PopulateCodecSpecific(bool base_layer_sync,
35 CodecSpecificInfoVP8* vp8_info, 42 CodecSpecificInfoVP8* vp8_info,
36 uint32_t timestamp) override; 43 uint32_t timestamp) override;
37 44
38 void FrameEncoded(unsigned int size, uint32_t timestamp, int qp) override {} 45 void FrameEncoded(unsigned int size, uint32_t timestamp, int qp) override {}
39 46
40 bool UpdateConfiguration(vpx_codec_enc_cfg_t* cfg) override { return false; }
41
42 int CurrentLayerId() const override; 47 int CurrentLayerId() const override;
43 48
44 private: 49 private:
45 enum TemporalReferences { 50 enum TemporalReferences {
46 // For 1 layer case: reference all (last, golden, and alt ref), but only 51 // For 1 layer case: reference all (last, golden, and alt ref), but only
47 // update last. 52 // update last.
48 kTemporalUpdateLastRefAll = 12, 53 kTemporalUpdateLastRefAll = 12,
49 // First base layer frame for 3 temporal layers, which updates last and 54 // First base layer frame for 3 temporal layers, which updates last and
50 // golden with alt ref dependency. 55 // golden with alt ref dependency.
51 kTemporalUpdateLastAndGoldenRefAltRef = 11, 56 kTemporalUpdateLastAndGoldenRefAltRef = 11,
(...skipping 18 matching lines...) Expand all
70 // First enhancement layer. 75 // First enhancement layer.
71 kTemporalUpdateGolden = 2, 76 kTemporalUpdateGolden = 2,
72 // First enhancement layer without dependency on previous frames in 77 // First enhancement layer without dependency on previous frames in
73 // the first enhancement layer. 78 // the first enhancement layer.
74 kTemporalUpdateGoldenWithoutDependency = 1, 79 kTemporalUpdateGoldenWithoutDependency = 1,
75 // Base layer. 80 // Base layer.
76 kTemporalUpdateLast = 0, 81 kTemporalUpdateLast = 0,
77 }; 82 };
78 enum { kMaxTemporalPattern = 16 }; 83 enum { kMaxTemporalPattern = 16 };
79 84
80 int number_of_temporal_layers_; 85 const int number_of_temporal_layers_;
81 int temporal_ids_length_; 86 int temporal_ids_length_;
82 int temporal_ids_[kMaxTemporalPattern]; 87 int temporal_ids_[kMaxTemporalPattern];
83 int temporal_pattern_length_; 88 int temporal_pattern_length_;
84 TemporalReferences temporal_pattern_[kMaxTemporalPattern]; 89 TemporalReferences temporal_pattern_[kMaxTemporalPattern];
85 uint8_t tl0_pic_idx_; 90 uint8_t tl0_pic_idx_;
86 uint8_t pattern_idx_; 91 uint8_t pattern_idx_;
87 uint32_t timestamp_; 92 uint32_t timestamp_;
88 bool last_base_layer_sync_; 93 bool last_base_layer_sync_;
94 rtc::Optional<std::vector<uint32_t>> new_bitrates_kbps_;
89 }; 95 };
90 96
91 } // namespace webrtc 97 } // namespace webrtc
92 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_DEFAULT_TEMPORAL_LAYERS_H_ 98 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_DEFAULT_TEMPORAL_LAYERS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698