Bug 1402242: use 2-byte vp8 picture ids always (cherrypick of issue 7877) r=dminor
authorRandell Jesup <rjesup@jesup.org>
Fri, 22 Sep 2017 14:16:59 -0400
changeset 382570 0d8a4ea4b26846cac9ff7df12dce86486d82b451
parent 382569 5d42f8d147c677923fb04ed83a7e41e9a27d4c91
child 382571 889010e4d6cfba305828f90b7954ae5a090862e5
push id32562
push userarchaeopteryx@coole-files.de
push dateSat, 23 Sep 2017 09:38:29 +0000
treeherdermozilla-central@8db0c4ecd94c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdminor
bugs1402242
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1402242: use 2-byte vp8 picture ids always (cherrypick of issue 7877) r=dminor
media/webrtc/trunk/webrtc/modules/rtp_rtcp/source/rtp_format_vp8.cc
media/webrtc/trunk/webrtc/modules/rtp_rtcp/source/rtp_format_vp8_test_helper.cc
media/webrtc/trunk/webrtc/modules/rtp_rtcp/source/rtp_format_vp8_unittest.cc
--- a/media/webrtc/trunk/webrtc/modules/rtp_rtcp/source/rtp_format_vp8.cc
+++ b/media/webrtc/trunk/webrtc/modules/rtp_rtcp/source/rtp_format_vp8.cc
@@ -612,19 +612,16 @@ size_t RtpPacketizerVp8::PayloadDescript
     ++length_bytes;  // Include the extension field.
   return length_bytes;
 }
 
 size_t RtpPacketizerVp8::PictureIdLength() const {
   if (hdr_info_.pictureId == kNoPictureId) {
     return 0;
   }
-  if (hdr_info_.pictureId <= 0x7F) {
-    return 1;
-  }
   return 2;
 }
 
 bool RtpPacketizerVp8::XFieldPresent() const {
   return (TIDFieldPresent() || TL0PicIdxFieldPresent() || PictureIdPresent() ||
           KeyIdxFieldPresent());
 }
 
--- a/media/webrtc/trunk/webrtc/modules/rtp_rtcp/source/rtp_format_vp8_test_helper.cc
+++ b/media/webrtc/trunk/webrtc/modules/rtp_rtcp/source/rtp_format_vp8_test_helper.cc
@@ -154,27 +154,21 @@ void RtpFormatVp8TestHelper::CheckHeader
 }
 
 // Verify that the I bit and the PictureID field are both set in accordance
 // with the information in hdr_info_->pictureId.
 void RtpFormatVp8TestHelper::CheckPictureID() {
   auto buffer = packet_.payload();
   if (hdr_info_->pictureId != kNoPictureId) {
     EXPECT_BIT_I_EQ(buffer[1], 1);
-    if (hdr_info_->pictureId > 0x7F) {
-      EXPECT_BIT_EQ(buffer[payload_start_], 7, 1);
-      EXPECT_EQ(buffer[payload_start_] & 0x7F,
-                (hdr_info_->pictureId >> 8) & 0x7F);
-      EXPECT_EQ(buffer[payload_start_ + 1], hdr_info_->pictureId & 0xFF);
-      payload_start_ += 2;
-    } else {
-      EXPECT_BIT_EQ(buffer[payload_start_], 7, 0);
-      EXPECT_EQ(buffer[payload_start_] & 0x7F, (hdr_info_->pictureId) & 0x7F);
-      payload_start_ += 1;
-    }
+    EXPECT_BIT_EQ(buffer[payload_start_], 7, 1);
+    EXPECT_EQ(buffer[payload_start_] & 0x7F,
+              (hdr_info_->pictureId >> 8) & 0x7F);
+    EXPECT_EQ(buffer[payload_start_ + 1], hdr_info_->pictureId & 0xFF);
+    payload_start_ += 2;
   } else {
     EXPECT_BIT_I_EQ(buffer[1], 0);
   }
 }
 
 // Verify that the L bit and the TL0PICIDX field are both set in accordance
 // with the information in hdr_info_->tl0PicIdx.
 void RtpFormatVp8TestHelper::CheckTl0PicIdx() {
--- a/media/webrtc/trunk/webrtc/modules/rtp_rtcp/source/rtp_format_vp8_unittest.cc
+++ b/media/webrtc/trunk/webrtc/modules/rtp_rtcp/source/rtp_format_vp8_unittest.cc
@@ -100,17 +100,17 @@ class RtpPacketizerVp8Test : public ::te
   test::RtpFormatVp8TestHelper* helper_;
 };
 
 TEST_F(RtpPacketizerVp8Test, TestStrictMode) {
   const size_t kSizeVector[] = {10, 8, 27};
   const size_t kNumPartitions = GTEST_ARRAY_SIZE_(kSizeVector);
   ASSERT_TRUE(Init(kSizeVector, kNumPartitions));
 
-  hdr_info_.pictureId = 200;  // > 0x7F should produce 2-byte PictureID.
+  hdr_info_.pictureId = 200;
   const size_t kMaxPayloadSize = 13;
   RtpPacketizerVp8 packetizer(hdr_info_, kMaxPayloadSize, kStrict);
   packetizer.SetPayloadData(helper_->payload_data(),
                             helper_->payload_size(),
                             helper_->fragmentation());
 
   // The expected sizes are obtained by running a verified good implementation.
   const size_t kExpectedSizes[] = {9, 9, 12, 11, 11, 11, 10};
@@ -131,17 +131,17 @@ TEST_F(RtpPacketizerVp8Test, TestStrictM
 // Verify that we get a minimal number of packets if the partition plus header
 // size fits exactly in the maximum packet size.
 // Test is disabled: https://code.google.com/p/webrtc/issues/detail?id=4019.
 TEST_F(RtpPacketizerVp8Test, DISABLED_TestStrictEqualTightPartitions) {
   const size_t kSizeVector[] = {10, 10, 10};
   const size_t kNumPartitions = GTEST_ARRAY_SIZE_(kSizeVector);
   ASSERT_TRUE(Init(kSizeVector, kNumPartitions));
 
-  hdr_info_.pictureId = 200;  // > 0x7F should produce 2-byte PictureID.
+  hdr_info_.pictureId = 200;
   const int kMaxPayloadSize = 14;
   RtpPacketizerVp8 packetizer(hdr_info_, kMaxPayloadSize, kStrict);
   packetizer.SetPayloadData(helper_->payload_data(), helper_->payload_size(),
                             helper_->fragmentation());
 
   // The expected sizes are obtained by running a verified good implementation.
   const size_t kExpectedSizes[] = {14, 14, 14};
   const int kExpectedPart[] = {0, 1, 2};
@@ -154,25 +154,25 @@ TEST_F(RtpPacketizerVp8Test, DISABLED_Te
                                  kExpectedFragStart, kExpectedNum);
 }
 
 TEST_F(RtpPacketizerVp8Test, TestAggregateMode) {
   const size_t kSizeVector[] = {60, 10, 10};
   const size_t kNumPartitions = GTEST_ARRAY_SIZE_(kSizeVector);
   ASSERT_TRUE(Init(kSizeVector, kNumPartitions));
 
-  hdr_info_.pictureId = 20;  // <= 0x7F should produce 1-byte PictureID.
+  hdr_info_.pictureId = 20;
   const size_t kMaxPayloadSize = 25;
   RtpPacketizerVp8 packetizer(hdr_info_, kMaxPayloadSize, kAggregate);
   packetizer.SetPayloadData(helper_->payload_data(),
                             helper_->payload_size(),
                             helper_->fragmentation());
 
-  // The expected sizes are obtained by running a verified good implementation.
-  const size_t kExpectedSizes[] = {23, 23, 23, 23};
+  // The expected sizes are obtained by hand.
+  const size_t kExpectedSizes[] = {24, 24, 24, 24};
   const int kExpectedPart[] = {0, 0, 0, 1};
   const bool kExpectedFragStart[] = {true, false, false, true};
   const size_t kExpectedNum = GTEST_ARRAY_SIZE_(kExpectedSizes);
   CHECK_ARRAY_SIZE(kExpectedNum, kExpectedPart);
   CHECK_ARRAY_SIZE(kExpectedNum, kExpectedFragStart);
 
   helper_->GetAllPacketsAndCheck(&packetizer,
                                  kExpectedSizes,
@@ -181,25 +181,25 @@ TEST_F(RtpPacketizerVp8Test, TestAggrega
                                  kExpectedNum);
 }
 
 TEST_F(RtpPacketizerVp8Test, TestAggregateModeManyPartitions1) {
   const size_t kSizeVector[] = {1600, 200, 200, 200, 200, 200, 200, 200, 200};
   const size_t kNumPartitions = GTEST_ARRAY_SIZE_(kSizeVector);
   ASSERT_TRUE(Init(kSizeVector, kNumPartitions));
 
-  hdr_info_.pictureId = 20;  // <= 0x7F should produce 1-byte PictureID.
+  hdr_info_.pictureId = 20;
   const size_t kMaxPayloadSize = 1000;
   RtpPacketizerVp8 packetizer(hdr_info_, kMaxPayloadSize, kAggregate);
   packetizer.SetPayloadData(helper_->payload_data(),
                             helper_->payload_size(),
                             helper_->fragmentation());
 
-  // The expected sizes are obtained by running a verified good implementation.
-  const size_t kExpectedSizes[] = {803, 803, 803, 803};
+  // The expected sizes are obtained by hand
+  const size_t kExpectedSizes[] = {804, 804, 804, 804};
   const int kExpectedPart[] = {0, 0, 1, 5};
   const bool kExpectedFragStart[] = {true, false, true, true};
   const size_t kExpectedNum = GTEST_ARRAY_SIZE_(kExpectedSizes);
   CHECK_ARRAY_SIZE(kExpectedNum, kExpectedPart);
   CHECK_ARRAY_SIZE(kExpectedNum, kExpectedFragStart);
 
   helper_->GetAllPacketsAndCheck(&packetizer,
                                  kExpectedSizes,
@@ -208,25 +208,25 @@ TEST_F(RtpPacketizerVp8Test, TestAggrega
                                  kExpectedNum);
 }
 
 TEST_F(RtpPacketizerVp8Test, TestAggregateModeManyPartitions2) {
   const size_t kSizeVector[] = {1599, 200, 200, 200, 1600, 200, 200, 200, 200};
   const size_t kNumPartitions = GTEST_ARRAY_SIZE_(kSizeVector);
   ASSERT_TRUE(Init(kSizeVector, kNumPartitions));
 
-  hdr_info_.pictureId = 20;  // <= 0x7F should produce 1-byte PictureID.
+  hdr_info_.pictureId = 20;
   const size_t kMaxPayloadSize = 1000;
   RtpPacketizerVp8 packetizer(hdr_info_, kMaxPayloadSize, kAggregate);
   packetizer.SetPayloadData(helper_->payload_data(),
                             helper_->payload_size(),
                             helper_->fragmentation());
 
-  // The expected sizes are obtained by running a verified good implementation.
-  const size_t kExpectedSizes[] = {803, 802, 603, 803, 803, 803};
+  // The expected sizes are obtained by hand
+  const size_t kExpectedSizes[] = {804, 803, 604, 804, 804, 804};
   const int kExpectedPart[] = {0, 0, 1, 4, 4, 5};
   const bool kExpectedFragStart[] = {true, false, true, true, false, true};
   const size_t kExpectedNum = GTEST_ARRAY_SIZE_(kExpectedSizes);
   CHECK_ARRAY_SIZE(kExpectedNum, kExpectedPart);
   CHECK_ARRAY_SIZE(kExpectedNum, kExpectedFragStart);
 
   helper_->GetAllPacketsAndCheck(&packetizer,
                                  kExpectedSizes,
@@ -235,25 +235,25 @@ TEST_F(RtpPacketizerVp8Test, TestAggrega
                                  kExpectedNum);
 }
 
 TEST_F(RtpPacketizerVp8Test, TestAggregateModeTwoLargePartitions) {
   const size_t kSizeVector[] = {1654, 2268};
   const size_t kNumPartitions = GTEST_ARRAY_SIZE_(kSizeVector);
   ASSERT_TRUE(Init(kSizeVector, kNumPartitions));
 
-  hdr_info_.pictureId = 20;  // <= 0x7F should produce 1-byte PictureID.
+  hdr_info_.pictureId = 20;
   const size_t kMaxPayloadSize = 1460;
   RtpPacketizerVp8 packetizer(hdr_info_, kMaxPayloadSize, kAggregate);
   packetizer.SetPayloadData(helper_->payload_data(),
                             helper_->payload_size(),
                             helper_->fragmentation());
 
-  // The expected sizes are obtained by running a verified good implementation.
-  const size_t kExpectedSizes[] = {830, 830, 1137, 1137};
+  // The expected sizes are obtained by hand
+  const size_t kExpectedSizes[] = {831, 831, 1138, 1138};
   const int kExpectedPart[] = {0, 0, 1, 1};
   const bool kExpectedFragStart[] = {true, false, true, false};
   const size_t kExpectedNum = GTEST_ARRAY_SIZE_(kExpectedSizes);
   CHECK_ARRAY_SIZE(kExpectedNum, kExpectedPart);
   CHECK_ARRAY_SIZE(kExpectedNum, kExpectedFragStart);
 
   helper_->GetAllPacketsAndCheck(&packetizer,
                                  kExpectedSizes,
@@ -263,17 +263,17 @@ TEST_F(RtpPacketizerVp8Test, TestAggrega
 }
 
 // Verify that EqualSize mode is forced if fragmentation info is missing.
 TEST_F(RtpPacketizerVp8Test, TestEqualSizeModeFallback) {
   const size_t kSizeVector[] = {10, 10, 10};
   const size_t kNumPartitions = GTEST_ARRAY_SIZE_(kSizeVector);
   ASSERT_TRUE(Init(kSizeVector, kNumPartitions));
 
-  hdr_info_.pictureId = 200;          // > 0x7F should produce 2-byte PictureID
+  hdr_info_.pictureId = 200;
   const size_t kMaxPayloadSize = 12;  // Small enough to produce 4 packets.
   RtpPacketizerVp8 packetizer(hdr_info_, kMaxPayloadSize);
   packetizer.SetPayloadData(
       helper_->payload_data(), helper_->payload_size(), NULL);
 
   // Expecting three full packets, and one with the remainder.
   const size_t kExpectedSizes[] = {12, 11, 12, 11};
   const int kExpectedPart[] = {0, 0, 0, 0};  // Always 0 for equal size mode.