Chromium Code Reviews| 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(bool is_keyframe, |
| 90 TemporalLayers::FrameConfig tl_config, | |
|
sprang_webrtc
2017/05/03 15:18:43
Since it's a proper struct now, make it const Temp
pbos-webrtc
2017/05/04 10:52:22
(FWIW: I didn't because I believe the struct is sm
| |
| 85 CodecSpecificInfoVP8* vp8_info, | 91 CodecSpecificInfoVP8* vp8_info, |
| 86 uint32_t timestamp) = 0; | 92 uint32_t timestamp) = 0; |
| 87 | 93 |
| 88 virtual void FrameEncoded(unsigned int size, int qp) = 0; | 94 virtual void FrameEncoded(unsigned int size, int qp) = 0; |
| 89 | 95 |
| 90 virtual int CurrentLayerId() const = 0; | 96 virtual int GetTemporalLayerId( |
| 97 TemporalLayers::FrameConfig tl_config) const = 0; | |
| 91 }; | 98 }; |
| 92 | 99 |
| 93 class TemporalLayersListener; | 100 class TemporalLayersListener; |
| 94 class TemporalLayersFactory { | 101 class TemporalLayersFactory { |
| 95 public: | 102 public: |
| 96 TemporalLayersFactory() : listener_(nullptr) {} | 103 TemporalLayersFactory() : listener_(nullptr) {} |
| 97 virtual ~TemporalLayersFactory() {} | 104 virtual ~TemporalLayersFactory() {} |
| 98 virtual TemporalLayers* Create(int simulcast_id, | 105 virtual TemporalLayers* Create(int simulcast_id, |
| 99 int temporal_layers, | 106 int temporal_layers, |
| 100 uint8_t initial_tl0_pic_idx) const; | 107 uint8_t initial_tl0_pic_idx) const; |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 118 public: | 125 public: |
| 119 TemporalLayersListener() {} | 126 TemporalLayersListener() {} |
| 120 virtual ~TemporalLayersListener() {} | 127 virtual ~TemporalLayersListener() {} |
| 121 | 128 |
| 122 virtual void OnTemporalLayersCreated(int simulcast_id, | 129 virtual void OnTemporalLayersCreated(int simulcast_id, |
| 123 TemporalLayers* layers) = 0; | 130 TemporalLayers* layers) = 0; |
| 124 }; | 131 }; |
| 125 | 132 |
| 126 } // namespace webrtc | 133 } // namespace webrtc |
| 127 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_TEMPORAL_LAYERS_H_ | 134 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_TEMPORAL_LAYERS_H_ |
| OLD | NEW |