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

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: Converted WebRtcCng to C++ 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..ae4b70acb2e6390fa4270cc31ffbfde7165123a6 100644
--- a/webrtc/modules/audio_coding/neteq/neteq_impl.cc
+++ b/webrtc/modules/audio_coding/neteq/neteq_impl.cc
@@ -14,6 +14,7 @@
#include <memory.h> // memset
#include <algorithm>
+#include <vector>
#include "webrtc/base/checks.h"
#include "webrtc/base/logging.h"
@@ -664,18 +665,21 @@ int NetEqImpl::InsertPacketInternal(const WebRtcRTPHeader& rtp_header,
}
}
- // Update bandwidth estimate, if the packet is not sync-packet.
+ // Update bandwidth estimate, if the packet is not sync-packet nor comfort
+ // noise.
kwiberg-webrtc 2016/04/12 13:35:31 Is this additional requirement because CN's Incomi
ossu 2016/04/12 13:54:50 Well, it just returned -1 before, so the call was
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)) {
kwiberg-webrtc 2016/04/12 13:35:31 Merge these two ifs?
ossu 2016/04/12 13:54:50 Acknowledged.
+ 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 +732,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,7 +1305,7 @@ int NetEqImpl::Decode(PacketList* packet_list, Operations* operation,
decoder->Reset();
// Reset comfort noise decoder.
- AudioDecoder* cng_decoder = decoder_database_->GetActiveCngDecoder();
+ ComfortNoiseDecoder* cng_decoder = decoder_database_->GetActiveCngDecoder();
if (cng_decoder)
cng_decoder->Reset();
@@ -1955,7 +1963,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,7 +2031,7 @@ void NetEqImpl::SetSampleRateAndChannels(int fs_hz, size_t channels) {
mute_factor_array_[i] = 16384; // 1.0 in Q14.
}
- AudioDecoder* cng_decoder = decoder_database_->GetActiveCngDecoder();
+ ComfortNoiseDecoder* cng_decoder = decoder_database_->GetActiveCngDecoder();
if (cng_decoder)
cng_decoder->Reset();

Powered by Google App Engine
This is Rietveld 408576698