Removing a hack for CNG
However, two other "hacks" had to be added to maintain bit-exactness
with legacy.
Note that this change requires a new version of the universal.rtp test
input, although the output reference stays the same.
Moving reference files, and using a new input vector for NetEq4.
The new input vector neteq_universal_new.rtp is identical to the old
neteq_universal.rtp, except that the payload type for CNG packets that
follows a wideband codec is changed to 98.
Update to resources revision 15 where the new reference files are.
Also changing a faulty log error.
Review URL: https://webrtc-codereview.appspot.com/1078009
git-svn-id: http://webrtc.googlecode.com/svn/trunk@3442 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/webrtc/modules/audio_coding/neteq4/neteq_impl.cc b/webrtc/modules/audio_coding/neteq4/neteq_impl.cc
index e16f083..5508d08 100644
--- a/webrtc/modules/audio_coding/neteq4/neteq_impl.cc
+++ b/webrtc/modules/audio_coding/neteq4/neteq_impl.cc
@@ -374,7 +374,9 @@
packet->primary = true;
packet->waiting_time = 0;
packet->payload = new uint8_t[packet->payload_length];
- LOG_F(LS_ERROR) << "Payload pointer is NULL.";
+ if (!packet->payload) {
+ LOG_F(LS_ERROR) << "Payload pointer is NULL.";
+ }
assert(payload); // Already checked above.
memcpy(packet->payload, payload, packet->payload_length);
// Insert packet in a packet list.
@@ -844,7 +846,14 @@
delay_manager_->Reset();
stats_.ResetMcu();
- if (*operation == kRfc3389CngNoPacket) {
+ if (*operation == kRfc3389CngNoPacket
+#ifndef LEGACY_BITEXACT
+ // Without this check, it can happen that a non-CNG packet is sent to
+ // the CNG decoder as if it was a SID frame. This is clearly a bug,
+ // but is kept for now to maintain bit-exactness with the test vectors.
+ && decoder_database_->IsComfortNoise(header->payloadType)
+#endif
+ ) {
// Change decision to CNG packet, since we do have a CNG packet, but it
// was considered too early to use. Now, use it anyway.
*operation = kRfc3389Cng;
@@ -1400,14 +1409,31 @@
assert(packet_list->size() == 1);
Packet* packet = packet_list->front();
packet_list->pop_front();
- // Temp hack to get correct PT for CNG.
- // TODO(hlundin): Update universal.rtp and remove this hack.
- if (fs_hz_ == 16000) {
- packet->header.payloadType = 98;
- } else if (fs_hz_ == 32000) {
- packet->header.payloadType = 99;
+ if (!decoder_database_->IsComfortNoise(packet->header.payloadType)) {
+#ifdef LEGACY_BITEXACT
+ // This can happen due to a bug in GetDecision. Change the payload type
+ // to a CNG type, and move on. Note that this means that we are in fact
+ // sending a non-CNG payload to the comfort noise decoder for decoding.
+ // Clearly wrong, but will maintain bit-exactness with legacy.
+ if (fs_hz_ == 8000) {
+ packet->header.payloadType =
+ decoder_database_->GetRtpPayloadType(kDecoderCNGnb);
+ } else if (fs_hz_ == 16000) {
+ packet->header.payloadType =
+ decoder_database_->GetRtpPayloadType(kDecoderCNGwb);
+ } else if (fs_hz_ == 32000) {
+ packet->header.payloadType =
+ decoder_database_->GetRtpPayloadType(kDecoderCNGswb32kHz);
+ } else if (fs_hz_ == 48000) {
+ packet->header.payloadType =
+ decoder_database_->GetRtpPayloadType(kDecoderCNGswb48kHz);
+ }
+ assert(decoder_database_->IsComfortNoise(packet->header.payloadType));
+#else
+ LOG(LS_ERROR) << "Trying to decode non-CNG payload as CNG.";
+ return kOtherError;
+#endif
}
- // End of hack.
// UpdateParameters() deletes |packet|.
if (comfort_noise_->UpdateParameters(packet) ==
ComfortNoise::kInternalError) {