Change default packetization mode to an equal size mode.
This will produce equal size packets for each frame, which should be somewhat more favorable (less overhead/padding data) for the FEC. Review URL: https://webrtc-codereview.appspot.com/396013 git-svn-id: http://webrtc.googlecode.com/svn/trunk@1754 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
70efc3250d
commit
946601e408
@ -20,11 +20,11 @@
|
|||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
// Define how the VP8PacketizerModes are implemented.
|
// Define how the VP8PacketizerModes are implemented.
|
||||||
// Modes are: kStrict, kAggregate, kSloppy.
|
// Modes are: kStrict, kAggregate, kEqualSize.
|
||||||
const RtpFormatVp8::AggregationMode RtpFormatVp8::aggr_modes_[kNumModes] =
|
const RtpFormatVp8::AggregationMode RtpFormatVp8::aggr_modes_[kNumModes] =
|
||||||
{ kAggrNone, kAggrPartitions, kAggrFragments };
|
{ kAggrNone, kAggrPartitions, kAggrFragments };
|
||||||
const bool RtpFormatVp8::balance_modes_[kNumModes] =
|
const bool RtpFormatVp8::balance_modes_[kNumModes] =
|
||||||
{ true, true, false };
|
{ true, true, true };
|
||||||
const bool RtpFormatVp8::separate_first_modes_[kNumModes] =
|
const bool RtpFormatVp8::separate_first_modes_[kNumModes] =
|
||||||
{ true, false, false };
|
{ true, false, false };
|
||||||
|
|
||||||
@ -55,9 +55,9 @@ RtpFormatVp8::RtpFormatVp8(const WebRtc_UWord8* payload_data,
|
|||||||
payload_size_(static_cast<int>(payload_size)),
|
payload_size_(static_cast<int>(payload_size)),
|
||||||
part_info_(),
|
part_info_(),
|
||||||
vp8_fixed_payload_descriptor_bytes_(1),
|
vp8_fixed_payload_descriptor_bytes_(1),
|
||||||
aggr_mode_(aggr_modes_[kSloppy]),
|
aggr_mode_(aggr_modes_[kEqualSize]),
|
||||||
balance_(balance_modes_[kSloppy]),
|
balance_(balance_modes_[kEqualSize]),
|
||||||
separate_first_(separate_first_modes_[kSloppy]),
|
separate_first_(separate_first_modes_[kEqualSize]),
|
||||||
hdr_info_(hdr_info),
|
hdr_info_(hdr_info),
|
||||||
num_partitions_(1),
|
num_partitions_(1),
|
||||||
max_payload_len_(max_payload_len),
|
max_payload_len_(max_payload_len),
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* together with the fragmentation information and a packetizer mode
|
* together with the fragmentation information and a packetizer mode
|
||||||
* of choice. Alternatively, if no fragmentation info is available, the
|
* of choice. Alternatively, if no fragmentation info is available, the
|
||||||
* second constructor can be used with only payload data and size; in that
|
* second constructor can be used with only payload data and size; in that
|
||||||
* case the mode kSloppy is used.
|
* case the mode kEqualSize is used.
|
||||||
*
|
*
|
||||||
* After creating the packetizer, the method NextPacket is called
|
* After creating the packetizer, the method NextPacket is called
|
||||||
* repeatedly to get all packets for the frame. The method returns
|
* repeatedly to get all packets for the frame. The method returns
|
||||||
@ -38,7 +38,8 @@ enum VP8PacketizerMode {
|
|||||||
kStrict = 0, // Split partitions if too large;
|
kStrict = 0, // Split partitions if too large;
|
||||||
// never aggregate, balance size.
|
// never aggregate, balance size.
|
||||||
kAggregate, // Split partitions if too large; aggregate whole partitions.
|
kAggregate, // Split partitions if too large; aggregate whole partitions.
|
||||||
kSloppy, // Split entire payload without considering partition limits.
|
kEqualSize, // Split entire payload without considering partition limits.
|
||||||
|
// This will produce equal size packets for the whole frame.
|
||||||
kNumModes,
|
kNumModes,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -54,7 +55,7 @@ class RtpFormatVp8 {
|
|||||||
const RTPFragmentationHeader& fragmentation,
|
const RTPFragmentationHeader& fragmentation,
|
||||||
VP8PacketizerMode mode);
|
VP8PacketizerMode mode);
|
||||||
|
|
||||||
// Initialize without fragmentation info. Mode kSloppy will be used.
|
// Initialize without fragmentation info. Mode kEqualSize will be used.
|
||||||
// The payload_data must be exactly one encoded VP8 frame.
|
// The payload_data must be exactly one encoded VP8 frame.
|
||||||
RtpFormatVp8(const WebRtc_UWord8* payload_data,
|
RtpFormatVp8(const WebRtc_UWord8* payload_data,
|
||||||
WebRtc_UWord32 payload_size,
|
WebRtc_UWord32 payload_size,
|
||||||
@ -67,9 +68,11 @@ class RtpFormatVp8 {
|
|||||||
// bytes_to_send is an output variable that will contain number of bytes
|
// bytes_to_send is an output variable that will contain number of bytes
|
||||||
// written to buffer. Parameter last_packet is true for the last packet of
|
// written to buffer. Parameter last_packet is true for the last packet of
|
||||||
// the frame, false otherwise (i.e., call the function again to get the
|
// the frame, false otherwise (i.e., call the function again to get the
|
||||||
// next packet). Returns the partition index from which the first payload
|
// next packet).
|
||||||
// byte in the packet is taken, with the first partition having index 0;
|
// For the kStrict and kAggregate mode: returns the partition index from which
|
||||||
// returns negative on error.
|
// the first payload byte in the packet is taken, with the first partition
|
||||||
|
// having index 0; returns negative on error.
|
||||||
|
// For the kEqualSize mode: returns 0 on success, return negative on error.
|
||||||
int NextPacket(WebRtc_UWord8* buffer,
|
int NextPacket(WebRtc_UWord8* buffer,
|
||||||
int* bytes_to_send,
|
int* bytes_to_send,
|
||||||
bool* last_packet);
|
bool* last_packet);
|
||||||
|
@ -200,38 +200,8 @@ TEST_F(RtpFormatVp8Test, TestAggregateModeTwoLargePartitions) {
|
|||||||
kExpectedFragStart, kExpectedNum);
|
kExpectedFragStart, kExpectedNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(RtpFormatVp8Test, TestSloppyMode) {
|
// Verify that EqualSize mode is forced if fragmentation info is missing.
|
||||||
const int kSizeVector[] = {10, 10, 10};
|
TEST_F(RtpFormatVp8Test, TestEqualSizeModeFallback) {
|
||||||
const int kNumPartitions = sizeof(kSizeVector) / sizeof(kSizeVector[0]);
|
|
||||||
ASSERT_TRUE(Init(kSizeVector, kNumPartitions));
|
|
||||||
|
|
||||||
hdr_info_.pictureId = kNoPictureId; // No PictureID.
|
|
||||||
const int kMaxSize = 9;
|
|
||||||
RtpFormatVp8 packetizer(helper_->payload_data(),
|
|
||||||
helper_->payload_size(),
|
|
||||||
hdr_info_,
|
|
||||||
kMaxSize,
|
|
||||||
*(helper_->fragmentation()),
|
|
||||||
kSloppy);
|
|
||||||
|
|
||||||
// The expected sizes are obtained by running a verified good implementation.
|
|
||||||
const int kExpectedSizes[] = {9, 9, 9, 7};
|
|
||||||
const int kExpectedPart[] = {0, 0, 1, 2};
|
|
||||||
const bool kExpectedFragStart[] = {true, false, false, 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Verify that sloppy mode is forced if fragmentation info is missing.
|
|
||||||
TEST_F(RtpFormatVp8Test, TestSloppyModeFallback) {
|
|
||||||
const int kSizeVector[] = {10, 10, 10};
|
const int kSizeVector[] = {10, 10, 10};
|
||||||
const int kNumPartitions = sizeof(kSizeVector) / sizeof(kSizeVector[0]);
|
const int kNumPartitions = sizeof(kSizeVector) / sizeof(kSizeVector[0]);
|
||||||
ASSERT_TRUE(Init(kSizeVector, kNumPartitions));
|
ASSERT_TRUE(Init(kSizeVector, kNumPartitions));
|
||||||
@ -244,9 +214,9 @@ TEST_F(RtpFormatVp8Test, TestSloppyModeFallback) {
|
|||||||
kMaxSize);
|
kMaxSize);
|
||||||
|
|
||||||
// Expecting three full packets, and one with the remainder.
|
// Expecting three full packets, and one with the remainder.
|
||||||
const int kExpectedSizes[] = {12, 12, 12, 10};
|
const int kExpectedSizes[] = {12, 11, 12, 11};
|
||||||
const int kExpectedPart[] = {0, 0, 0, 0}; // Always 0 for sloppy mode.
|
const int kExpectedPart[] = {0, 0, 0, 0}; // Always 0 for equal size mode.
|
||||||
// Frag start only true for first packet in sloppy mode.
|
// Frag start only true for first packet in equal size mode.
|
||||||
const bool kExpectedFragStart[] = {true, false, false, false};
|
const bool kExpectedFragStart[] = {true, false, false, false};
|
||||||
const int kExpectedNum = sizeof(kExpectedSizes) / sizeof(kExpectedSizes[0]);
|
const int kExpectedNum = sizeof(kExpectedSizes) / sizeof(kExpectedSizes[0]);
|
||||||
COMPILE_ASSERT(kExpectedNum ==
|
COMPILE_ASSERT(kExpectedNum ==
|
||||||
@ -261,7 +231,7 @@ TEST_F(RtpFormatVp8Test, TestSloppyModeFallback) {
|
|||||||
kExpectedFragStart, kExpectedNum);
|
kExpectedFragStart, kExpectedNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify that non-reference bit is set. Sloppy mode fallback is expected.
|
// Verify that non-reference bit is set. EqualSize mode fallback is expected.
|
||||||
TEST_F(RtpFormatVp8Test, TestNonReferenceBit) {
|
TEST_F(RtpFormatVp8Test, TestNonReferenceBit) {
|
||||||
const int kSizeVector[] = {10, 10, 10};
|
const int kSizeVector[] = {10, 10, 10};
|
||||||
const int kNumPartitions = sizeof(kSizeVector) / sizeof(kSizeVector[0]);
|
const int kNumPartitions = sizeof(kSizeVector) / sizeof(kSizeVector[0]);
|
||||||
@ -274,10 +244,10 @@ TEST_F(RtpFormatVp8Test, TestNonReferenceBit) {
|
|||||||
hdr_info_,
|
hdr_info_,
|
||||||
kMaxSize);
|
kMaxSize);
|
||||||
|
|
||||||
// Sloppy mode => First packet full; other not.
|
// EqualSize mode => First packet full; other not.
|
||||||
const int kExpectedSizes[] = {25, 7};
|
const int kExpectedSizes[] = {16, 16};
|
||||||
const int kExpectedPart[] = {0, 0}; // Always 0 for sloppy mode.
|
const int kExpectedPart[] = {0, 0}; // Always 0 for equal size mode.
|
||||||
// Frag start only true for first packet in sloppy mode.
|
// Frag start only true for first packet in equal size mode.
|
||||||
const bool kExpectedFragStart[] = {true, false};
|
const bool kExpectedFragStart[] = {true, false};
|
||||||
const int kExpectedNum = sizeof(kExpectedSizes) / sizeof(kExpectedSizes[0]);
|
const int kExpectedNum = sizeof(kExpectedSizes) / sizeof(kExpectedSizes[0]);
|
||||||
COMPILE_ASSERT(kExpectedNum ==
|
COMPILE_ASSERT(kExpectedNum ==
|
||||||
|
@ -545,8 +545,10 @@ RTPSenderVideo::SendVP8(const FrameType frameType,
|
|||||||
WebRtc_UWord16 maxPayloadLengthVP8 = _rtpSender.MaxDataPayloadLength();
|
WebRtc_UWord16 maxPayloadLengthVP8 = _rtpSender.MaxDataPayloadLength();
|
||||||
|
|
||||||
assert(rtpTypeHdr);
|
assert(rtpTypeHdr);
|
||||||
|
// Initialize disregarding partition boundaries: this will use kEqualSize
|
||||||
|
// packetization mode, which produces ~equal size packets for each frame.
|
||||||
RtpFormatVp8 packetizer(data, payloadBytesToSend, rtpTypeHdr->VP8,
|
RtpFormatVp8 packetizer(data, payloadBytesToSend, rtpTypeHdr->VP8,
|
||||||
maxPayloadLengthVP8, *fragmentation, kAggregate);
|
maxPayloadLengthVP8);
|
||||||
|
|
||||||
StorageType storage = kAllowRetransmission;
|
StorageType storage = kAllowRetransmission;
|
||||||
if (rtpTypeHdr->VP8.temporalIdx == 0 &&
|
if (rtpTypeHdr->VP8.temporalIdx == 0 &&
|
||||||
|
Loading…
x
Reference in New Issue
Block a user