diff --git a/webrtc/modules/video_coding/codecs/vp8/default_temporal_layers.cc b/webrtc/modules/video_coding/codecs/vp8/default_temporal_layers.cc index ec0b5c635c..62d9ae613c 100644 --- a/webrtc/modules/video_coding/codecs/vp8/default_temporal_layers.cc +++ b/webrtc/modules/video_coding/codecs/vp8/default_temporal_layers.cc @@ -277,4 +277,10 @@ void DefaultTemporalLayers::PopulateCodecSpecific( vp8_info->tl0PicIdx = tl0_pic_idx_; } } + +TemporalLayers* TemporalLayers::Factory::Create( + int temporal_layers, + uint8_t initial_tl0_pic_idx) const { + return new DefaultTemporalLayers(temporal_layers, initial_tl0_pic_idx); +} } // namespace webrtc diff --git a/webrtc/modules/video_coding/codecs/vp8/temporal_layers.h b/webrtc/modules/video_coding/codecs/vp8/temporal_layers.h index 4895dc98b1..9df88b9be4 100644 --- a/webrtc/modules/video_coding/codecs/vp8/temporal_layers.h +++ b/webrtc/modules/video_coding/codecs/vp8/temporal_layers.h @@ -24,6 +24,13 @@ struct CodecSpecificInfoVP8; class TemporalLayers { public: + struct Factory { + Factory() {} + virtual ~Factory() {} + virtual TemporalLayers* Create(int temporal_layers, + uint8_t initial_tl0_pic_idx) const; + }; + virtual ~TemporalLayers() {} // Returns the recommended VP8 encode flags needed. May refresh the decoder diff --git a/webrtc/modules/video_coding/codecs/vp8/vp8_impl.cc b/webrtc/modules/video_coding/codecs/vp8/vp8_impl.cc index c988498302..910a5f3f8b 100644 --- a/webrtc/modules/video_coding/codecs/vp8/vp8_impl.cc +++ b/webrtc/modules/video_coding/codecs/vp8/vp8_impl.cc @@ -23,9 +23,10 @@ #include "vpx/vp8cx.h" #include "vpx/vp8dx.h" +#include "webrtc/common.h" #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" #include "webrtc/modules/interface/module_common_types.h" -#include "webrtc/modules/video_coding/codecs/vp8/default_temporal_layers.h" +#include "webrtc/modules/video_coding/codecs/vp8/temporal_layers.h" #include "webrtc/modules/video_coding/codecs/vp8/reference_picture_selection.h" #include "webrtc/system_wrappers/interface/tick_util.h" #include "webrtc/system_wrappers/interface/trace_event.h" @@ -153,10 +154,16 @@ int VP8EncoderImpl::InitEncode(const VideoCodec* inst, codec_ = *inst; } + // TODO(andresp): assert(inst->extra_options) and cleanup. + Config default_options; + const Config& options = + inst->extra_options ? *inst->extra_options : default_options; + int num_temporal_layers = inst->codecSpecific.VP8.numberOfTemporalLayers > 1 ? inst->codecSpecific.VP8.numberOfTemporalLayers : 1; assert(temporal_layers_ == NULL); - temporal_layers_ = new DefaultTemporalLayers(num_temporal_layers, rand()); + temporal_layers_ = options.Get() + .Create(num_temporal_layers, rand()); // random start 16 bits is enough. picture_id_ = static_cast(rand()) & 0x7FFF;