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

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

Issue 2747123005: Simplify default temporal layers. (Closed)
Patch Set: move GetTemporalPattern out of class Created 3 years, 9 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 /* 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> 15 #include <vector>
16 16
17 #include "webrtc/modules/video_coding/codecs/vp8/temporal_layers.h" 17 #include "webrtc/modules/video_coding/codecs/vp8/temporal_layers.h"
18 18
19 #include "webrtc/base/optional.h" 19 #include "webrtc/base/optional.h"
20 20
21 namespace webrtc { 21 namespace webrtc {
22 22
23 enum TemporalBufferUsage {
24 kNone = 0,
25 kReference = 1,
26 kUpdate = 2,
27 kReferenceAndUpdate = kReference | kUpdate,
28 };
29 enum TemporalFlags { kLayerSync = 1, kFreezeEntropy = 2 };
30
31 struct TemporalReferences {
32 TemporalReferences(TemporalBufferUsage last,
33 TemporalBufferUsage golden,
34 TemporalBufferUsage arf);
35 TemporalReferences(TemporalBufferUsage last,
36 TemporalBufferUsage golden,
37 TemporalBufferUsage arf,
38 int extra_flags);
39
40 const bool reference_last;
pbos-webrtc 2017/03/17 18:03:44 The idea is that these bools here are easier to un
41 const bool update_last;
42 const bool reference_golden;
43 const bool update_golden;
brandtr 2017/03/21 12:20:09 I like these names instead of "buffer 0, 1, 2". Wh
pbos-webrtc 2017/03/21 17:37:46 Potentially that the buffer used doesn't really ma
44 const bool reference_arf;
45 const bool update_arf;
46 const bool layer_sync;
47 const bool freeze_entropy;
48
49 private:
50 TemporalReferences(TemporalBufferUsage last,
51 TemporalBufferUsage golden,
52 TemporalBufferUsage arf,
53 bool layer_sync,
54 bool freeze_entropy);
55 };
56
23 class DefaultTemporalLayers : public TemporalLayers { 57 class DefaultTemporalLayers : public TemporalLayers {
24 public: 58 public:
25 DefaultTemporalLayers(int number_of_temporal_layers, 59 DefaultTemporalLayers(int number_of_temporal_layers,
26 uint8_t initial_tl0_pic_idx); 60 uint8_t initial_tl0_pic_idx);
27 virtual ~DefaultTemporalLayers() {} 61 virtual ~DefaultTemporalLayers() {}
28 62
29 // Returns the recommended VP8 encode flags needed. May refresh the decoder 63 // Returns the recommended VP8 encode flags needed. May refresh the decoder
30 // and/or update the reference buffers. 64 // and/or update the reference buffers.
31 int EncodeFlags(uint32_t timestamp) override; 65 int EncodeFlags(uint32_t timestamp) override;
32 66
33 // Update state based on new bitrate target and incoming framerate. 67 // Update state based on new bitrate target and incoming framerate.
34 // Returns the bitrate allocation for the active temporal layers. 68 // Returns the bitrate allocation for the active temporal layers.
35 std::vector<uint32_t> OnRatesUpdated(int bitrate_kbps, 69 std::vector<uint32_t> OnRatesUpdated(int bitrate_kbps,
36 int max_bitrate_kbps, 70 int max_bitrate_kbps,
37 int framerate) override; 71 int framerate) override;
38 72
39 bool UpdateConfiguration(vpx_codec_enc_cfg_t* cfg) override; 73 bool UpdateConfiguration(vpx_codec_enc_cfg_t* cfg) override;
40 74
41 void PopulateCodecSpecific(bool base_layer_sync, 75 void PopulateCodecSpecific(bool base_layer_sync,
42 CodecSpecificInfoVP8* vp8_info, 76 CodecSpecificInfoVP8* vp8_info,
43 uint32_t timestamp) override; 77 uint32_t timestamp) override;
44 78
45 void FrameEncoded(unsigned int size, uint32_t timestamp, int qp) override {} 79 void FrameEncoded(unsigned int size, uint32_t timestamp, int qp) override {}
46 80
47 int CurrentLayerId() const override; 81 int CurrentLayerId() const override;
48 82
49 private: 83 private:
50 enum TemporalReferences { 84 const size_t num_layers_;
51 // For 1 layer case: reference all (last, golden, and alt ref), but only 85 const std::vector<unsigned int> temporal_ids_;
52 // update last. 86 const std::vector<TemporalReferences> temporal_pattern_;
53 kTemporalUpdateLastRefAll = 12,
54 // First base layer frame for 3 temporal layers, which updates last and
55 // golden with alt ref dependency.
56 kTemporalUpdateLastAndGoldenRefAltRef = 11,
57 // First enhancement layer with alt ref dependency.
58 kTemporalUpdateGoldenRefAltRef = 10,
59 // First enhancement layer with alt ref dependency.
60 kTemporalUpdateGoldenWithoutDependencyRefAltRef = 9,
61 // Base layer with alt ref dependency.
62 kTemporalUpdateLastRefAltRef = 8,
63 // Highest enhacement layer without dependency on golden with alt ref
64 // dependency.
65 kTemporalUpdateNoneNoRefGoldenRefAltRef = 7,
66 // Second layer and last frame in cycle, for 2 layers.
67 kTemporalUpdateNoneNoRefAltref = 6,
68 // Highest enhancement layer.
69 kTemporalUpdateNone = 5,
70 // Second enhancement layer.
71 kTemporalUpdateAltref = 4,
72 // Second enhancement layer without dependency on previous frames in
73 // the second enhancement layer.
74 kTemporalUpdateAltrefWithoutDependency = 3,
75 // First enhancement layer.
76 kTemporalUpdateGolden = 2,
77 // First enhancement layer without dependency on previous frames in
78 // the first enhancement layer.
79 kTemporalUpdateGoldenWithoutDependency = 1,
80 // Base layer.
81 kTemporalUpdateLast = 0,
82 };
83 enum { kMaxTemporalPattern = 16 };
84 87
85 const int number_of_temporal_layers_;
86 int temporal_ids_length_;
87 int temporal_ids_[kMaxTemporalPattern];
88 int temporal_pattern_length_;
89 TemporalReferences temporal_pattern_[kMaxTemporalPattern];
90 uint8_t tl0_pic_idx_; 88 uint8_t tl0_pic_idx_;
91 uint8_t pattern_idx_; 89 uint8_t pattern_idx_;
92 uint32_t timestamp_; 90 uint32_t timestamp_;
93 bool last_base_layer_sync_; 91 bool last_base_layer_sync_;
94 rtc::Optional<std::vector<uint32_t>> new_bitrates_kbps_; 92 rtc::Optional<std::vector<uint32_t>> new_bitrates_kbps_;
95 }; 93 };
96 94
97 } // namespace webrtc 95 } // namespace webrtc
98 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_DEFAULT_TEMPORAL_LAYERS_H_ 96 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_DEFAULT_TEMPORAL_LAYERS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698