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}
This commit is contained in:

committed by
Commit Bot

parent
a3f3ab91dd
commit
c2f56862a6
@ -20,5 +20,6 @@ rtc_source_set("generic_frame_descriptor") {
|
||||
"../../rtc_base:checks",
|
||||
"//third_party/abseil-cpp/absl/container:inlined_vector",
|
||||
"//third_party/abseil-cpp/absl/strings",
|
||||
"//third_party/abseil-cpp/absl/types:optional",
|
||||
]
|
||||
}
|
||||
|
@ -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 @@ GenericFrameInfo::Builder& GenericFrameInfo::Builder::Fdiffs(
|
||||
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
|
||||
|
@ -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 @@ struct CodecBufferUsage {
|
||||
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 @@ struct GenericFrameInfo {
|
||||
~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 @@ class GenericFrameInfo::Builder {
|
||||
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_
|
||||
|
@ -585,12 +585,12 @@ void DefaultTemporalLayers::OnRttUpdate(int64_t rtt_ms) {}
|
||||
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;
|
||||
|
@ -77,8 +77,7 @@ class DefaultTemporalLayers final : public Vp8FrameBufferController {
|
||||
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 @@ class DefaultTemporalLayers final : public Vp8FrameBufferController {
|
||||
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.
|
||||
|
@ -421,12 +421,12 @@ void ScreenshareLayers::OnRttUpdate(int64_t rtt_ms) {}
|
||||
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;
|
||||
|
@ -81,8 +81,7 @@ class ScreenshareLayers final : public Vp8FrameBufferController {
|
||||
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 @@ class ScreenshareLayers final : public Vp8FrameBufferController {
|
||||
} layers_[kMaxNumTemporalLayers];
|
||||
|
||||
void UpdateHistograms();
|
||||
TemplateStructure GetTemplateStructure(int num_layers) const;
|
||||
FrameDependencyStructure GetTemplateStructure(int num_layers) const;
|
||||
|
||||
// Data for histogram statistics.
|
||||
struct Stats {
|
||||
|
@ -107,7 +107,7 @@ struct RTC_EXPORT CodecSpecificInfo {
|
||||
VideoCodecType codecType;
|
||||
CodecSpecificInfoUnion codecSpecific;
|
||||
absl::optional<GenericFrameInfo> generic_frame_info;
|
||||
absl::optional<TemplateStructure> template_structure;
|
||||
absl::optional<FrameDependencyStructure> template_structure;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
Reference in New Issue
Block a user