Bugfix in VP8 packetizer

Handle the case with no small partitions in Vp8PartitionAggregator.
Also added a new unit test for the packetizer to verify that the
bug is fixed.

TEST=RtpFormatVp8Test.TestAggregateModeTwoLargePartitions
TBR=stefan@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/348011

git-svn-id: http://webrtc.googlecode.com/svn/trunk@1451 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
henrik.lundin@webrtc.org 2012-01-18 10:01:03 +00:00
parent 8224451ee4
commit 4407edc314
2 changed files with 36 additions and 0 deletions

View File

@ -170,6 +170,36 @@ TEST_F(RtpFormatVp8Test, TestAggregateModeManyPartitions2) {
kExpectedFragStart, kExpectedNum);
}
TEST_F(RtpFormatVp8Test, TestAggregateModeTwoLargePartitions) {
const int kSizeVector[] = {1654, 2268};
const int kNumPartitions = sizeof(kSizeVector) / sizeof(kSizeVector[0]);
ASSERT_TRUE(Init(kSizeVector, kNumPartitions));
hdr_info_.pictureId = 20; // <= 0x7F should produce 1-byte PictureID.
const int kMaxSize = 1460;
RtpFormatVp8 packetizer(helper_->payload_data(),
helper_->payload_size(),
hdr_info_,
kMaxSize,
*(helper_->fragmentation()),
kAggregate);
// The expected sizes are obtained by running a verified good implementation.
const int kExpectedSizes[] = {830, 830, 1137, 1137};
const int kExpectedPart[] = {0, 0, 1, 1};
const bool kExpectedFragStart[] = {true, false, true, false};
const int kExpectedNum = sizeof(kExpectedSizes) / sizeof(kExpectedSizes[0]);
COMPILE_ASSERT(kExpectedNum ==
sizeof(kExpectedPart) / sizeof(kExpectedPart[0]),
kExpectedPart_wrong_size);
COMPILE_ASSERT(kExpectedNum ==
sizeof(kExpectedFragStart) / sizeof(kExpectedFragStart[0]),
kExpectedFragStart_wrong_size);
helper_->GetAllPacketsAndCheck(&packetizer, kExpectedSizes, kExpectedPart,
kExpectedFragStart, kExpectedNum);
}
TEST_F(RtpFormatVp8Test, TestSloppyMode) {
const int kSizeVector[] = {10, 10, 10};
const int kNumPartitions = sizeof(kSizeVector) / sizeof(kSizeVector[0]);

View File

@ -229,9 +229,15 @@ int Vp8PartitionAggregator::CalcNumberOfFragments(int large_partition_size,
int max_size) {
assert(max_size <= max_payload_size);
assert(min_size <= max_size);
assert(max_payload_size > 0);
// Divisions with rounding up.
const int min_number_of_fragments =
(large_partition_size + max_payload_size - 1) / max_payload_size;
if (min_size < 0 || max_size < 0) {
// No aggregates produced, so we do not have any size boundaries.
// Simply split in as few partitions as possible.
return min_number_of_fragments;
}
const int max_number_of_fragments =
(large_partition_size + min_size - 1) / min_size;
int num_fragments = -1;