Don't treat picture ids as wrapping in the FrameBuffer2 class.
Picture ids are now unwrapped in the RtpFrameReferenceFinder class, so the
FrameBuffer2 no longer need to treat them as wrapping.
BUG=webrtc:7874
Review-Url: https://codereview.webrtc.org/3012883002
Cr-Original-Commit-Position: refs/heads/master@{#19779}
Cr-Mirrored-From: https://chromium.googlesource.com/external/webrtc
Cr-Mirrored-Commit: 3b3c9c4eb03cb82373a978eb9c5b8c8c08cc7e27
diff --git a/modules/video_coding/frame_buffer2.cc b/modules/video_coding/frame_buffer2.cc
index f314ccb..5b81c5f 100644
--- a/modules/video_coding/frame_buffer2.cc
+++ b/modules/video_coding/frame_buffer2.cc
@@ -248,9 +248,13 @@
}
bool FrameBuffer::ValidReferences(const FrameObject& frame) const {
+ if (frame.picture_id < 0)
+ return false;
+
for (size_t i = 0; i < frame.num_references; ++i) {
- if (AheadOrAt<uint16_t>(frame.references[i], frame.picture_id))
+ if (frame.references[i] < 0 || frame.references[i] >= frame.picture_id)
return false;
+
for (size_t j = i + 1; j < frame.num_references; ++j) {
if (frame.references[i] == frame.references[j])
return false;
diff --git a/modules/video_coding/frame_buffer2.h b/modules/video_coding/frame_buffer2.h
index 5f5173e..77fe485 100644
--- a/modules/video_coding/frame_buffer2.h
+++ b/modules/video_coding/frame_buffer2.h
@@ -76,19 +76,19 @@
private:
struct FrameKey {
- FrameKey() : picture_id(0), spatial_layer(0) {}
- FrameKey(uint16_t picture_id, uint8_t spatial_layer)
+ FrameKey() : picture_id(-1), spatial_layer(0) {}
+ FrameKey(int64_t picture_id, uint8_t spatial_layer)
: picture_id(picture_id), spatial_layer(spatial_layer) {}
bool operator<(const FrameKey& rhs) const {
if (picture_id == rhs.picture_id)
return spatial_layer < rhs.spatial_layer;
- return AheadOf(rhs.picture_id, picture_id);
+ return picture_id < rhs.picture_id;
}
bool operator<=(const FrameKey& rhs) const { return !(rhs < *this); }
- uint16_t picture_id;
+ int64_t picture_id;
uint8_t spatial_layer;
};
diff --git a/modules/video_coding/rtp_frame_reference_finder_unittest.cc b/modules/video_coding/rtp_frame_reference_finder_unittest.cc
index 5500430..a40a727 100644
--- a/modules/video_coding/rtp_frame_reference_finder_unittest.cc
+++ b/modules/video_coding/rtp_frame_reference_finder_unittest.cc
@@ -54,7 +54,7 @@
class TestRtpFrameReferenceFinder : public ::testing::Test,
public OnCompleteFrameCallback {
protected:
- static constexpr uint64_t kUnwrappedSequenceStart = 10000000000000000000UL;
+ static constexpr uint64_t kUnwrappedSequenceStart = 1000000000000000000UL;
TestRtpFrameReferenceFinder()
: rand_(0x8739211),
diff --git a/modules/video_coding/sequence_number_util.h b/modules/video_coding/sequence_number_util.h
index 3e7d64a..053f9d0 100644
--- a/modules/video_coding/sequence_number_util.h
+++ b/modules/video_coding/sequence_number_util.h
@@ -91,11 +91,11 @@
"Type unwrapped must be an unsigned integer smaller than uint64_t.");
public:
- // We want a value that is close to 2^63 for two reasons. Firstly, we
- // can unwrap wrapping numbers in either direction, and secondly, we avoid
- // causing a crash on bad input. We also want the default value to be somewhat
- // human readable, a power of 10 for example.
- static constexpr uint64_t kDefaultStartValue = 10000000000000000000UL;
+ // We want a default value that is close to 2^62 for a two reasons. Firstly,
+ // we can unwrap wrapping numbers in either direction, and secondly, the
+ // unwrapped numbers can be stored in either int64_t or uint64_t. We also want
+ // the default value to be human readable, which makes a power of 10 suitable.
+ static constexpr uint64_t kDefaultStartValue = 1000000000000000000UL;
SeqNumUnwrapper() : last_unwrapped_(kDefaultStartValue) {}
explicit SeqNumUnwrapper(uint64_t start_at) : last_unwrapped_(start_at) {}