Support layer skipping in S2T1 structure
Bug: webrtc:11999 Change-Id: I22bcf357d29dfdf93239b1b71732a647d9b0557a Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/189548 Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Reviewed-by: Philip Eliasson <philipel@webrtc.org> Cr-Commit-Position: refs/heads/master@{#32442}
This commit is contained in:
parent
0607c962c1
commit
82031310f5
@ -18,24 +18,15 @@
|
|||||||
#include "rtc_base/logging.h"
|
#include "rtc_base/logging.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
namespace {
|
|
||||||
|
|
||||||
constexpr auto kNotPresent = DecodeTargetIndication::kNotPresent;
|
constexpr int ScalabilityStructureS2T1::kNumSpatialLayers;
|
||||||
constexpr auto kSwitch = DecodeTargetIndication::kSwitch;
|
|
||||||
|
|
||||||
constexpr DecodeTargetIndication kDtis[2][2] = {
|
|
||||||
{kSwitch, kNotPresent}, // S0
|
|
||||||
{kNotPresent, kSwitch}, // S1
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
ScalabilityStructureS2T1::~ScalabilityStructureS2T1() = default;
|
ScalabilityStructureS2T1::~ScalabilityStructureS2T1() = default;
|
||||||
|
|
||||||
ScalableVideoController::StreamLayersConfig
|
ScalableVideoController::StreamLayersConfig
|
||||||
ScalabilityStructureS2T1::StreamConfig() const {
|
ScalabilityStructureS2T1::StreamConfig() const {
|
||||||
StreamLayersConfig result;
|
StreamLayersConfig result;
|
||||||
result.num_spatial_layers = 2;
|
result.num_spatial_layers = kNumSpatialLayers;
|
||||||
result.num_temporal_layers = 1;
|
result.num_temporal_layers = 1;
|
||||||
result.scaling_factor_num[0] = 1;
|
result.scaling_factor_num[0] = 1;
|
||||||
result.scaling_factor_den[0] = 2;
|
result.scaling_factor_den[0] = 2;
|
||||||
@ -44,8 +35,8 @@ ScalabilityStructureS2T1::StreamConfig() const {
|
|||||||
|
|
||||||
FrameDependencyStructure ScalabilityStructureS2T1::DependencyStructure() const {
|
FrameDependencyStructure ScalabilityStructureS2T1::DependencyStructure() const {
|
||||||
FrameDependencyStructure structure;
|
FrameDependencyStructure structure;
|
||||||
structure.num_decode_targets = 2;
|
structure.num_decode_targets = kNumSpatialLayers;
|
||||||
structure.num_chains = 2;
|
structure.num_chains = kNumSpatialLayers;
|
||||||
structure.decode_target_protected_by_chain = {0, 1};
|
structure.decode_target_protected_by_chain = {0, 1};
|
||||||
structure.templates.resize(4);
|
structure.templates.resize(4);
|
||||||
structure.templates[0].S(0).Dtis("S-").ChainDiffs({2, 1}).FrameDiffs({2});
|
structure.templates[0].S(0).Dtis("S-").ChainDiffs({2, 1}).FrameDiffs({2});
|
||||||
@ -57,35 +48,50 @@ FrameDependencyStructure ScalabilityStructureS2T1::DependencyStructure() const {
|
|||||||
|
|
||||||
std::vector<ScalableVideoController::LayerFrameConfig>
|
std::vector<ScalableVideoController::LayerFrameConfig>
|
||||||
ScalabilityStructureS2T1::NextFrameConfig(bool restart) {
|
ScalabilityStructureS2T1::NextFrameConfig(bool restart) {
|
||||||
std::vector<LayerFrameConfig> result(2);
|
if (restart) {
|
||||||
// Buffer0 keeps latest S0T0 frame, Buffer1 keeps latest S1T0 frame.
|
can_reference_frame_for_spatial_id_.reset();
|
||||||
if (restart || keyframe_) {
|
|
||||||
result[0].S(0).Keyframe().Update(0);
|
|
||||||
result[1].S(1).Keyframe().Update(1);
|
|
||||||
keyframe_ = false;
|
|
||||||
} else {
|
|
||||||
result[0].S(0).ReferenceAndUpdate(0);
|
|
||||||
result[1].S(1).ReferenceAndUpdate(1);
|
|
||||||
}
|
}
|
||||||
return result;
|
std::vector<LayerFrameConfig> configs;
|
||||||
|
configs.reserve(kNumSpatialLayers);
|
||||||
|
for (int sid = 0; sid < kNumSpatialLayers; ++sid) {
|
||||||
|
if (!active_decode_targets_[sid]) {
|
||||||
|
can_reference_frame_for_spatial_id_.reset(sid);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
configs.emplace_back();
|
||||||
|
LayerFrameConfig& config = configs.back().S(sid);
|
||||||
|
if (can_reference_frame_for_spatial_id_[sid]) {
|
||||||
|
config.ReferenceAndUpdate(sid);
|
||||||
|
} else {
|
||||||
|
config.Keyframe().Update(sid);
|
||||||
|
can_reference_frame_for_spatial_id_.set(sid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return configs;
|
||||||
}
|
}
|
||||||
|
|
||||||
GenericFrameInfo ScalabilityStructureS2T1::OnEncodeDone(
|
GenericFrameInfo ScalabilityStructureS2T1::OnEncodeDone(
|
||||||
const LayerFrameConfig& config) {
|
const LayerFrameConfig& config) {
|
||||||
GenericFrameInfo frame_info;
|
GenericFrameInfo frame_info;
|
||||||
if (config.SpatialId() < 0 ||
|
|
||||||
config.SpatialId() >= int{ABSL_ARRAYSIZE(kDtis)}) {
|
|
||||||
RTC_LOG(LS_ERROR) << "Unexpected spatial id " << config.SpatialId();
|
|
||||||
return frame_info;
|
|
||||||
}
|
|
||||||
frame_info.spatial_id = config.SpatialId();
|
frame_info.spatial_id = config.SpatialId();
|
||||||
frame_info.temporal_id = config.TemporalId();
|
frame_info.temporal_id = config.TemporalId();
|
||||||
frame_info.encoder_buffers = std::move(config.Buffers());
|
frame_info.encoder_buffers = config.Buffers();
|
||||||
frame_info.decode_target_indications.assign(
|
frame_info.decode_target_indications = {
|
||||||
std::begin(kDtis[config.SpatialId()]),
|
config.SpatialId() == 0 ? DecodeTargetIndication::kSwitch
|
||||||
std::end(kDtis[config.SpatialId()]));
|
: DecodeTargetIndication::kNotPresent,
|
||||||
|
config.SpatialId() == 1 ? DecodeTargetIndication::kSwitch
|
||||||
|
: DecodeTargetIndication::kNotPresent,
|
||||||
|
};
|
||||||
frame_info.part_of_chain = {config.SpatialId() == 0, config.SpatialId() == 1};
|
frame_info.part_of_chain = {config.SpatialId() == 0, config.SpatialId() == 1};
|
||||||
|
frame_info.active_decode_targets = active_decode_targets_;
|
||||||
return frame_info;
|
return frame_info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScalabilityStructureS2T1::OnRatesUpdated(
|
||||||
|
const VideoBitrateAllocation& bitrates) {
|
||||||
|
active_decode_targets_.set(0, bitrates.GetBitrate(/*sid=*/0, /*tid=*/0) > 0);
|
||||||
|
active_decode_targets_.set(1, bitrates.GetBitrate(/*sid=*/1, /*tid=*/0) > 0);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|||||||
@ -13,6 +13,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "api/transport/rtp/dependency_descriptor.h"
|
#include "api/transport/rtp/dependency_descriptor.h"
|
||||||
|
#include "api/video/video_bitrate_allocation.h"
|
||||||
#include "common_video/generic_frame_descriptor/generic_frame_info.h"
|
#include "common_video/generic_frame_descriptor/generic_frame_info.h"
|
||||||
#include "modules/video_coding/svc/scalable_video_controller.h"
|
#include "modules/video_coding/svc/scalable_video_controller.h"
|
||||||
|
|
||||||
@ -30,9 +31,13 @@ class ScalabilityStructureS2T1 : public ScalableVideoController {
|
|||||||
|
|
||||||
std::vector<LayerFrameConfig> NextFrameConfig(bool restart) override;
|
std::vector<LayerFrameConfig> NextFrameConfig(bool restart) override;
|
||||||
GenericFrameInfo OnEncodeDone(const LayerFrameConfig& config) override;
|
GenericFrameInfo OnEncodeDone(const LayerFrameConfig& config) override;
|
||||||
|
void OnRatesUpdated(const VideoBitrateAllocation& bitrates) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool keyframe_ = true;
|
static constexpr int kNumSpatialLayers = 2;
|
||||||
|
|
||||||
|
std::bitset<kNumSpatialLayers> can_reference_frame_for_spatial_id_;
|
||||||
|
std::bitset<32> active_decode_targets_ = 0b11;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|||||||
@ -324,7 +324,8 @@ INSTANTIATE_TEST_SUITE_P(
|
|||||||
SvcTestParam{"L2T2_KEY", /*num_temporal_units=*/4},
|
SvcTestParam{"L2T2_KEY", /*num_temporal_units=*/4},
|
||||||
SvcTestParam{"L3T1", /*num_temporal_units=*/3},
|
SvcTestParam{"L3T1", /*num_temporal_units=*/3},
|
||||||
SvcTestParam{"L3T3", /*num_temporal_units=*/8},
|
SvcTestParam{"L3T3", /*num_temporal_units=*/8},
|
||||||
SvcTestParam{"L3T3_KEY", /*num_temporal_units=*/8}),
|
SvcTestParam{"L3T3_KEY", /*num_temporal_units=*/8},
|
||||||
|
SvcTestParam{"S2T1", /*num_temporal_units=*/3}),
|
||||||
[](const testing::TestParamInfo<SvcTestParam>& info) {
|
[](const testing::TestParamInfo<SvcTestParam>& info) {
|
||||||
return info.param.name;
|
return info.param.name;
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user