| 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 { | 27 // TODO(pbos): Remove along with layer_sync and freeze_entropy, they are |
| 28 kNone = 0, | 28 // derivable from picture_idx and should be exposed with |
| 29 kReference = 1, | 29 // TL::IsLayerSync(TL::FrameConfig). |
| 30 kUpdate = 2, | |
| 31 kReferenceAndUpdate = kReference | kUpdate, | |
| 32 }; | |
| 33 | |
| 34 enum TemporalFlags { kLayerSync = 1, kFreezeEntropy = 2 }; | 30 enum TemporalFlags { kLayerSync = 1, kFreezeEntropy = 2 }; |
| 35 | 31 |
| 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 | |
| 64 class TemporalLayers { | 32 class TemporalLayers { |
| 65 public: | 33 public: |
| 34 enum BufferFlags { |
| 35 kNone = 0, |
| 36 kReference = 1, |
| 37 kUpdate = 2, |
| 38 kReferenceAndUpdate = kReference | kUpdate, |
| 39 }; |
| 40 |
| 41 struct FrameConfig { |
| 42 FrameConfig(); |
| 43 |
| 44 FrameConfig(BufferFlags last, BufferFlags golden, BufferFlags arf); |
| 45 FrameConfig(BufferFlags last, |
| 46 BufferFlags golden, |
| 47 BufferFlags arf, |
| 48 int extra_flags); |
| 49 |
| 50 bool drop_frame; |
| 51 BufferFlags last_buffer_flags; |
| 52 BufferFlags golden_buffer_flags; |
| 53 BufferFlags arf_buffer_flags; |
| 54 |
| 55 // TODO(pbos): Consider breaking these out of here and returning only a |
| 56 // pattern index that needs to be returned to fill CodecSpecificInfoVP8 or |
| 57 // EncodeFlags. |
| 58 bool layer_sync; |
| 59 bool freeze_entropy; |
| 60 |
| 61 int pattern_idx; |
| 62 |
| 63 private: |
| 64 FrameConfig(BufferFlags last, |
| 65 BufferFlags golden, |
| 66 BufferFlags arf, |
| 67 bool layer_sync, |
| 68 bool freeze_entropy); |
| 69 }; |
| 70 |
| 66 // Factory for TemporalLayer strategy. Default behavior is a fixed pattern | 71 // Factory for TemporalLayer strategy. Default behavior is a fixed pattern |
| 67 // of temporal layers. See default_temporal_layers.cc | 72 // of temporal layers. See default_temporal_layers.cc |
| 68 virtual ~TemporalLayers() {} | 73 virtual ~TemporalLayers() {} |
| 69 | 74 |
| 70 // Returns the recommended VP8 encode flags needed. May refresh the decoder | 75 // Returns the recommended VP8 encode flags needed. May refresh the decoder |
| 71 // and/or update the reference buffers. | 76 // and/or update the reference buffers. |
| 72 virtual TemporalReferences UpdateLayerConfig(uint32_t timestamp) = 0; | 77 virtual FrameConfig UpdateLayerConfig(uint32_t timestamp) = 0; |
| 73 | 78 |
| 74 // Update state based on new bitrate target and incoming framerate. | 79 // Update state based on new bitrate target and incoming framerate. |
| 75 // Returns the bitrate allocation for the active temporal layers. | 80 // Returns the bitrate allocation for the active temporal layers. |
| 76 virtual std::vector<uint32_t> OnRatesUpdated(int bitrate_kbps, | 81 virtual std::vector<uint32_t> OnRatesUpdated(int bitrate_kbps, |
| 77 int max_bitrate_kbps, | 82 int max_bitrate_kbps, |
| 78 int framerate) = 0; | 83 int framerate) = 0; |
| 79 | 84 |
| 80 // Update the encoder configuration with target bitrates or other parameters. | 85 // Update the encoder configuration with target bitrates or other parameters. |
| 81 // Returns true iff the configuration was actually modified. | 86 // Returns true iff the configuration was actually modified. |
| 82 virtual bool UpdateConfiguration(vpx_codec_enc_cfg_t* cfg) = 0; | 87 virtual bool UpdateConfiguration(vpx_codec_enc_cfg_t* cfg) = 0; |
| 83 | 88 |
| 84 virtual void PopulateCodecSpecific(bool is_keyframe, | 89 virtual void PopulateCodecSpecific( |
| 85 CodecSpecificInfoVP8* vp8_info, | 90 bool is_keyframe, |
| 86 uint32_t timestamp) = 0; | 91 const TemporalLayers::FrameConfig& tl_config, |
| 92 CodecSpecificInfoVP8* vp8_info, |
| 93 uint32_t timestamp) = 0; |
| 87 | 94 |
| 88 virtual void FrameEncoded(unsigned int size, int qp) = 0; | 95 virtual void FrameEncoded(unsigned int size, int qp) = 0; |
| 89 | 96 |
| 90 virtual int CurrentLayerId() const = 0; | |
| 91 | |
| 92 // Returns the current tl0_pic_idx, so it can be reused in future | 97 // Returns the current tl0_pic_idx, so it can be reused in future |
| 93 // instantiations. | 98 // instantiations. |
| 94 virtual uint8_t Tl0PicIdx() const = 0; | 99 virtual uint8_t Tl0PicIdx() const = 0; |
| 100 virtual int GetTemporalLayerId( |
| 101 const TemporalLayers::FrameConfig& tl_config) const = 0; |
| 95 }; | 102 }; |
| 96 | 103 |
| 97 class TemporalLayersListener; | 104 class TemporalLayersListener; |
| 98 class TemporalLayersFactory { | 105 class TemporalLayersFactory { |
| 99 public: | 106 public: |
| 100 TemporalLayersFactory() : listener_(nullptr) {} | 107 TemporalLayersFactory() : listener_(nullptr) {} |
| 101 virtual ~TemporalLayersFactory() {} | 108 virtual ~TemporalLayersFactory() {} |
| 102 virtual TemporalLayers* Create(int simulcast_id, | 109 virtual TemporalLayers* Create(int simulcast_id, |
| 103 int temporal_layers, | 110 int temporal_layers, |
| 104 uint8_t initial_tl0_pic_idx) const; | 111 uint8_t initial_tl0_pic_idx) const; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 122 public: | 129 public: |
| 123 TemporalLayersListener() {} | 130 TemporalLayersListener() {} |
| 124 virtual ~TemporalLayersListener() {} | 131 virtual ~TemporalLayersListener() {} |
| 125 | 132 |
| 126 virtual void OnTemporalLayersCreated(int simulcast_id, | 133 virtual void OnTemporalLayersCreated(int simulcast_id, |
| 127 TemporalLayers* layers) = 0; | 134 TemporalLayers* layers) = 0; |
| 128 }; | 135 }; |
| 129 | 136 |
| 130 } // namespace webrtc | 137 } // namespace webrtc |
| 131 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_TEMPORAL_LAYERS_H_ | 138 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_TEMPORAL_LAYERS_H_ |
| OLD | NEW |