Returning correct duration estimate on Opus DTX packets.
Bug 4985 revealed two flaws
1. Opus duration estimate did not return correct length for DTX packets,
2. NetEq DoCodecInternalCng did not assign enough buffer.
P.S.
Generalizing problem 1, current NetEq decode function checks memory size by calling the duration estimate function. This is not ideal. A better way is to let codec's decode function to receive buffer size and return failure if it is not enough. This can be made in a separate CL.
BUG=webrtc:4985
R=henrik.lundin@webrtc.org
Review URL: https://codereview.webrtc.org/1334303005 .
Cr-Commit-Position: refs/heads/master@{#10031}
diff --git a/webrtc/modules/audio_coding/neteq/neteq_impl.h b/webrtc/modules/audio_coding/neteq/neteq_impl.h
index effecba..d7c9ac4 100644
--- a/webrtc/modules/audio_coding/neteq/neteq_impl.h
+++ b/webrtc/modules/audio_coding/neteq/neteq_impl.h
@@ -243,9 +243,14 @@
AudioDecoder::SpeechType* speech_type)
EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
+ // Sub-method to Decode(). Performs codec internal CNG.
+ int DecodeCng(AudioDecoder* decoder, int* decoded_length,
+ AudioDecoder::SpeechType* speech_type)
+ EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
+
// Sub-method to Decode(). Performs the actual decoding.
int DecodeLoop(PacketList* packet_list,
- Operations* operation,
+ const Operations& operation,
AudioDecoder* decoder,
int* decoded_length,
AudioDecoder::SpeechType* speech_type)
@@ -290,7 +295,8 @@
// Calls the audio decoder to generate codec-internal comfort noise when
// no packet was received.
- void DoCodecInternalCng() EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
+ void DoCodecInternalCng(const int16_t* decoded_buffer, size_t decoded_length)
+ EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
// Calls the DtmfToneGenerator class to generate DTMF tones.
int DoDtmf(const DtmfEvent& dtmf_event, bool* play_dtmf)