Line data Source code
1 : /* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
2 : *
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
5 : * tree. An additional intellectual property rights grant can be found
6 : * in the file PATENTS. All contributing project authors may
7 : * be found in the AUTHORS file in the root of the source tree.
8 : */
9 : /*
10 : * This file defines classes for doing temporal layers with VP8.
11 : */
12 : #ifndef WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_DEFAULT_TEMPORAL_LAYERS_H_
13 : #define WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_DEFAULT_TEMPORAL_LAYERS_H_
14 :
15 : #include <vector>
16 :
17 : #include "webrtc/modules/video_coding/codecs/vp8/temporal_layers.h"
18 :
19 : #include "webrtc/base/optional.h"
20 :
21 : namespace webrtc {
22 :
23 : class DefaultTemporalLayers : public TemporalLayers {
24 : public:
25 : DefaultTemporalLayers(int number_of_temporal_layers,
26 : uint8_t initial_tl0_pic_idx);
27 0 : virtual ~DefaultTemporalLayers() {}
28 :
29 : // Returns the recommended VP8 encode flags needed. May refresh the decoder
30 : // and/or update the reference buffers.
31 : int EncodeFlags(uint32_t timestamp) override;
32 :
33 : // Update state based on new bitrate target and incoming framerate.
34 : // Returns the bitrate allocation for the active temporal layers.
35 : std::vector<uint32_t> OnRatesUpdated(int bitrate_kbps,
36 : int max_bitrate_kbps,
37 : int framerate) override;
38 :
39 : bool UpdateConfiguration(vpx_codec_enc_cfg_t* cfg) override;
40 :
41 : void PopulateCodecSpecific(bool base_layer_sync,
42 : CodecSpecificInfoVP8* vp8_info,
43 : uint32_t timestamp) override;
44 :
45 0 : void FrameEncoded(unsigned int size, uint32_t timestamp, int qp) override {}
46 :
47 : int CurrentLayerId() const override;
48 :
49 : private:
50 : enum TemporalReferences {
51 : // For 1 layer case: reference all (last, golden, and alt ref), but only
52 : // update last.
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 :
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_;
91 : uint8_t pattern_idx_;
92 : uint32_t timestamp_;
93 : bool last_base_layer_sync_;
94 : rtc::Optional<std::vector<uint32_t>> new_bitrates_kbps_;
95 : };
96 :
97 : } // namespace webrtc
98 : #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_DEFAULT_TEMPORAL_LAYERS_H_
|