OLD | NEW |
1 /* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 1 /* Copyright (c) 2011 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 the interface for doing temporal layers with VP8. | 10 * This file defines the interface for doing temporal layers with VP8. |
11 */ | 11 */ |
12 #ifndef WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_TEMPORAL_LAYERS_H_ | 12 #ifndef WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_TEMPORAL_LAYERS_H_ |
13 #define WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_TEMPORAL_LAYERS_H_ | 13 #define WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_TEMPORAL_LAYERS_H_ |
14 | 14 |
15 #include <vector> | 15 #include <vector> |
16 | 16 |
17 #include "webrtc/common_video/include/video_image.h" | 17 #include "webrtc/common_video/include/video_image.h" |
18 #include "webrtc/typedefs.h" | 18 #include "webrtc/typedefs.h" |
19 | 19 |
20 struct vpx_codec_enc_cfg; | 20 struct vpx_codec_enc_cfg; |
21 typedef struct vpx_codec_enc_cfg vpx_codec_enc_cfg_t; | 21 typedef struct vpx_codec_enc_cfg vpx_codec_enc_cfg_t; |
22 | 22 |
23 namespace webrtc { | 23 namespace webrtc { |
24 | 24 |
25 struct CodecSpecificInfoVP8; | 25 struct CodecSpecificInfoVP8; |
26 | 26 |
| 27 enum TemporalBufferFlags { |
| 28 kNone = 0, |
| 29 kReference = 1, |
| 30 kUpdate = 2, |
| 31 kReferenceAndUpdate = kReference | kUpdate, |
| 32 }; |
| 33 |
| 34 enum TemporalFlags { kLayerSync = 1, kFreezeEntropy = 2 }; |
| 35 |
| 36 struct TemporalReferences { |
| 37 TemporalReferences(TemporalBufferFlags last, |
| 38 TemporalBufferFlags golden, |
| 39 TemporalBufferFlags arf); |
| 40 TemporalReferences(TemporalBufferFlags last, |
| 41 TemporalBufferFlags golden, |
| 42 TemporalBufferFlags arf, |
| 43 int extra_flags); |
| 44 |
| 45 const bool drop_frame; |
| 46 const TemporalBufferFlags last_buffer_flags; |
| 47 const TemporalBufferFlags golden_buffer_flags; |
| 48 const TemporalBufferFlags arf_buffer_flags; |
| 49 |
| 50 // TODO(pbos): Consider breaking these out of here and returning only a |
| 51 // pattern index that needs to be returned to fill CodecSpecificInfoVP8 or |
| 52 // EncodeFlags. |
| 53 const bool layer_sync; |
| 54 const bool freeze_entropy; |
| 55 |
| 56 private: |
| 57 TemporalReferences(TemporalBufferFlags last, |
| 58 TemporalBufferFlags golden, |
| 59 TemporalBufferFlags arf, |
| 60 bool layer_sync, |
| 61 bool freeze_entropy); |
| 62 }; |
| 63 |
27 class TemporalLayers { | 64 class TemporalLayers { |
28 public: | 65 public: |
29 // Factory for TemporalLayer strategy. Default behavior is a fixed pattern | 66 // Factory for TemporalLayer strategy. Default behavior is a fixed pattern |
30 // of temporal layers. See default_temporal_layers.cc | 67 // of temporal layers. See default_temporal_layers.cc |
31 virtual ~TemporalLayers() {} | 68 virtual ~TemporalLayers() {} |
32 | 69 |
33 // Returns the recommended VP8 encode flags needed. May refresh the decoder | 70 // Returns the recommended VP8 encode flags needed. May refresh the decoder |
34 // and/or update the reference buffers. | 71 // and/or update the reference buffers. |
35 virtual int EncodeFlags(uint32_t timestamp) = 0; | 72 virtual TemporalReferences UpdateLayerConfig(uint32_t timestamp) = 0; |
| 73 |
| 74 int EncodeFlags(uint32_t timestamp); |
36 | 75 |
37 // Update state based on new bitrate target and incoming framerate. | 76 // Update state based on new bitrate target and incoming framerate. |
38 // Returns the bitrate allocation for the active temporal layers. | 77 // Returns the bitrate allocation for the active temporal layers. |
39 virtual std::vector<uint32_t> OnRatesUpdated(int bitrate_kbps, | 78 virtual std::vector<uint32_t> OnRatesUpdated(int bitrate_kbps, |
40 int max_bitrate_kbps, | 79 int max_bitrate_kbps, |
41 int framerate) = 0; | 80 int framerate) = 0; |
42 | 81 |
43 // Update the encoder configuration with target bitrates or other parameters. | 82 // Update the encoder configuration with target bitrates or other parameters. |
44 // Returns true iff the configuration was actually modified. | 83 // Returns true iff the configuration was actually modified. |
45 virtual bool UpdateConfiguration(vpx_codec_enc_cfg_t* cfg) = 0; | 84 virtual bool UpdateConfiguration(vpx_codec_enc_cfg_t* cfg) = 0; |
46 | 85 |
47 virtual void PopulateCodecSpecific(bool base_layer_sync, | 86 virtual void PopulateCodecSpecific(bool is_keyframe, |
48 CodecSpecificInfoVP8* vp8_info, | 87 CodecSpecificInfoVP8* vp8_info, |
49 uint32_t timestamp) = 0; | 88 uint32_t timestamp) = 0; |
50 | 89 |
51 virtual void FrameEncoded(unsigned int size, uint32_t timestamp, int qp) = 0; | 90 virtual void FrameEncoded(unsigned int size, int qp) = 0; |
52 | 91 |
53 virtual int CurrentLayerId() const = 0; | 92 virtual int CurrentLayerId() const = 0; |
54 }; | 93 }; |
55 | 94 |
56 class TemporalLayersListener; | 95 class TemporalLayersListener; |
57 class TemporalLayersFactory { | 96 class TemporalLayersFactory { |
58 public: | 97 public: |
59 TemporalLayersFactory() : listener_(nullptr) {} | 98 TemporalLayersFactory() : listener_(nullptr) {} |
60 virtual ~TemporalLayersFactory() {} | 99 virtual ~TemporalLayersFactory() {} |
61 virtual TemporalLayers* Create(int simulcast_id, | 100 virtual TemporalLayers* Create(int simulcast_id, |
(...skipping 19 matching lines...) Expand all Loading... |
81 public: | 120 public: |
82 TemporalLayersListener() {} | 121 TemporalLayersListener() {} |
83 virtual ~TemporalLayersListener() {} | 122 virtual ~TemporalLayersListener() {} |
84 | 123 |
85 virtual void OnTemporalLayersCreated(int simulcast_id, | 124 virtual void OnTemporalLayersCreated(int simulcast_id, |
86 TemporalLayers* layers) = 0; | 125 TemporalLayers* layers) = 0; |
87 }; | 126 }; |
88 | 127 |
89 } // namespace webrtc | 128 } // namespace webrtc |
90 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_TEMPORAL_LAYERS_H_ | 129 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_TEMPORAL_LAYERS_H_ |
OLD | NEW |