Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(253)

Unified Diff: webrtc/modules/audio_coding/neteq/neteq_impl.cc

Issue 1868143002: Convert CNG into C++ and remove it from AudioDecoder (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_coding/neteq/neteq_impl.cc
diff --git a/webrtc/modules/audio_coding/neteq/neteq_impl.cc b/webrtc/modules/audio_coding/neteq/neteq_impl.cc
index db37e716d66dde966a4cac42f10dd47166c4f42c..f54d2c5cf6c778e8f30fa68b521a9a3fc66e6dbe 100644
--- a/webrtc/modules/audio_coding/neteq/neteq_impl.cc
+++ b/webrtc/modules/audio_coding/neteq/neteq_impl.cc
@@ -667,15 +667,17 @@ int NetEqImpl::InsertPacketInternal(const WebRtcRTPHeader& rtp_header,
// Update bandwidth estimate, if the packet is not sync-packet.
hlundin-webrtc 2016/04/11 11:33:00 Update the comment to mention that CNG packets are
ossu 2016/04/11 12:59:57 Acknowledged.
if (!packet_list.empty() && !packet_list.front()->sync_packet) {
// The list can be empty here if we got nothing but DTMF payloads.
- AudioDecoder* decoder =
- decoder_database_->GetDecoder(main_header.payloadType);
- assert(decoder); // Should always get a valid object, since we have
- // already checked that the payload types are known.
- decoder->IncomingPacket(packet_list.front()->payload,
- packet_list.front()->payload_length,
- packet_list.front()->header.sequenceNumber,
- packet_list.front()->header.timestamp,
- receive_timestamp);
+ if (!decoder_database_->IsComfortNoise(main_header.payloadType)) {
+ AudioDecoder* decoder =
+ decoder_database_->GetDecoder(main_header.payloadType);
+ assert(decoder); // Should always get a valid object, since we have
+ // already checked that the payload types are known.
+ decoder->IncomingPacket(packet_list.front()->payload,
+ packet_list.front()->payload_length,
+ packet_list.front()->header.sequenceNumber,
+ packet_list.front()->header.timestamp,
+ receive_timestamp);
+ }
}
if (nack_enabled_) {
@@ -728,14 +730,18 @@ int NetEqImpl::InsertPacketInternal(const WebRtcRTPHeader& rtp_header,
const RTPHeader* rtp_header = packet_buffer_->NextRtpHeader();
assert(rtp_header);
int payload_type = rtp_header->payloadType;
- AudioDecoder* decoder = decoder_database_->GetDecoder(payload_type);
- assert(decoder); // Payloads are already checked to be valid.
+ size_t channels = 1;
+ if (!decoder_database_->IsComfortNoise(payload_type)) {
+ AudioDecoder* decoder = decoder_database_->GetDecoder(payload_type);
+ assert(decoder); // Payloads are already checked to be valid.
+ channels = decoder->Channels();
+ }
const DecoderDatabase::DecoderInfo* decoder_info =
decoder_database_->GetDecoderInfo(payload_type);
assert(decoder_info);
if (decoder_info->fs_hz != fs_hz_ ||
- decoder->Channels() != algorithm_buffer_->Channels()) {
- SetSampleRateAndChannels(decoder_info->fs_hz, decoder->Channels());
+ channels != algorithm_buffer_->Channels()) {
+ SetSampleRateAndChannels(decoder_info->fs_hz, channels);
}
if (nack_enabled_) {
RTC_DCHECK(nack_);
@@ -1297,9 +1303,9 @@ int NetEqImpl::Decode(PacketList* packet_list, Operations* operation,
decoder->Reset();
// Reset comfort noise decoder.
- AudioDecoder* cng_decoder = decoder_database_->GetActiveCngDecoder();
+ CNG_dec_inst* cng_decoder = decoder_database_->GetActiveCngDecoder();
if (cng_decoder)
- cng_decoder->Reset();
+ WebRtcCng_InitDec(cng_decoder);
reset_decoder_ = false;
}
@@ -1955,7 +1961,7 @@ int NetEqImpl::ExtractPackets(size_t required_samples,
stats_.SecondaryDecodedSamples(packet_duration);
}
}
- } else {
+ } else if (!decoder_database_->IsComfortNoise(packet->header.payloadType)) {
LOG(LS_WARNING) << "Unknown payload type "
<< static_cast<int>(packet->header.payloadType);
assert(false);
@@ -2023,9 +2029,9 @@ void NetEqImpl::SetSampleRateAndChannels(int fs_hz, size_t channels) {
mute_factor_array_[i] = 16384; // 1.0 in Q14.
}
- AudioDecoder* cng_decoder = decoder_database_->GetActiveCngDecoder();
+ CNG_dec_inst* cng_decoder = decoder_database_->GetActiveCngDecoder();
if (cng_decoder)
- cng_decoder->Reset();
+ WebRtcCng_InitDec(cng_decoder);
// Reinit post-decode VAD with new sample rate.
assert(vad_.get()); // Cannot be NULL here.

Powered by Google App Engine
This is Rietveld 408576698