From 45d2234a5c7cb63ea3794342e21e43daf5d78390 Mon Sep 17 00:00:00 2001 From: Danil Chapovalov Date: Thu, 11 Feb 2021 14:58:29 +0100 Subject: [PATCH] Test and fix unscalable video structure. Bug: webrtc:11999 Change-Id: I94e3a97ebadbf92ca741d750f67fbea5cbd2b66f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/206984 Reviewed-by: Philip Eliasson Commit-Queue: Danil Chapovalov Cr-Commit-Position: refs/heads/master@{#33237} --- .../svc/scalability_structure_unittest.cc | 3 ++- .../scalable_video_controller_no_layering.cc | 26 ++++++++++++++++--- .../scalable_video_controller_no_layering.h | 3 ++- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/modules/video_coding/svc/scalability_structure_unittest.cc b/modules/video_coding/svc/scalability_structure_unittest.cc index d6766f0d50..3bb658352d 100644 --- a/modules/video_coding/svc/scalability_structure_unittest.cc +++ b/modules/video_coding/svc/scalability_structure_unittest.cc @@ -292,7 +292,8 @@ TEST_P(ScalabilityStructureTest, ProduceNoFrameForDisabledLayers) { INSTANTIATE_TEST_SUITE_P( Svc, ScalabilityStructureTest, - Values(SvcTestParam{"L1T2", /*num_temporal_units=*/4}, + Values(SvcTestParam{"NONE", /*num_temporal_units=*/3}, + SvcTestParam{"L1T2", /*num_temporal_units=*/4}, SvcTestParam{"L1T3", /*num_temporal_units=*/8}, SvcTestParam{"L2T1", /*num_temporal_units=*/3}, SvcTestParam{"L2T1_KEY", /*num_temporal_units=*/3}, diff --git a/modules/video_coding/svc/scalable_video_controller_no_layering.cc b/modules/video_coding/svc/scalable_video_controller_no_layering.cc index 6d8e6e8fc6..3934e57804 100644 --- a/modules/video_coding/svc/scalable_video_controller_no_layering.cc +++ b/modules/video_coding/svc/scalable_video_controller_no_layering.cc @@ -32,14 +32,28 @@ FrameDependencyStructure ScalableVideoControllerNoLayering::DependencyStructure() const { FrameDependencyStructure structure; structure.num_decode_targets = 1; - FrameDependencyTemplate a_template; - a_template.decode_target_indications = {DecodeTargetIndication::kSwitch}; - structure.templates.push_back(a_template); + structure.num_chains = 1; + structure.decode_target_protected_by_chain = {0}; + + FrameDependencyTemplate key_frame; + key_frame.decode_target_indications = {DecodeTargetIndication::kSwitch}; + key_frame.chain_diffs = {0}; + structure.templates.push_back(key_frame); + + FrameDependencyTemplate delta_frame; + delta_frame.decode_target_indications = {DecodeTargetIndication::kSwitch}; + delta_frame.chain_diffs = {1}; + delta_frame.frame_diffs = {1}; + structure.templates.push_back(delta_frame); + return structure; } std::vector ScalableVideoControllerNoLayering::NextFrameConfig(bool restart) { + if (!enabled_) { + return {}; + } std::vector result(1); if (restart || start_) { result[0].Id(0).Keyframe().Update(0); @@ -61,7 +75,13 @@ GenericFrameInfo ScalableVideoControllerNoLayering::OnEncodeDone( } } frame_info.decode_target_indications = {DecodeTargetIndication::kSwitch}; + frame_info.part_of_chain = {true}; return frame_info; } +void ScalableVideoControllerNoLayering::OnRatesUpdated( + const VideoBitrateAllocation& bitrates) { + enabled_ = bitrates.GetBitrate(0, 0) > 0; +} + } // namespace webrtc diff --git a/modules/video_coding/svc/scalable_video_controller_no_layering.h b/modules/video_coding/svc/scalable_video_controller_no_layering.h index e253ffe841..6d66b61c8b 100644 --- a/modules/video_coding/svc/scalable_video_controller_no_layering.h +++ b/modules/video_coding/svc/scalable_video_controller_no_layering.h @@ -28,10 +28,11 @@ class ScalableVideoControllerNoLayering : public ScalableVideoController { std::vector NextFrameConfig(bool restart) override; GenericFrameInfo OnEncodeDone(const LayerFrameConfig& config) override; - void OnRatesUpdated(const VideoBitrateAllocation& bitrates) override {} + void OnRatesUpdated(const VideoBitrateAllocation& bitrates) override; private: bool start_ = true; + bool enabled_ = true; }; } // namespace webrtc