FEC: Fix to coverity issue 14448: unintended sign extension.
Review URL: https://webrtc-codereview.appspot.com/647004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@2400 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
f0d4696ab3
commit
c35f1d26c5
@ -111,8 +111,7 @@ int32_t ForwardErrorCorrection::GenerateFEC(
|
||||
}
|
||||
const uint16_t numMediaPackets = mediaPacketList.size();
|
||||
bool lBit = (numMediaPackets > 8 * kMaskSizeLBitClear);
|
||||
uint16_t numMaskBytes = lBit ?
|
||||
kMaskSizeLBitSet : kMaskSizeLBitClear;
|
||||
int numMaskBytes = lBit ? kMaskSizeLBitSet : kMaskSizeLBitClear;
|
||||
|
||||
if (numMediaPackets > kMaxMediaPackets) {
|
||||
WEBRTC_TRACE(kTraceError, kTraceRtpRtcp, _id,
|
||||
@ -217,19 +216,18 @@ int ForwardErrorCorrection::GetNumberOfFecPackets(int numMediaPackets,
|
||||
void ForwardErrorCorrection::GenerateFecBitStrings(
|
||||
const PacketList& mediaPacketList,
|
||||
uint8_t* packetMask,
|
||||
uint32_t numFecPackets,
|
||||
int numFecPackets,
|
||||
bool lBit) {
|
||||
if (mediaPacketList.empty()) {
|
||||
return;
|
||||
}
|
||||
uint8_t mediaPayloadLength[2];
|
||||
const uint16_t numMaskBytes = lBit ?
|
||||
kMaskSizeLBitSet : kMaskSizeLBitClear;
|
||||
const int numMaskBytes = lBit ? kMaskSizeLBitSet : kMaskSizeLBitClear;
|
||||
const uint16_t ulpHeaderSize = lBit ?
|
||||
kUlpHeaderSizeLBitSet : kUlpHeaderSizeLBitClear;
|
||||
const uint16_t fecRtpOffset = kFecHeaderSize + ulpHeaderSize - kRtpHeaderSize;
|
||||
|
||||
for (uint32_t i = 0; i < numFecPackets; i++) {
|
||||
for (int i = 0; i < numFecPackets; i++) {
|
||||
PacketList::const_iterator mediaListIt = mediaPacketList.begin();
|
||||
uint32_t pktMaskIdx = i * numMaskBytes;
|
||||
uint32_t mediaPktIdx = 0;
|
||||
@ -304,8 +302,8 @@ void ForwardErrorCorrection::GenerateFecBitStrings(
|
||||
int ForwardErrorCorrection::InsertZerosInBitMasks(
|
||||
const PacketList& media_packets,
|
||||
uint8_t* packet_mask,
|
||||
uint16_t num_mask_bytes,
|
||||
uint32_t num_fec_packets) {
|
||||
int num_mask_bytes,
|
||||
int num_fec_packets) {
|
||||
uint8_t* new_mask = NULL;
|
||||
if (media_packets.size() <= 1) {
|
||||
return media_packets.size();
|
||||
@ -406,7 +404,7 @@ void ForwardErrorCorrection::GenerateFecUlpHeaders(
|
||||
const PacketList& mediaPacketList,
|
||||
uint8_t* packetMask,
|
||||
bool lBit,
|
||||
uint32_t numFecPackets) {
|
||||
int numFecPackets) {
|
||||
// -- Generate FEC and ULP headers --
|
||||
//
|
||||
// FEC Header, 10 bytes
|
||||
@ -431,12 +429,11 @@ void ForwardErrorCorrection::GenerateFecUlpHeaders(
|
||||
PacketList::const_iterator mediaListIt = mediaPacketList.begin();
|
||||
Packet* mediaPacket = *mediaListIt;
|
||||
assert(mediaPacket != NULL);
|
||||
const uint16_t numMaskBytes = lBit ?
|
||||
kMaskSizeLBitSet : kMaskSizeLBitClear;
|
||||
int numMaskBytes = lBit ? kMaskSizeLBitSet : kMaskSizeLBitClear;
|
||||
const uint16_t ulpHeaderSize = lBit ?
|
||||
kUlpHeaderSizeLBitSet : kUlpHeaderSizeLBitClear;
|
||||
|
||||
for (uint32_t i = 0; i < numFecPackets; i++) {
|
||||
for (int i = 0; i < numFecPackets; i++) {
|
||||
// -- FEC header --
|
||||
_generatedFecPackets[i].data[0] &= 0x7f; // Set E to zero.
|
||||
if (lBit == 0) {
|
||||
|
@ -238,7 +238,7 @@ class ForwardErrorCorrection {
|
||||
void GenerateFecUlpHeaders(const PacketList& mediaPacketList,
|
||||
uint8_t* packetMask,
|
||||
bool lBit,
|
||||
uint32_t numFecPackets);
|
||||
int numFecPackets);
|
||||
|
||||
// Analyzes |media_packets| for holes in the sequence and inserts zero columns
|
||||
// into the |packet_mask| where those holes are found. Zero columns means that
|
||||
@ -248,8 +248,8 @@ class ForwardErrorCorrection {
|
||||
// allocated.
|
||||
int InsertZerosInBitMasks(const PacketList& media_packets,
|
||||
uint8_t* packet_mask,
|
||||
uint16_t num_mask_bytes,
|
||||
uint32_t num_fec_packets);
|
||||
int num_mask_bytes,
|
||||
int num_fec_packets);
|
||||
|
||||
// Inserts |num_zeros| zero columns into |new_mask| at position
|
||||
// |new_bit_index|. If the current byte of |new_mask| can't fit all zeros, the
|
||||
@ -279,7 +279,7 @@ class ForwardErrorCorrection {
|
||||
|
||||
void GenerateFecBitStrings(const PacketList& mediaPacketList,
|
||||
uint8_t* packetMask,
|
||||
uint32_t numFecPackets,
|
||||
int numFecPackets,
|
||||
bool lBit);
|
||||
|
||||
// Insert received packets into FEC or recovered list.
|
||||
|
Loading…
x
Reference in New Issue
Block a user