From 943e3b95a6a41fc036a655554b88a766f92507d6 Mon Sep 17 00:00:00 2001 From: "marpan@webrtc.org" Date: Tue, 22 Oct 2013 01:55:07 +0000 Subject: [PATCH] Add CurrentLayerId() to temporal layers. same patch as: https://webrtc-codereview.appspot.com/2427004/ TBR=holmer@google.com Review URL: https://webrtc-codereview.appspot.com/2729004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@5012 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../video_coding/codecs/vp8/default_temporal_layers.cc | 10 ++++++++-- .../video_coding/codecs/vp8/default_temporal_layers.h | 2 ++ .../codecs/vp8/realtime_temporal_layers.cc | 2 +- .../modules/video_coding/codecs/vp8/temporal_layers.h | 2 ++ 4 files changed, 13 insertions(+), 3 deletions(-) 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 62d9ae613..a92a87afc 100644 --- a/webrtc/modules/video_coding/codecs/vp8/default_temporal_layers.cc +++ b/webrtc/modules/video_coding/codecs/vp8/default_temporal_layers.cc @@ -36,6 +36,13 @@ DefaultTemporalLayers::DefaultTemporalLayers(int numberOfTemporalLayers, memset(temporal_pattern_, 0, sizeof(temporal_pattern_)); } +int DefaultTemporalLayers::CurrentLayerId() const { + assert(temporal_ids_length_ > 0); + int index = pattern_idx_ % temporal_ids_length_; + assert(index >= 0); + return temporal_ids_[index]; + } + bool DefaultTemporalLayers::ConfigureBitrates(int bitrateKbit, int max_bitrate_kbit, int framerate, @@ -247,8 +254,7 @@ void DefaultTemporalLayers::PopulateCodecSpecific( vp8_info->temporalIdx = 0; vp8_info->layerSync = true; } else { - vp8_info->temporalIdx = temporal_ids_ - [pattern_idx_ % temporal_ids_length_]; + vp8_info->temporalIdx = CurrentLayerId(); TemporalReferences temporal_reference = temporal_pattern_[pattern_idx_ % temporal_pattern_length_]; diff --git a/webrtc/modules/video_coding/codecs/vp8/default_temporal_layers.h b/webrtc/modules/video_coding/codecs/vp8/default_temporal_layers.h index 99b0e9569..61f281f2b 100644 --- a/webrtc/modules/video_coding/codecs/vp8/default_temporal_layers.h +++ b/webrtc/modules/video_coding/codecs/vp8/default_temporal_layers.h @@ -37,6 +37,8 @@ class DefaultTemporalLayers : public TemporalLayers { virtual void FrameEncoded(unsigned int size, uint32_t timestamp) {} + virtual int CurrentLayerId() const; + private: enum TemporalReferences { // For 1 layer case: reference all (last, golden, and alt ref), but only diff --git a/webrtc/modules/video_coding/codecs/vp8/realtime_temporal_layers.cc b/webrtc/modules/video_coding/codecs/vp8/realtime_temporal_layers.cc index ba7412bd1..f16c75681 100644 --- a/webrtc/modules/video_coding/codecs/vp8/realtime_temporal_layers.cc +++ b/webrtc/modules/video_coding/codecs/vp8/realtime_temporal_layers.cc @@ -189,7 +189,7 @@ class RealTimeTemporalLayers : public TemporalLayers { return encode_flags_[index]; } - unsigned int CurrentLayerId() const { + virtual int CurrentLayerId() const { assert(layer_ids_length_ > 0 && layer_ids_ != NULL); int index = frame_counter_ % layer_ids_length_; assert(index >= 0 && index < layer_ids_length_); diff --git a/webrtc/modules/video_coding/codecs/vp8/temporal_layers.h b/webrtc/modules/video_coding/codecs/vp8/temporal_layers.h index 4549e287c..7ca4840c3 100644 --- a/webrtc/modules/video_coding/codecs/vp8/temporal_layers.h +++ b/webrtc/modules/video_coding/codecs/vp8/temporal_layers.h @@ -49,6 +49,8 @@ class TemporalLayers { uint32_t timestamp) = 0; virtual void FrameEncoded(unsigned int size, uint32_t timestamp) = 0; + + virtual int CurrentLayerId() const = 0; }; // Factory for a temporal layers strategy that adaptively changes the number of