Refactor FrameBuffer to store decoded frames history separately

This will allow to increase the stored decoded frames history size and
optimize it to reduce memory consumption.

Bug: webrtc:9710
Change-Id: I82be0eb376c5d0b61ad5d754e6a37d606b4df29d
Reviewed-on: https://webrtc-review.googlesource.com/c/116686
Commit-Queue: Ilya Nikolaevskiy <ilnik@webrtc.org>
Reviewed-by: Philip Eliasson <philipel@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26200}
This commit is contained in:
Ilya Nikolaevskiy
2019-01-10 15:16:47 +01:00
committed by Commit Bot
parent 0a7d56e0e5
commit 6551faf089
2 changed files with 47 additions and 74 deletions

View File

@ -14,6 +14,7 @@
#include <array>
#include <map>
#include <memory>
#include <set>
#include <utility>
#include <vector>
@ -131,8 +132,7 @@ class FrameBuffer {
void PropagateDecodability(const FrameInfo& info)
RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_);
// Advances |last_decoded_frame_it_| to |decoded| and removes old
// frame info.
// Removes undecodable frames and moves decoded frame to the history.
void AdvanceLastDecodedFrame(FrameMap::iterator decoded)
RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_);
@ -159,7 +159,9 @@ class FrameBuffer {
EncodedFrame* CombineAndDeleteFrames(
const std::vector<EncodedFrame*>& frames) const;
// Stores only undecoded frames.
FrameMap frames_ RTC_GUARDED_BY(crit_);
std::set<VideoLayerFrameId> decoded_frames_history_ RTC_GUARDED_BY(crit_);
rtc::CriticalSection crit_;
Clock* const clock_;
@ -168,11 +170,10 @@ class FrameBuffer {
VCMTiming* const timing_ RTC_GUARDED_BY(crit_);
VCMInterFrameDelay inter_frame_delay_ RTC_GUARDED_BY(crit_);
absl::optional<uint32_t> last_decoded_frame_timestamp_ RTC_GUARDED_BY(crit_);
FrameMap::iterator last_decoded_frame_it_ RTC_GUARDED_BY(crit_);
FrameMap::iterator last_continuous_frame_it_ RTC_GUARDED_BY(crit_);
absl::optional<VideoLayerFrameId> last_decoded_frame_ RTC_GUARDED_BY(crit_);
absl::optional<VideoLayerFrameId> last_continuous_frame_
RTC_GUARDED_BY(crit_);
std::vector<FrameMap::iterator> frames_to_decode_ RTC_GUARDED_BY(crit_);
int num_frames_history_ RTC_GUARDED_BY(crit_);
int num_frames_buffered_ RTC_GUARDED_BY(crit_);
bool stopped_ RTC_GUARDED_BY(crit_);
VCMVideoProtection protection_mode_ RTC_GUARDED_BY(crit_);
VCMReceiveStatisticsCallback* const stats_callback_;