Extend structures to store updated version of the dependency descriptor
Rename structures to match terminology in the spec
Bug: webrtc:10342
Change-Id: I1329abaca98ae7f82307451032d5ce1533e80772
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/143960
Reviewed-by: Philip Eliasson <philipel@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28402}
diff --git a/common_video/generic_frame_descriptor/BUILD.gn b/common_video/generic_frame_descriptor/BUILD.gn
index dc9461a..6b8434e 100644
--- a/common_video/generic_frame_descriptor/BUILD.gn
+++ b/common_video/generic_frame_descriptor/BUILD.gn
@@ -20,5 +20,6 @@
"../../rtc_base:checks",
"//third_party/abseil-cpp/absl/container:inlined_vector",
"//third_party/abseil-cpp/absl/strings",
+ "//third_party/abseil-cpp/absl/types:optional",
]
}
diff --git a/common_video/generic_frame_descriptor/generic_frame_info.cc b/common_video/generic_frame_descriptor/generic_frame_info.cc
index 1c01b6c..5c40ddc 100644
--- a/common_video/generic_frame_descriptor/generic_frame_info.cc
+++ b/common_video/generic_frame_descriptor/generic_frame_info.cc
@@ -15,7 +15,7 @@
namespace webrtc {
-absl::InlinedVector<GenericFrameInfo::DecodeTargetIndication, 10>
+absl::InlinedVector<DecodeTargetIndication, 10>
GenericFrameInfo::DecodeTargetInfo(absl::string_view indication_symbols) {
absl::InlinedVector<DecodeTargetIndication, 10> decode_targets;
for (char symbol : indication_symbols) {
@@ -67,10 +67,4 @@
return *this;
}
-TemplateStructure::TemplateStructure() = default;
-TemplateStructure::TemplateStructure(const TemplateStructure&) = default;
-TemplateStructure::TemplateStructure(TemplateStructure&&) = default;
-TemplateStructure& TemplateStructure::operator=(const TemplateStructure&) =
- default;
-TemplateStructure::~TemplateStructure() = default;
} // namespace webrtc
diff --git a/common_video/generic_frame_descriptor/generic_frame_info.h b/common_video/generic_frame_descriptor/generic_frame_info.h
index d12ae88..d54e53d 100644
--- a/common_video/generic_frame_descriptor/generic_frame_info.h
+++ b/common_video/generic_frame_descriptor/generic_frame_info.h
@@ -16,10 +16,85 @@
#include "absl/container/inlined_vector.h"
#include "absl/strings/string_view.h"
+#include "absl/types/optional.h"
#include "api/array_view.h"
#include "api/video/video_codec_constants.h"
namespace webrtc {
+// Structures to build and parse dependency descriptor as described in
+// https://aomediacodec.github.io/av1-rtp-spec/#dependency-descriptor-rtp-header-extension
+class RenderResolution {
+ public:
+ constexpr RenderResolution() = default;
+ constexpr RenderResolution(int width, int height)
+ : width_(width), height_(height) {}
+ RenderResolution(const RenderResolution&) = default;
+ RenderResolution& operator=(const RenderResolution&) = default;
+
+ friend bool operator==(const RenderResolution& lhs,
+ const RenderResolution& rhs) {
+ return lhs.width_ == rhs.width_ && lhs.height_ == rhs.height_;
+ }
+
+ constexpr int Width() const { return width_; }
+ constexpr int Height() const { return height_; }
+
+ private:
+ int width_ = 0;
+ int height_ = 0;
+};
+
+// Relationship of a frame to a Decode target.
+enum class DecodeTargetIndication {
+ kNotPresent = 0, // DecodeTargetInfo symbol '-'
+ kDiscardable = 1, // DecodeTargetInfo symbol 'D'
+ kSwitch = 2, // DecodeTargetInfo symbol 'S'
+ kRequired = 3 // DecodeTargetInfo symbol 'R'
+};
+
+struct FrameDependencyTemplate {
+ friend bool operator==(const FrameDependencyTemplate& lhs,
+ const FrameDependencyTemplate& rhs) {
+ return lhs.spatial_id == rhs.spatial_id &&
+ lhs.temporal_id == rhs.temporal_id &&
+ lhs.decode_target_indications == rhs.decode_target_indications &&
+ lhs.frame_diffs == rhs.frame_diffs &&
+ lhs.chain_diffs == rhs.chain_diffs;
+ }
+
+ int spatial_id = 0;
+ int temporal_id = 0;
+ absl::InlinedVector<DecodeTargetIndication, 10> decode_target_indications;
+ absl::InlinedVector<int, 4> frame_diffs;
+ absl::InlinedVector<int, 4> chain_diffs;
+};
+
+struct FrameDependencyStructure {
+ friend bool operator==(const FrameDependencyStructure& lhs,
+ const FrameDependencyStructure& rhs) {
+ return lhs.num_decode_targets == rhs.num_decode_targets &&
+ lhs.num_chains == rhs.num_chains &&
+ lhs.decode_target_protected_by_chain ==
+ rhs.decode_target_protected_by_chain &&
+ lhs.resolutions == rhs.resolutions && lhs.templates == rhs.templates;
+ }
+
+ int structure_id = 0;
+ int num_decode_targets = 0;
+ int num_chains = 0;
+ absl::InlinedVector<int, 10> decode_target_protected_by_chain;
+ absl::InlinedVector<RenderResolution, 4> resolutions;
+ std::vector<FrameDependencyTemplate> templates;
+};
+
+struct DependencyDescriptor {
+ bool first_packet_in_frame = true;
+ bool last_packet_in_frame = true;
+ bool has_structure_attached = false;
+ int frame_number = 0;
+ FrameDependencyTemplate frame_dependencies;
+ absl::optional<RenderResolution> resolution;
+};
// Describes how a certain encoder buffer was used when encoding a frame.
struct CodecBufferUsage {
@@ -31,14 +106,7 @@
bool updated = false;
};
-struct GenericFrameInfo {
- enum class DecodeTargetIndication {
- kNotPresent, // DecodeTargetInfo symbol '-'
- kDiscardable, // DecodeTargetInfo symbol 'D'
- kSwitch, // DecodeTargetInfo symbol 'S'
- kRequired // DecodeTargetInfo symbol 'R'
- };
-
+struct GenericFrameInfo : public FrameDependencyTemplate {
static absl::InlinedVector<DecodeTargetIndication, 10> DecodeTargetInfo(
absl::string_view indication_symbols);
@@ -49,10 +117,6 @@
~GenericFrameInfo();
int64_t frame_id = 0;
- int temporal_id = 0;
- int spatial_id = 0;
- absl::InlinedVector<int, 10> frame_diffs;
- absl::InlinedVector<DecodeTargetIndication, 10> decode_target_indications;
absl::InlinedVector<CodecBufferUsage, kMaxEncoderBuffers> encoder_buffers;
};
@@ -71,16 +135,6 @@
GenericFrameInfo info_;
};
-struct TemplateStructure {
- TemplateStructure();
- TemplateStructure(const TemplateStructure&);
- TemplateStructure(TemplateStructure&&);
- TemplateStructure& operator=(const TemplateStructure&);
- ~TemplateStructure();
-
- int num_decode_targets = 0;
- std::vector<GenericFrameInfo> templates;
-};
} // namespace webrtc
#endif // COMMON_VIDEO_GENERIC_FRAME_DESCRIPTOR_GENERIC_FRAME_INFO_H_
diff --git a/modules/video_coding/codecs/vp8/default_temporal_layers.cc b/modules/video_coding/codecs/vp8/default_temporal_layers.cc
index 986ea2e..84e948e 100644
--- a/modules/video_coding/codecs/vp8/default_temporal_layers.cc
+++ b/modules/video_coding/codecs/vp8/default_temporal_layers.cc
@@ -585,12 +585,12 @@
void DefaultTemporalLayers::OnLossNotification(
const VideoEncoder::LossNotification& loss_notification) {}
-TemplateStructure DefaultTemporalLayers::GetTemplateStructure(
+FrameDependencyStructure DefaultTemporalLayers::GetTemplateStructure(
int num_layers) const {
RTC_CHECK_LT(num_layers, 5);
RTC_CHECK_GT(num_layers, 0);
- TemplateStructure template_structure;
+ FrameDependencyStructure template_structure;
template_structure.num_decode_targets = num_layers;
using Builder = GenericFrameInfo::Builder;
diff --git a/modules/video_coding/codecs/vp8/default_temporal_layers.h b/modules/video_coding/codecs/vp8/default_temporal_layers.h
index cb1cbbe..9f86d40 100644
--- a/modules/video_coding/codecs/vp8/default_temporal_layers.h
+++ b/modules/video_coding/codecs/vp8/default_temporal_layers.h
@@ -77,8 +77,7 @@
GenericFrameInfo::DecodeTargetInfo(indication_symbols)),
frame_config(frame_config) {}
- absl::InlinedVector<GenericFrameInfo::DecodeTargetIndication, 10>
- decode_target_indications;
+ absl::InlinedVector<DecodeTargetIndication, 10> decode_target_indications;
Vp8FrameConfig frame_config;
};
@@ -93,7 +92,7 @@
const std::vector<DependencyInfo> temporal_pattern_;
// Set of buffers that are never updated except by keyframes.
std::set<Vp8FrameConfig::Vp8BufferReference> kf_buffers_;
- TemplateStructure GetTemplateStructure(int num_layers) const;
+ FrameDependencyStructure GetTemplateStructure(int num_layers) const;
uint8_t pattern_idx_;
// Updated cumulative bitrates, per temporal layer.
diff --git a/modules/video_coding/codecs/vp8/screenshare_layers.cc b/modules/video_coding/codecs/vp8/screenshare_layers.cc
index c8ea6ca..b5b963e 100644
--- a/modules/video_coding/codecs/vp8/screenshare_layers.cc
+++ b/modules/video_coding/codecs/vp8/screenshare_layers.cc
@@ -421,12 +421,12 @@
void ScreenshareLayers::OnLossNotification(
const VideoEncoder::LossNotification& loss_notification) {}
-TemplateStructure ScreenshareLayers::GetTemplateStructure(
+FrameDependencyStructure ScreenshareLayers::GetTemplateStructure(
int num_layers) const {
RTC_CHECK_LT(num_layers, 3);
RTC_CHECK_GT(num_layers, 0);
- TemplateStructure template_structure;
+ FrameDependencyStructure template_structure;
template_structure.num_decode_targets = num_layers;
using Builder = GenericFrameInfo::Builder;
diff --git a/modules/video_coding/codecs/vp8/screenshare_layers.h b/modules/video_coding/codecs/vp8/screenshare_layers.h
index d7de527..5270ffe 100644
--- a/modules/video_coding/codecs/vp8/screenshare_layers.h
+++ b/modules/video_coding/codecs/vp8/screenshare_layers.h
@@ -81,8 +81,7 @@
GenericFrameInfo::DecodeTargetInfo(indication_symbols)),
frame_config(frame_config) {}
- absl::InlinedVector<GenericFrameInfo::DecodeTargetIndication, 10>
- decode_target_indications;
+ absl::InlinedVector<DecodeTargetIndication, 10> decode_target_indications;
Vp8FrameConfig frame_config;
};
@@ -140,7 +139,7 @@
} layers_[kMaxNumTemporalLayers];
void UpdateHistograms();
- TemplateStructure GetTemplateStructure(int num_layers) const;
+ FrameDependencyStructure GetTemplateStructure(int num_layers) const;
// Data for histogram statistics.
struct Stats {
diff --git a/modules/video_coding/include/video_codec_interface.h b/modules/video_coding/include/video_codec_interface.h
index 4aa13ac..e66dea7 100644
--- a/modules/video_coding/include/video_codec_interface.h
+++ b/modules/video_coding/include/video_codec_interface.h
@@ -107,7 +107,7 @@
VideoCodecType codecType;
CodecSpecificInfoUnion codecSpecific;
absl::optional<GenericFrameInfo> generic_frame_info;
- absl::optional<TemplateStructure> template_structure;
+ absl::optional<FrameDependencyStructure> template_structure;
};
} // namespace webrtc