Make FrameBuffer support an unlimited number of dependents per frame

Bug: webrtc:10190
Change-Id: I59680ec0dc05bc77dcbef50ddbb83ce2bcd91f7e
Reviewed-on: https://webrtc-review.googlesource.com/c/116788
Reviewed-by: Sergey Silkin <ssilkin@webrtc.org>
Reviewed-by: Philip Eliasson <philipel@webrtc.org>
Commit-Queue: Elad Alon <eladalon@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26196}
This commit is contained in:
Elad Alon
2019-01-10 15:02:54 +01:00
committed by Commit Bot
parent 977cd17316
commit 69321ddfb5
3 changed files with 6 additions and 24 deletions

View File

@ -197,6 +197,7 @@ rtc_static_library("video_coding") {
"../../system_wrappers", "../../system_wrappers",
"../rtp_rtcp:rtp_rtcp_format", "../rtp_rtcp:rtp_rtcp_format",
"../utility:utility", "../utility:utility",
"//third_party/abseil-cpp/absl/container:inlined_vector",
"//third_party/abseil-cpp/absl/types:optional", "//third_party/abseil-cpp/absl/types:optional",
"//third_party/abseil-cpp/absl/types:variant", "//third_party/abseil-cpp/absl/types:variant",
] ]

View File

@ -479,7 +479,7 @@ void FrameBuffer::PropagateContinuity(FrameMap::iterator start) {
// Loop through all dependent frames, and if that frame no longer has // Loop through all dependent frames, and if that frame no longer has
// any unfulfilled dependencies then that frame is continuous as well. // any unfulfilled dependencies then that frame is continuous as well.
for (size_t d = 0; d < frame->second.num_dependent_frames; ++d) { for (size_t d = 0; d < frame->second.dependent_frames.size(); ++d) {
auto frame_ref = frames_.find(frame->second.dependent_frames[d]); auto frame_ref = frames_.find(frame->second.dependent_frames[d]);
RTC_DCHECK(frame_ref != frames_.end()); RTC_DCHECK(frame_ref != frames_.end());
@ -497,8 +497,7 @@ void FrameBuffer::PropagateContinuity(FrameMap::iterator start) {
void FrameBuffer::PropagateDecodability(const FrameInfo& info) { void FrameBuffer::PropagateDecodability(const FrameInfo& info) {
TRACE_EVENT0("webrtc", "FrameBuffer::PropagateDecodability"); TRACE_EVENT0("webrtc", "FrameBuffer::PropagateDecodability");
RTC_CHECK(info.num_dependent_frames < FrameInfo::kMaxNumDependentFrames); for (size_t d = 0; d < info.dependent_frames.size(); ++d) {
for (size_t d = 0; d < info.num_dependent_frames; ++d) {
auto ref_info = frames_.find(info.dependent_frames[d]); auto ref_info = frames_.find(info.dependent_frames[d]);
RTC_DCHECK(ref_info != frames_.end()); RTC_DCHECK(ref_info != frames_.end());
// TODO(philipel): Look into why we've seen this happen. // TODO(philipel): Look into why we've seen this happen.
@ -608,20 +607,7 @@ bool FrameBuffer::UpdateFrameInfoWithIncomingFrame(const EncodedFrame& frame,
if (dep.continuous) if (dep.continuous)
--info->second.num_missing_continuous; --info->second.num_missing_continuous;
// At this point we know we want to insert this frame, so here we frames_[dep.id].dependent_frames.push_back(id);
// intentionally get or create the FrameInfo for this dependency.
FrameInfo* dep_info = &frames_[dep.id];
if (dep_info->num_dependent_frames <
(FrameInfo::kMaxNumDependentFrames - 1)) {
dep_info->dependent_frames[dep_info->num_dependent_frames] = id;
++dep_info->num_dependent_frames;
} else {
RTC_LOG(LS_WARNING) << "Frame with (picture_id:spatial_id) ("
<< dep.id.picture_id << ":"
<< static_cast<int>(dep.id.spatial_layer)
<< ") is referenced by too many frames.";
}
} }
return true; return true;

View File

@ -17,6 +17,7 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#include "absl/container/inlined_vector.h"
#include "api/video/encoded_frame.h" #include "api/video/encoded_frame.h"
#include "modules/video_coding/include/video_coding_defines.h" #include "modules/video_coding/include/video_coding_defines.h"
#include "modules/video_coding/inter_frame_delay.h" #include "modules/video_coding/inter_frame_delay.h"
@ -89,15 +90,9 @@ class FrameBuffer {
FrameInfo(FrameInfo&&); FrameInfo(FrameInfo&&);
~FrameInfo(); ~FrameInfo();
// The maximum number of frames that can depend on this frame.
static constexpr size_t kMaxNumDependentFrames = 8;
// Which other frames that have direct unfulfilled dependencies // Which other frames that have direct unfulfilled dependencies
// on this frame. // on this frame.
// TODO(philipel): Add simple modify/access functions to prevent adding too absl::InlinedVector<VideoLayerFrameId, 8> dependent_frames;
// many |dependent_frames|.
VideoLayerFrameId dependent_frames[kMaxNumDependentFrames];
size_t num_dependent_frames = 0;
// A frame is continiuous if it has all its referenced/indirectly // A frame is continiuous if it has all its referenced/indirectly
// referenced frames. // referenced frames.