Share constants for dependency descriptor rtp header extension
Bug: webrtc:10342 Change-Id: I9c81215569bd1bd96b953faa359f5a3d32c7d0c4 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/177521 Reviewed-by: Philip Eliasson <philipel@webrtc.org> Reviewed-by: Björn Terelius <terelius@webrtc.org> Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31549}
This commit is contained in:
parent
af0d5bca34
commit
09867d37ed
@ -15,6 +15,12 @@
|
||||
#include "rtc_base/checks.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
constexpr int DependencyDescriptor::kMaxSpatialIds;
|
||||
constexpr int DependencyDescriptor::kMaxTemporalIds;
|
||||
constexpr int DependencyDescriptor::kMaxTemplates;
|
||||
constexpr int DependencyDescriptor::kMaxDecodeTargets;
|
||||
|
||||
namespace webrtc_impl {
|
||||
|
||||
absl::InlinedVector<DecodeTargetIndication, 10> StringToDecodeTargetIndications(
|
||||
|
||||
@ -99,6 +99,11 @@ struct FrameDependencyStructure {
|
||||
};
|
||||
|
||||
struct DependencyDescriptor {
|
||||
static constexpr int kMaxSpatialIds = 4;
|
||||
static constexpr int kMaxTemporalIds = 8;
|
||||
static constexpr int kMaxDecodeTargets = 32;
|
||||
static constexpr int kMaxTemplates = 64;
|
||||
|
||||
bool first_packet_in_frame = true;
|
||||
bool last_packet_in_frame = true;
|
||||
int frame_number = 0;
|
||||
|
||||
@ -18,13 +18,6 @@
|
||||
#include "rtc_base/checks.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace {
|
||||
|
||||
constexpr int kMaxTemporalId = 7;
|
||||
constexpr int kMaxSpatialId = 3;
|
||||
constexpr int kMaxTemplates = 64;
|
||||
|
||||
} // namespace
|
||||
|
||||
RtpDependencyDescriptorReader::RtpDependencyDescriptorReader(
|
||||
rtc::ArrayView<const uint8_t> raw_data,
|
||||
@ -95,7 +88,7 @@ void RtpDependencyDescriptorReader::ReadTemplateLayers() {
|
||||
int spatial_id = 0;
|
||||
NextLayerIdc next_layer_idc;
|
||||
do {
|
||||
if (templates.size() == kMaxTemplates) {
|
||||
if (templates.size() == DependencyDescriptor::kMaxTemplates) {
|
||||
parsing_failed_ = true;
|
||||
break;
|
||||
}
|
||||
@ -107,14 +100,14 @@ void RtpDependencyDescriptorReader::ReadTemplateLayers() {
|
||||
next_layer_idc = static_cast<NextLayerIdc>(ReadBits(2));
|
||||
if (next_layer_idc == kNextTemporalLayer) {
|
||||
temporal_id++;
|
||||
if (temporal_id > kMaxTemporalId) {
|
||||
if (temporal_id >= DependencyDescriptor::kMaxTemporalIds) {
|
||||
parsing_failed_ = true;
|
||||
break;
|
||||
}
|
||||
} else if (next_layer_idc == kNextSpatialLayer) {
|
||||
temporal_id = 0;
|
||||
spatial_id++;
|
||||
if (spatial_id > kMaxSpatialId) {
|
||||
if (spatial_id >= DependencyDescriptor::kMaxSpatialIds) {
|
||||
parsing_failed_ = true;
|
||||
break;
|
||||
}
|
||||
@ -198,9 +191,10 @@ void RtpDependencyDescriptorReader::ReadExtendedFields() {
|
||||
}
|
||||
|
||||
void RtpDependencyDescriptorReader::ReadFrameDependencyDefinition() {
|
||||
size_t template_index = (frame_dependency_template_id_ + kMaxTemplates -
|
||||
structure_->structure_id) %
|
||||
kMaxTemplates;
|
||||
size_t template_index =
|
||||
(frame_dependency_template_id_ + DependencyDescriptor::kMaxTemplates -
|
||||
structure_->structure_id) %
|
||||
DependencyDescriptor::kMaxTemplates;
|
||||
|
||||
if (template_index >= structure_->templates.size()) {
|
||||
parsing_failed_ = true;
|
||||
|
||||
@ -23,8 +23,6 @@
|
||||
namespace webrtc {
|
||||
namespace {
|
||||
|
||||
constexpr int kMaxTemplates = 64;
|
||||
|
||||
enum class NextLayerIdc : uint64_t {
|
||||
kSameLayer = 0,
|
||||
kNextTemporal = 1,
|
||||
@ -35,12 +33,8 @@ enum class NextLayerIdc : uint64_t {
|
||||
|
||||
NextLayerIdc GetNextLayerIdc(const FrameDependencyTemplate& previous,
|
||||
const FrameDependencyTemplate& next) {
|
||||
// TODO(danilchap): Move these constants to header shared between reader and
|
||||
// writer.
|
||||
static constexpr int kMaxSpatialId = 3;
|
||||
static constexpr int kMaxTemporalId = 7;
|
||||
RTC_DCHECK_LE(next.spatial_id, kMaxSpatialId);
|
||||
RTC_DCHECK_LE(next.temporal_id, kMaxTemporalId);
|
||||
RTC_DCHECK_LT(next.spatial_id, DependencyDescriptor::kMaxSpatialIds);
|
||||
RTC_DCHECK_LT(next.temporal_id, DependencyDescriptor::kMaxTemporalIds);
|
||||
|
||||
if (next.spatial_id == previous.spatial_id &&
|
||||
next.temporal_id == previous.temporal_id) {
|
||||
@ -201,7 +195,7 @@ bool RtpDependencyDescriptorWriter::HasExtendedFields() const {
|
||||
uint64_t RtpDependencyDescriptorWriter::TemplateId() const {
|
||||
return (best_template_.template_position - structure_.templates.begin() +
|
||||
structure_.structure_id) %
|
||||
kMaxTemplates;
|
||||
DependencyDescriptor::kMaxTemplates;
|
||||
}
|
||||
|
||||
void RtpDependencyDescriptorWriter::WriteBits(uint64_t val, size_t bit_count) {
|
||||
@ -217,9 +211,10 @@ void RtpDependencyDescriptorWriter::WriteNonSymmetric(uint32_t value,
|
||||
|
||||
void RtpDependencyDescriptorWriter::WriteTemplateDependencyStructure() {
|
||||
RTC_DCHECK_GE(structure_.structure_id, 0);
|
||||
RTC_DCHECK_LT(structure_.structure_id, kMaxTemplates);
|
||||
RTC_DCHECK_LT(structure_.structure_id, DependencyDescriptor::kMaxTemplates);
|
||||
RTC_DCHECK_GT(structure_.num_decode_targets, 0);
|
||||
RTC_DCHECK_LE(structure_.num_decode_targets, 1 << 5);
|
||||
RTC_DCHECK_LE(structure_.num_decode_targets,
|
||||
DependencyDescriptor::kMaxDecodeTargets);
|
||||
|
||||
WriteBits(structure_.structure_id, 6);
|
||||
WriteBits(structure_.num_decode_targets - 1, 5);
|
||||
@ -236,7 +231,7 @@ void RtpDependencyDescriptorWriter::WriteTemplateDependencyStructure() {
|
||||
void RtpDependencyDescriptorWriter::WriteTemplateLayers() {
|
||||
const auto& templates = structure_.templates;
|
||||
RTC_DCHECK(!templates.empty());
|
||||
RTC_DCHECK_LE(templates.size(), kMaxTemplates);
|
||||
RTC_DCHECK_LE(templates.size(), DependencyDescriptor::kMaxTemplates);
|
||||
RTC_DCHECK_EQ(templates[0].spatial_id, 0);
|
||||
RTC_DCHECK_EQ(templates[0].temporal_id, 0);
|
||||
|
||||
|
||||
@ -127,6 +127,7 @@ if (rtc_include_tests) {
|
||||
":scalable_video_controller",
|
||||
"../..:chain_diff_calculator",
|
||||
"../..:frame_dependencies_calculator",
|
||||
"../../../../api/transport/rtp:dependency_descriptor",
|
||||
"../../../../api/video:video_frame_type",
|
||||
"../../../../test:test_support",
|
||||
]
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
#include <string>
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/transport/rtp/dependency_descriptor.h"
|
||||
#include "api/video/video_frame_type.h"
|
||||
#include "modules/video_coding/chain_diff_calculator.h"
|
||||
#include "modules/video_coding/codecs/av1/scalability_structure_l1t2.h"
|
||||
@ -105,7 +106,8 @@ TEST_P(ScalabilityStructureTest,
|
||||
FrameDependencyStructure structure =
|
||||
GetParam().svc_factory()->DependencyStructure();
|
||||
EXPECT_GT(structure.num_decode_targets, 0);
|
||||
EXPECT_LE(structure.num_decode_targets, 32);
|
||||
EXPECT_LE(structure.num_decode_targets,
|
||||
DependencyDescriptor::kMaxDecodeTargets);
|
||||
EXPECT_GE(structure.num_chains, 0);
|
||||
EXPECT_LE(structure.num_chains, structure.num_decode_targets);
|
||||
if (structure.num_chains == 0) {
|
||||
@ -115,7 +117,8 @@ TEST_P(ScalabilityStructureTest,
|
||||
AllOf(SizeIs(structure.num_decode_targets), Each(Ge(0)),
|
||||
Each(Le(structure.num_chains))));
|
||||
}
|
||||
EXPECT_THAT(structure.templates, SizeIs(Lt(size_t{64})));
|
||||
EXPECT_THAT(structure.templates,
|
||||
SizeIs(Lt(size_t{DependencyDescriptor::kMaxTemplates})));
|
||||
}
|
||||
|
||||
TEST_P(ScalabilityStructureTest, TemplatesAreSortedByLayerId) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user