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

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

Issue 2747123005: Simplify default temporal layers. (Closed)
Patch Set: update comments so that it doesn't look like updates are optional 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
« no previous file with comments | « no previous file | webrtc/modules/video_coding/codecs/vp8/default_temporal_layers.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
41 const bool update_last;
42 const bool reference_golden;
43 const bool update_golden;
44 const bool reference_arf;
45 const bool update_arf;
46
47 // TODO(pbos): Consider breaking these out of here and returning only a
48 // pattern index that needs to be returned to fill CodecSpecificInfoVP8 or
49 // EncodeFlags.
50 const bool layer_sync;
51 const bool freeze_entropy;
52
53 private:
54 TemporalReferences(TemporalBufferUsage last,
55 TemporalBufferUsage golden,
56 TemporalBufferUsage arf,
57 bool layer_sync,
58 bool freeze_entropy);
59 };
60
23 class DefaultTemporalLayers : public TemporalLayers { 61 class DefaultTemporalLayers : public TemporalLayers {
24 public: 62 public:
25 DefaultTemporalLayers(int number_of_temporal_layers, 63 DefaultTemporalLayers(int number_of_temporal_layers,
26 uint8_t initial_tl0_pic_idx); 64 uint8_t initial_tl0_pic_idx);
27 virtual ~DefaultTemporalLayers() {} 65 virtual ~DefaultTemporalLayers() {}
28 66
29 // Returns the recommended VP8 encode flags needed. May refresh the decoder 67 // Returns the recommended VP8 encode flags needed. May refresh the decoder
30 // and/or update the reference buffers. 68 // and/or update the reference buffers.
31 int EncodeFlags(uint32_t timestamp) override; 69 int EncodeFlags(uint32_t timestamp) override;
32 70
33 // Update state based on new bitrate target and incoming framerate. 71 // Update state based on new bitrate target and incoming framerate.
34 // Returns the bitrate allocation for the active temporal layers. 72 // Returns the bitrate allocation for the active temporal layers.
35 std::vector<uint32_t> OnRatesUpdated(int bitrate_kbps, 73 std::vector<uint32_t> OnRatesUpdated(int bitrate_kbps,
36 int max_bitrate_kbps, 74 int max_bitrate_kbps,
37 int framerate) override; 75 int framerate) override;
38 76
39 bool UpdateConfiguration(vpx_codec_enc_cfg_t* cfg) override; 77 bool UpdateConfiguration(vpx_codec_enc_cfg_t* cfg) override;
40 78
41 void PopulateCodecSpecific(bool base_layer_sync, 79 void PopulateCodecSpecific(bool base_layer_sync,
42 CodecSpecificInfoVP8* vp8_info, 80 CodecSpecificInfoVP8* vp8_info,
43 uint32_t timestamp) override; 81 uint32_t timestamp) override;
44 82
45 void FrameEncoded(unsigned int size, uint32_t timestamp, int qp) override {} 83 void FrameEncoded(unsigned int size, uint32_t timestamp, int qp) override {}
46 84
47 int CurrentLayerId() const override; 85 int CurrentLayerId() const override;
48 86
49 private: 87 private:
50 enum TemporalReferences { 88 const size_t num_layers_;
51 // For 1 layer case: reference all (last, golden, and alt ref), but only 89 const std::vector<unsigned int> temporal_ids_;
52 // update last. 90 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 91
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_; 92 uint8_t tl0_pic_idx_;
91 uint8_t pattern_idx_; 93 uint8_t pattern_idx_;
92 uint32_t timestamp_; 94 uint32_t timestamp_;
93 bool last_base_layer_sync_; 95 bool last_base_layer_sync_;
94 rtc::Optional<std::vector<uint32_t>> new_bitrates_kbps_; 96 rtc::Optional<std::vector<uint32_t>> new_bitrates_kbps_;
95 }; 97 };
96 98
97 } // namespace webrtc 99 } // namespace webrtc
98 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_DEFAULT_TEMPORAL_LAYERS_H_ 100 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_DEFAULT_TEMPORAL_LAYERS_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/video_coding/codecs/vp8/default_temporal_layers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698