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

Unified Diff: webrtc/modules/video_coding/rtp_frame_reference_finder.cc

Issue 2985283002: Unwrap picture ids in the RtpFrameReferencerFinder. (Closed)
Patch Set: . Created 3 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/video_coding/rtp_frame_reference_finder.cc
diff --git a/webrtc/modules/video_coding/rtp_frame_reference_finder.cc b/webrtc/modules/video_coding/rtp_frame_reference_finder.cc
index 8d74c363c511b07420f961e75f93e152c8df71df..970d3e98301f44717443e02ff5d1d2ba35fff26e 100644
--- a/webrtc/modules/video_coding/rtp_frame_reference_finder.cc
+++ b/webrtc/modules/video_coding/rtp_frame_reference_finder.cc
@@ -27,7 +27,9 @@ RtpFrameReferenceFinder::RtpFrameReferenceFinder(
last_unwrap_(-1),
current_ss_idx_(0),
cleared_to_seq_num_(-1),
- frame_callback_(frame_callback) {}
+ frame_callback_(frame_callback),
+ generic_unwrapper_(100000),
terelius 2017/08/18 11:53:16 Is this the starting point for unwrapped numbers?
philipel 2017/08/24 10:46:10 Changed the SeqNumUnwrapper default start value to
+ unwrapper_(100000) {}
void RtpFrameReferenceFinder::ManageFrame(
std::unique_ptr<RtpFrameObject> frame) {
@@ -176,7 +178,7 @@ RtpFrameReferenceFinder::ManageFrameGeneric(RtpFrameObject* frame,
if (last_unwrap_ == -1)
last_unwrap_ = picture_id;
- frame->picture_id = UnwrapPictureId(picture_id % kPicIdLength);
+ frame->picture_id = unwrapper_.Unwrap(picture_id);
frame->num_references = frame->frame_type() == kVideoFrameKey ? 0 : 1;
frame->references[0] = frame->picture_id - 1;
return kHandOff;
@@ -228,14 +230,15 @@ RtpFrameReferenceFinder::ManageFrameGeneric(RtpFrameObject* frame,
// picture id according to some incrementing counter.
frame->picture_id = frame->last_seq_num();
frame->num_references = frame->frame_type() == kVideoFrameDelta;
- frame->references[0] = last_picture_id_gop;
- if (AheadOf(frame->picture_id, last_picture_id_gop)) {
+ frame->references[0] = generic_unwrapper_.Unwrap(last_picture_id_gop);
+ if (AheadOf<uint16_t>(frame->picture_id, last_picture_id_gop)) {
seq_num_it->second.first = frame->picture_id;
seq_num_it->second.second = frame->picture_id;
}
last_picture_id_ = frame->picture_id;
UpdateLastPictureIdWithPadding(frame->picture_id);
+ frame->picture_id = generic_unwrapper_.Unwrap(frame->picture_id);
return kHandOff;
}
@@ -367,7 +370,6 @@ void RtpFrameReferenceFinder::UpdateLayerInfoVp8(RtpFrameObject* frame) {
rtc::Optional<RTPVideoTypeHeader> rtp_codec_header = frame->GetCodecHeader();
RTC_DCHECK(rtp_codec_header);
const RTPVideoHeaderVP8& codec_header = rtp_codec_header->VP8;
-
uint8_t tl0_pic_idx = codec_header.tl0PicIdx;
uint8_t temporal_index = codec_header.temporalIdx;
auto layer_info_it = layer_info_.find(tl0_pic_idx);
@@ -394,7 +396,8 @@ void RtpFrameReferenceFinder::UpdateLayerInfoVp8(RtpFrameObject* frame) {
RtpFrameReferenceFinder::FrameDecision RtpFrameReferenceFinder::ManageFrameVp9(
RtpFrameObject* frame) {
rtc::Optional<RTPVideoTypeHeader> rtp_codec_header = frame->GetCodecHeader();
- RTC_DCHECK(rtp_codec_header);
+ if (!rtp_codec_header)
+ return kDrop;
const RTPVideoHeaderVP9& codec_header = rtp_codec_header->VP9;
if (codec_header.picture_id == kNoPictureId ||
@@ -585,22 +588,8 @@ bool RtpFrameReferenceFinder::UpSwitchInIntervalVp9(uint16_t picture_id,
void RtpFrameReferenceFinder::UnwrapPictureIds(RtpFrameObject* frame) {
for (size_t i = 0; i < frame->num_references; ++i)
- frame->references[i] = UnwrapPictureId(frame->references[i]);
- frame->picture_id = UnwrapPictureId(frame->picture_id);
-}
-
-uint16_t RtpFrameReferenceFinder::UnwrapPictureId(uint16_t picture_id) {
- RTC_DCHECK_NE(-1, last_unwrap_);
-
- uint16_t unwrap_truncated = last_unwrap_ % kPicIdLength;
- uint16_t diff = MinDiff<uint16_t, kPicIdLength>(unwrap_truncated, picture_id);
-
- if (AheadOf<uint16_t, kPicIdLength>(picture_id, unwrap_truncated))
- last_unwrap_ = Add<1 << 16>(last_unwrap_, diff);
- else
- last_unwrap_ = Subtract<1 << 16>(last_unwrap_, diff);
-
- return last_unwrap_;
+ frame->references[i] = unwrapper_.Unwrap(frame->references[i]);
+ frame->picture_id = unwrapper_.Unwrap(frame->picture_id);
}
} // namespace video_coding

Powered by Google App Engine
This is Rietveld 408576698