Avoid implicit type truncations by inserting explicit casts or modifying prototypes to avoid needless up- and then down-casting.
BUG=chromium:82439 TEST=none R=henrik.lundin@webrtc.org, mflodman@webrtc.org, pthatcher@webrtc.org Review URL: https://webrtc-codereview.appspot.com/40569004 Cr-Commit-Position: refs/heads/master@{#8229} git-svn-id: http://webrtc.googlecode.com/svn/trunk@8229 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@ -61,7 +61,7 @@ bool AcmSendTest::RegisterCodec(int codec_type,
|
||||
|
||||
Packet* AcmSendTest::NextPacket() {
|
||||
assert(codec_registered_);
|
||||
if (filter_.test(payload_type_)) {
|
||||
if (filter_.test(static_cast<size_t>(payload_type_))) {
|
||||
// This payload type should be filtered out. Since the payload type is the
|
||||
// same throughout the whole test run, no packet at all will be delivered.
|
||||
// We can just as well signal that the test is over by returning NULL.
|
||||
@ -111,7 +111,7 @@ Packet* AcmSendTest::CreatePacket() {
|
||||
uint8_t* packet_memory = new uint8_t[allocated_bytes];
|
||||
// Populate the header bytes.
|
||||
packet_memory[0] = 0x80;
|
||||
packet_memory[1] = payload_type_;
|
||||
packet_memory[1] = static_cast<uint8_t>(payload_type_);
|
||||
packet_memory[2] = (sequence_number_ >> 8) & 0xFF;
|
||||
packet_memory[3] = (sequence_number_) & 0xFF;
|
||||
packet_memory[4] = (timestamp_ >> 24) & 0xFF;
|
||||
|
@ -64,7 +64,7 @@ bool AcmSendTestOldApi::RegisterCodec(const char* payload_name,
|
||||
|
||||
Packet* AcmSendTestOldApi::NextPacket() {
|
||||
assert(codec_registered_);
|
||||
if (filter_.test(payload_type_)) {
|
||||
if (filter_.test(static_cast<size_t>(payload_type_))) {
|
||||
// This payload type should be filtered out. Since the payload type is the
|
||||
// same throughout the whole test run, no packet at all will be delivered.
|
||||
// We can just as well signal that the test is over by returning NULL.
|
||||
@ -115,7 +115,7 @@ Packet* AcmSendTestOldApi::CreatePacket() {
|
||||
uint8_t* packet_memory = new uint8_t[allocated_bytes];
|
||||
// Populate the header bytes.
|
||||
packet_memory[0] = 0x80;
|
||||
packet_memory[1] = payload_type_;
|
||||
packet_memory[1] = static_cast<uint8_t>(payload_type_);
|
||||
packet_memory[2] = (sequence_number_ >> 8) & 0xFF;
|
||||
packet_memory[3] = (sequence_number_) & 0xFF;
|
||||
packet_memory[4] = (timestamp_ >> 24) & 0xFF;
|
||||
|
@ -1129,12 +1129,12 @@ int NetEqImpl::Decode(PacketList* packet_list, Operations* operation,
|
||||
AudioDecoder* decoder = NULL;
|
||||
if (!packet_list->empty()) {
|
||||
const Packet* packet = packet_list->front();
|
||||
int payload_type = packet->header.payloadType;
|
||||
uint8_t payload_type = packet->header.payloadType;
|
||||
if (!decoder_database_->IsComfortNoise(payload_type)) {
|
||||
decoder = decoder_database_->GetDecoder(payload_type);
|
||||
assert(decoder);
|
||||
if (!decoder) {
|
||||
LOG_FERR1(LS_WARNING, GetDecoder, payload_type);
|
||||
LOG_FERR1(LS_WARNING, GetDecoder, static_cast<int>(payload_type));
|
||||
PacketBuffer::DeleteAllPackets(packet_list);
|
||||
return kDecoderNotFound;
|
||||
}
|
||||
@ -1146,7 +1146,7 @@ int NetEqImpl::Decode(PacketList* packet_list, Operations* operation,
|
||||
->GetDecoderInfo(payload_type);
|
||||
assert(decoder_info);
|
||||
if (!decoder_info) {
|
||||
LOG_FERR1(LS_WARNING, GetDecoderInfo, payload_type);
|
||||
LOG_FERR1(LS_WARNING, GetDecoderInfo, static_cast<int>(payload_type));
|
||||
PacketBuffer::DeleteAllPackets(packet_list);
|
||||
return kDecoderNotFound;
|
||||
}
|
||||
|
@ -187,57 +187,64 @@ std::string CodecName(webrtc::NetEqDecoder codec) {
|
||||
void RegisterPayloadTypes(NetEq* neteq) {
|
||||
assert(neteq);
|
||||
int error;
|
||||
error = neteq->RegisterPayloadType(webrtc::kDecoderPCMu, FLAGS_pcmu);
|
||||
error = neteq->RegisterPayloadType(webrtc::kDecoderPCMu,
|
||||
static_cast<uint8_t>(FLAGS_pcmu));
|
||||
if (error) {
|
||||
std::cerr << "Cannot register payload type " << FLAGS_pcmu <<
|
||||
" as " << CodecName(webrtc::kDecoderPCMu).c_str() << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
error = neteq->RegisterPayloadType(webrtc::kDecoderPCMa, FLAGS_pcma);
|
||||
error = neteq->RegisterPayloadType(webrtc::kDecoderPCMa,
|
||||
static_cast<uint8_t>(FLAGS_pcma));
|
||||
if (error) {
|
||||
std::cerr << "Cannot register payload type " << FLAGS_pcma <<
|
||||
" as " << CodecName(webrtc::kDecoderPCMa).c_str() << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
error = neteq->RegisterPayloadType(webrtc::kDecoderILBC, FLAGS_ilbc);
|
||||
error = neteq->RegisterPayloadType(webrtc::kDecoderILBC,
|
||||
static_cast<uint8_t>(FLAGS_ilbc));
|
||||
if (error) {
|
||||
std::cerr << "Cannot register payload type " << FLAGS_ilbc <<
|
||||
" as " << CodecName(webrtc::kDecoderILBC).c_str() << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
error = neteq->RegisterPayloadType(webrtc::kDecoderISAC, FLAGS_isac);
|
||||
error = neteq->RegisterPayloadType(webrtc::kDecoderISAC,
|
||||
static_cast<uint8_t>(FLAGS_isac));
|
||||
if (error) {
|
||||
std::cerr << "Cannot register payload type " << FLAGS_isac <<
|
||||
" as " << CodecName(webrtc::kDecoderISAC).c_str() << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
error = neteq->RegisterPayloadType(webrtc::kDecoderISACswb, FLAGS_isac_swb);
|
||||
error = neteq->RegisterPayloadType(webrtc::kDecoderISACswb,
|
||||
static_cast<uint8_t>(FLAGS_isac_swb));
|
||||
if (error) {
|
||||
std::cerr << "Cannot register payload type " << FLAGS_isac_swb <<
|
||||
" as " << CodecName(webrtc::kDecoderISACswb).c_str() << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
error = neteq->RegisterPayloadType(webrtc::kDecoderOpus, FLAGS_opus);
|
||||
error = neteq->RegisterPayloadType(webrtc::kDecoderOpus,
|
||||
static_cast<uint8_t>(FLAGS_opus));
|
||||
if (error) {
|
||||
std::cerr << "Cannot register payload type " << FLAGS_opus << " as "
|
||||
<< CodecName(webrtc::kDecoderOpus).c_str() << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
error = neteq->RegisterPayloadType(webrtc::kDecoderPCM16B, FLAGS_pcm16b);
|
||||
error = neteq->RegisterPayloadType(webrtc::kDecoderPCM16B,
|
||||
static_cast<uint8_t>(FLAGS_pcm16b));
|
||||
if (error) {
|
||||
std::cerr << "Cannot register payload type " << FLAGS_pcm16b <<
|
||||
" as " << CodecName(webrtc::kDecoderPCM16B).c_str() << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
error = neteq->RegisterPayloadType(webrtc::kDecoderPCM16Bwb,
|
||||
FLAGS_pcm16b_wb);
|
||||
static_cast<uint8_t>(FLAGS_pcm16b_wb));
|
||||
if (error) {
|
||||
std::cerr << "Cannot register payload type " << FLAGS_pcm16b_wb <<
|
||||
" as " << CodecName(webrtc::kDecoderPCM16Bwb).c_str() << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
error = neteq->RegisterPayloadType(webrtc::kDecoderPCM16Bswb32kHz,
|
||||
FLAGS_pcm16b_swb32);
|
||||
static_cast<uint8_t>(FLAGS_pcm16b_swb32));
|
||||
if (error) {
|
||||
std::cerr << "Cannot register payload type " << FLAGS_pcm16b_swb32 <<
|
||||
" as " << CodecName(webrtc::kDecoderPCM16Bswb32kHz).c_str() <<
|
||||
@ -245,52 +252,57 @@ void RegisterPayloadTypes(NetEq* neteq) {
|
||||
exit(1);
|
||||
}
|
||||
error = neteq->RegisterPayloadType(webrtc::kDecoderPCM16Bswb48kHz,
|
||||
FLAGS_pcm16b_swb48);
|
||||
static_cast<uint8_t>(FLAGS_pcm16b_swb48));
|
||||
if (error) {
|
||||
std::cerr << "Cannot register payload type " << FLAGS_pcm16b_swb48 <<
|
||||
" as " << CodecName(webrtc::kDecoderPCM16Bswb48kHz).c_str() <<
|
||||
std::endl;
|
||||
exit(1);
|
||||
}
|
||||
error = neteq->RegisterPayloadType(webrtc::kDecoderG722, FLAGS_g722);
|
||||
error = neteq->RegisterPayloadType(webrtc::kDecoderG722,
|
||||
static_cast<uint8_t>(FLAGS_g722));
|
||||
if (error) {
|
||||
std::cerr << "Cannot register payload type " << FLAGS_g722 <<
|
||||
" as " << CodecName(webrtc::kDecoderG722).c_str() << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
error = neteq->RegisterPayloadType(webrtc::kDecoderAVT, FLAGS_avt);
|
||||
error = neteq->RegisterPayloadType(webrtc::kDecoderAVT,
|
||||
static_cast<uint8_t>(FLAGS_avt));
|
||||
if (error) {
|
||||
std::cerr << "Cannot register payload type " << FLAGS_avt <<
|
||||
" as " << CodecName(webrtc::kDecoderAVT).c_str() << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
error = neteq->RegisterPayloadType(webrtc::kDecoderRED, FLAGS_red);
|
||||
error = neteq->RegisterPayloadType(webrtc::kDecoderRED,
|
||||
static_cast<uint8_t>(FLAGS_red));
|
||||
if (error) {
|
||||
std::cerr << "Cannot register payload type " << FLAGS_red <<
|
||||
" as " << CodecName(webrtc::kDecoderRED).c_str() << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
error = neteq->RegisterPayloadType(webrtc::kDecoderCNGnb, FLAGS_cn_nb);
|
||||
error = neteq->RegisterPayloadType(webrtc::kDecoderCNGnb,
|
||||
static_cast<uint8_t>(FLAGS_cn_nb));
|
||||
if (error) {
|
||||
std::cerr << "Cannot register payload type " << FLAGS_cn_nb <<
|
||||
" as " << CodecName(webrtc::kDecoderCNGnb).c_str() << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
error = neteq->RegisterPayloadType(webrtc::kDecoderCNGwb, FLAGS_cn_wb);
|
||||
error = neteq->RegisterPayloadType(webrtc::kDecoderCNGwb,
|
||||
static_cast<uint8_t>(FLAGS_cn_wb));
|
||||
if (error) {
|
||||
std::cerr << "Cannot register payload type " << FLAGS_cn_wb <<
|
||||
" as " << CodecName(webrtc::kDecoderCNGwb).c_str() << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
error = neteq->RegisterPayloadType(webrtc::kDecoderCNGswb32kHz,
|
||||
FLAGS_cn_swb32);
|
||||
static_cast<uint8_t>(FLAGS_cn_swb32));
|
||||
if (error) {
|
||||
std::cerr << "Cannot register payload type " << FLAGS_cn_swb32 <<
|
||||
" as " << CodecName(webrtc::kDecoderCNGswb32kHz).c_str() << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
error = neteq->RegisterPayloadType(webrtc::kDecoderCNGswb48kHz,
|
||||
FLAGS_cn_swb48);
|
||||
static_cast<uint8_t>(FLAGS_cn_swb48));
|
||||
if (error) {
|
||||
std::cerr << "Cannot register payload type " << FLAGS_cn_swb48 <<
|
||||
" as " << CodecName(webrtc::kDecoderCNGswb48kHz).c_str() << std::endl;
|
||||
@ -442,16 +454,18 @@ size_t ReplacePayload(webrtc::test::InputAudioFile* replacement_audio_file,
|
||||
// Change payload type to PCM16.
|
||||
switch (CodecSampleRate(rtp_header->header.payloadType)) {
|
||||
case 8000:
|
||||
rtp_header->header.payloadType = FLAGS_pcm16b;
|
||||
rtp_header->header.payloadType = static_cast<uint8_t>(FLAGS_pcm16b);
|
||||
break;
|
||||
case 16000:
|
||||
rtp_header->header.payloadType = FLAGS_pcm16b_wb;
|
||||
rtp_header->header.payloadType = static_cast<uint8_t>(FLAGS_pcm16b_wb);
|
||||
break;
|
||||
case 32000:
|
||||
rtp_header->header.payloadType = FLAGS_pcm16b_swb32;
|
||||
rtp_header->header.payloadType =
|
||||
static_cast<uint8_t>(FLAGS_pcm16b_swb32);
|
||||
break;
|
||||
case 48000:
|
||||
rtp_header->header.payloadType = FLAGS_pcm16b_swb48;
|
||||
rtp_header->header.payloadType =
|
||||
static_cast<uint8_t>(FLAGS_pcm16b_swb48);
|
||||
break;
|
||||
default:
|
||||
std::cerr << "Payload type " <<
|
||||
|
Reference in New Issue
Block a user