Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(365)

Side by Side Diff: webrtc/modules/video_coding/rtp_frame_reference_finder.h

Issue 2841913002: Stashed frames are now retried in a loop rather than recursively. (Closed)
Patch Set: Apparently RTC_NOTREACHED is not enough for the win compiler. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | webrtc/modules/video_coding/rtp_frame_reference_finder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 26 matching lines...) Expand all
37 virtual void OnCompleteFrame(std::unique_ptr<FrameObject> frame) = 0; 37 virtual void OnCompleteFrame(std::unique_ptr<FrameObject> frame) = 0;
38 }; 38 };
39 39
40 class RtpFrameReferenceFinder { 40 class RtpFrameReferenceFinder {
41 public: 41 public:
42 explicit RtpFrameReferenceFinder(OnCompleteFrameCallback* frame_callback); 42 explicit RtpFrameReferenceFinder(OnCompleteFrameCallback* frame_callback);
43 43
44 // Manage this frame until: 44 // Manage this frame until:
45 // - We have all information needed to determine its references, after 45 // - We have all information needed to determine its references, after
46 // which |frame_callback_| is called with the completed frame, or 46 // which |frame_callback_| is called with the completed frame, or
47 // - We have too many stashed frames (determined by |kMaxStashedFrames) 47 // - We have too many stashed frames (determined by |kMaxStashedFrames|)
48 // so we drop this frame, or 48 // so we drop this frame, or
49 // - It gets cleared by ClearTo, which also means we drop it. 49 // - It gets cleared by ClearTo, which also means we drop it.
50 void ManageFrame(std::unique_ptr<RtpFrameObject> frame); 50 void ManageFrame(std::unique_ptr<RtpFrameObject> frame);
51 51
52 // Notifies that padding has been received, which the reference finder 52 // Notifies that padding has been received, which the reference finder
53 // might need to calculate the references of a frame. 53 // might need to calculate the references of a frame.
54 void PaddingReceived(uint16_t seq_num); 54 void PaddingReceived(uint16_t seq_num);
55 55
56 // Clear all stashed frames that include packets older than |seq_num|. 56 // Clear all stashed frames that include packets older than |seq_num|.
57 void ClearTo(uint16_t seq_num); 57 void ClearTo(uint16_t seq_num);
58 58
59 private: 59 private:
60 static const uint16_t kPicIdLength = 1 << 15; 60 static const uint16_t kPicIdLength = 1 << 15;
61 static const uint8_t kMaxTemporalLayers = 5; 61 static const uint8_t kMaxTemporalLayers = 5;
62 static const int kMaxLayerInfo = 50; 62 static const int kMaxLayerInfo = 50;
63 static const int kMaxStashedFrames = 50; 63 static const int kMaxStashedFrames = 50;
64 static const int kMaxNotYetReceivedFrames = 100; 64 static const int kMaxNotYetReceivedFrames = 100;
65 static const int kMaxGofSaved = 50; 65 static const int kMaxGofSaved = 50;
66 static const int kMaxPaddingAge = 100; 66 static const int kMaxPaddingAge = 100;
67 67
68 enum FrameDecision { kStash, kHandOff, kDrop };
68 69
69 struct GofInfo { 70 struct GofInfo {
70 GofInfo(GofInfoVP9* gof, uint16_t last_picture_id) 71 GofInfo(GofInfoVP9* gof, uint16_t last_picture_id)
71 : gof(gof), last_picture_id(last_picture_id) {} 72 : gof(gof), last_picture_id(last_picture_id) {}
72 GofInfoVP9* gof; 73 GofInfoVP9* gof;
73 uint16_t last_picture_id; 74 uint16_t last_picture_id;
74 }; 75 };
75 76
76 rtc::CriticalSection crit_; 77 rtc::CriticalSection crit_;
77 78
78 // Find the relevant group of pictures and update its "last-picture-id-with 79 // Find the relevant group of pictures and update its "last-picture-id-with
79 // padding" sequence number. 80 // padding" sequence number.
80 void UpdateLastPictureIdWithPadding(uint16_t seq_num) 81 void UpdateLastPictureIdWithPadding(uint16_t seq_num)
81 EXCLUSIVE_LOCKS_REQUIRED(crit_); 82 EXCLUSIVE_LOCKS_REQUIRED(crit_);
82 83
83 // Retry finding references for all frames that previously didn't have 84 // Retry stashed frames until no more complete frames are found.
84 // all information needed.
85 void RetryStashedFrames() EXCLUSIVE_LOCKS_REQUIRED(crit_); 85 void RetryStashedFrames() EXCLUSIVE_LOCKS_REQUIRED(crit_);
86 86
87 FrameDecision ManageFrameInternal(RtpFrameObject* frame)
88 EXCLUSIVE_LOCKS_REQUIRED(crit_);
89
87 // Find references for generic frames. If |picture_id| is unspecified 90 // Find references for generic frames. If |picture_id| is unspecified
88 // then packet sequence numbers will be used to determine the references 91 // then packet sequence numbers will be used to determine the references
89 // of the frames. 92 // of the frames.
90 void ManageFrameGeneric(std::unique_ptr<RtpFrameObject> frame, 93 FrameDecision ManageFrameGeneric(RtpFrameObject* frame, int picture_id)
91 int picture_id) EXCLUSIVE_LOCKS_REQUIRED(crit_); 94 EXCLUSIVE_LOCKS_REQUIRED(crit_);
92 95
93 // Find references for Vp8 frames 96 // Find references for Vp8 frames
94 void ManageFrameVp8(std::unique_ptr<RtpFrameObject> frame) 97 FrameDecision ManageFrameVp8(RtpFrameObject* frame)
95 EXCLUSIVE_LOCKS_REQUIRED(crit_); 98 EXCLUSIVE_LOCKS_REQUIRED(crit_);
96 99
97 // Updates all necessary state used to determine frame references 100 // Updates necessary layer info state used to determine frame references for
98 // for Vp8 and then calls the |frame_callback| callback with the 101 // Vp8.
99 // completed frame. 102 void UpdateLayerInfoVp8(RtpFrameObject* frame)
100 void CompletedFrameVp8(std::unique_ptr<RtpFrameObject> frame)
101 EXCLUSIVE_LOCKS_REQUIRED(crit_); 103 EXCLUSIVE_LOCKS_REQUIRED(crit_);
102 104
103 // Find references for Vp9 frames 105 // Find references for Vp9 frames
104 void ManageFrameVp9(std::unique_ptr<RtpFrameObject> frame) 106 FrameDecision ManageFrameVp9(RtpFrameObject* frame)
105 EXCLUSIVE_LOCKS_REQUIRED(crit_);
106
107 // Unwrap the picture id and the frame references and then call the
108 // |frame_callback| callback with the completed frame.
109 void CompletedFrameVp9(std::unique_ptr<RtpFrameObject> frame)
110 EXCLUSIVE_LOCKS_REQUIRED(crit_); 107 EXCLUSIVE_LOCKS_REQUIRED(crit_);
111 108
112 // Check if we are missing a frame necessary to determine the references 109 // Check if we are missing a frame necessary to determine the references
113 // for this frame. 110 // for this frame.
114 bool MissingRequiredFrameVp9(uint16_t picture_id, const GofInfo& info) 111 bool MissingRequiredFrameVp9(uint16_t picture_id, const GofInfo& info)
115 EXCLUSIVE_LOCKS_REQUIRED(crit_); 112 EXCLUSIVE_LOCKS_REQUIRED(crit_);
116 113
117 // Updates which frames that have been received. If there is a gap, 114 // Updates which frames that have been received. If there is a gap,
118 // missing frames will be added to |missing_frames_for_layer_| or 115 // missing frames will be added to |missing_frames_for_layer_| or
119 // if this is an already missing frame then it will be removed. 116 // if this is an already missing frame then it will be removed.
120 void FrameReceivedVp9(uint16_t picture_id, GofInfo* info) 117 void FrameReceivedVp9(uint16_t picture_id, GofInfo* info)
121 EXCLUSIVE_LOCKS_REQUIRED(crit_); 118 EXCLUSIVE_LOCKS_REQUIRED(crit_);
122 119
123 // Check if there is a frame with the up-switch flag set in the interval 120 // Check if there is a frame with the up-switch flag set in the interval
124 // (|pid_ref|, |picture_id|) with temporal layer smaller than |temporal_idx|. 121 // (|pid_ref|, |picture_id|) with temporal layer smaller than |temporal_idx|.
125 bool UpSwitchInIntervalVp9(uint16_t picture_id, 122 bool UpSwitchInIntervalVp9(uint16_t picture_id,
126 uint8_t temporal_idx, 123 uint8_t temporal_idx,
127 uint16_t pid_ref) EXCLUSIVE_LOCKS_REQUIRED(crit_); 124 uint16_t pid_ref) EXCLUSIVE_LOCKS_REQUIRED(crit_);
128 125
126 // Unwrap |frame|s picture id and its references to 16 bits.
127 void UnwrapPictureIds(RtpFrameObject* frame) EXCLUSIVE_LOCKS_REQUIRED(crit_);
129 // All picture ids are unwrapped to 16 bits. 128 // All picture ids are unwrapped to 16 bits.
130 uint16_t UnwrapPictureId(uint16_t picture_id) EXCLUSIVE_LOCKS_REQUIRED(crit_); 129 uint16_t UnwrapPictureId(uint16_t picture_id) EXCLUSIVE_LOCKS_REQUIRED(crit_);
131 130
132 // Returns true if the frame is old and should be dropped. 131 // Returns true if the frame is old and should be dropped.
133 // TODO(philipel): Remove when VP9 PID/TL0 does not jump mid-stream (should be 132 // TODO(philipel): Remove when VP9 PID/TL0 does not jump mid-stream (should be
134 // around M59). 133 // around M59).
135 bool Vp9PidTl0Fix(const RtpFrameObject& frame, 134 bool Vp9PidTl0Fix(const RtpFrameObject& frame,
136 int16_t* picture_id, 135 int16_t* picture_id,
137 int16_t* tl0_pic_idx) EXCLUSIVE_LOCKS_REQUIRED(crit_); 136 int16_t* tl0_pic_idx) EXCLUSIVE_LOCKS_REQUIRED(crit_);
138 137
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 int vp9_fix_last_picture_id_ = -1; 221 int vp9_fix_last_picture_id_ = -1;
223 int vp9_fix_pid_offset_ = 0; 222 int vp9_fix_pid_offset_ = 0;
224 int vp9_fix_last_tl0_pic_idx_ = -1; 223 int vp9_fix_last_tl0_pic_idx_ = -1;
225 int vp9_fix_tl0_pic_idx_offset_ = 0; 224 int vp9_fix_tl0_pic_idx_offset_ = 0;
226 }; 225 };
227 226
228 } // namespace video_coding 227 } // namespace video_coding
229 } // namespace webrtc 228 } // namespace webrtc
230 229
231 #endif // WEBRTC_MODULES_VIDEO_CODING_RTP_FRAME_REFERENCE_FINDER_H_ 230 #endif // WEBRTC_MODULES_VIDEO_CODING_RTP_FRAME_REFERENCE_FINDER_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/video_coding/rtp_frame_reference_finder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698