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-Commit-Position: refs/heads/master@{#19779}
This commit is contained in:
philipel 2017-09-11 09:38:36 -07:00 committed by Commit Bot
parent 4232273061
commit 3b3c9c4eb0
4 changed files with 15 additions and 11 deletions

View File

@ -248,9 +248,13 @@ void FrameBuffer::Stop() {
}
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;

View File

@ -76,19 +76,19 @@ class FrameBuffer {
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;
};

View File

@ -54,7 +54,7 @@ class FakePacketBuffer : public PacketBuffer {
class TestRtpFrameReferenceFinder : public ::testing::Test,
public OnCompleteFrameCallback {
protected:
static constexpr uint64_t kUnwrappedSequenceStart = 10000000000000000000UL;
static constexpr uint64_t kUnwrappedSequenceStart = 1000000000000000000UL;
TestRtpFrameReferenceFinder()
: rand_(0x8739211),

View File

@ -91,11 +91,11 @@ class SeqNumUnwrapper {
"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) {}