Index: webrtc/modules/audio_coding/neteq/test/RTPencode.cc |
diff --git a/webrtc/modules/audio_coding/neteq/test/RTPencode.cc b/webrtc/modules/audio_coding/neteq/test/RTPencode.cc |
index 45586ee111c655ae0b6f28ffd339ed74bcfc32fc..cd7cf31661314861513874a0515683688485a279 100644 |
--- a/webrtc/modules/audio_coding/neteq/test/RTPencode.cc |
+++ b/webrtc/modules/audio_coding/neteq/test/RTPencode.cc |
@@ -265,7 +265,7 @@ GSMFR_encinst_t* GSMFRenc_inst[2]; |
#endif |
#if (defined(CODEC_CNGCODEC8) || defined(CODEC_CNGCODEC16) || \ |
defined(CODEC_CNGCODEC32) || defined(CODEC_CNGCODEC48)) |
-CNG_enc_inst* CNGenc_inst[2]; |
+std::unique_ptr<webrtc::ComfortNoiseEncoder> CNG_encoder[2]; |
#endif |
#ifdef CODEC_SPEEX_8 |
SPEEX_encinst_t* SPEEX8enc_inst[2]; |
@@ -928,18 +928,9 @@ int NetEQTest_init_coders(webrtc::NetEqDecoder coder, |
#if (defined(CODEC_CNGCODEC8) || defined(CODEC_CNGCODEC16) || \ |
defined(CODEC_CNGCODEC32) || defined(CODEC_CNGCODEC48)) |
- ok = WebRtcCng_CreateEnc(&CNGenc_inst[k]); |
- if (ok != 0) { |
- printf("Error: Couldn't allocate memory for CNG encoding instance\n"); |
- exit(0); |
- } |
+ // TODO(ossu): Why <= 16000? |
if (sampfreq <= 16000) { |
- ok = WebRtcCng_InitEnc(CNGenc_inst[k], sampfreq, 200, 5); |
- if (ok == -1) { |
- printf("Error: Initialization of CNG struct failed. Error code %d\n", |
- WebRtcCng_GetErrorCodeEnc(CNGenc_inst[k])); |
- exit(0); |
- } |
+ CNG_encoder[k].reset(new webrtc::ComfortNoiseEncoder(sampfreq, 200, 5)); |
kwiberg-webrtc
2016/04/12 13:35:31
The old code created but didn't initialize a CNG e
ossu
2016/04/12 13:54:50
I ... don't know. I put a TODO comment about that
hlundin-webrtc
2016/04/13 07:05:24
I think we've always said that we only support CNG
ossu
2016/04/13 11:57:07
Acknowledged.
|
} |
#endif |
@@ -1461,7 +1452,7 @@ int NetEQTest_free_coders(webrtc::NetEqDecoder coder, size_t numChannels) { |
WebRtcVad_Free(VAD_inst[k]); |
#if (defined(CODEC_CNGCODEC8) || defined(CODEC_CNGCODEC16) || \ |
defined(CODEC_CNGCODEC32) || defined(CODEC_CNGCODEC48)) |
- WebRtcCng_FreeEnc(CNGenc_inst[k]); |
+ CNG_encoder[k].reset(); |
#endif |
switch (coder) { |
@@ -1601,16 +1592,16 @@ size_t NetEQTest_encode(webrtc::NetEqDecoder coder, |
size_t cdlen = 0; |
int16_t* tempdata; |
static int first_cng = 1; |
- size_t tempLen; |
+ int tempLen; |
hlundin-webrtc
2016/04/13 07:05:24
Why change this?
ossu
2016/04/13 11:57:07
Because ComfortNoiseEncoder->Encode returns an int
|
*vad = 1; |
// check VAD first |
if (useVAD) { |
*vad = 0; |
- size_t sampleRate_10 = static_cast<size_t>(10 * sampleRate / 1000); |
- size_t sampleRate_20 = static_cast<size_t>(20 * sampleRate / 1000); |
- size_t sampleRate_30 = static_cast<size_t>(30 * sampleRate / 1000); |
+ const int sampleRate_10 = 10 * sampleRate / 1000; |
hlundin-webrtc
2016/04/13 07:05:24
And these?
ossu
2016/04/13 11:57:07
Because changing tempLen to int caused a warning a
|
+ const int sampleRate_20 = 20 * sampleRate / 1000; |
+ const int sampleRate_30 = 30 * sampleRate / 1000; |
for (size_t k = 0; k < numChannels; k++) { |
tempLen = frameLen; |
tempdata = &indata[k * frameLen]; |
@@ -1644,9 +1635,15 @@ size_t NetEQTest_encode(webrtc::NetEqDecoder coder, |
// all channels are silent |
cdlen = 0; |
for (size_t k = 0; k < numChannels; k++) { |
- WebRtcCng_Encode(CNGenc_inst[k], &indata[k * frameLen], |
- (frameLen <= 640 ? frameLen : 640) /* max 640 */, |
- encoded, &tempLen, first_cng); |
+ tempLen = CNG_encoder[k]->Encode( |
+ rtc::ArrayView<const int16_t>( |
+ &indata[k * frameLen], |
+ (frameLen <= 640 ? frameLen : 640) /* max 640 */), |
+ // TODO(ossu): kRtpDataSize is wrong to use here, but we should be |
+ // fine. |
+ rtc::ArrayView<uint8_t>(encoded, kRtpDataSize), |
+ first_cng); |
+ RTC_CHECK_GE(tempLen, 0); |
encoded += tempLen; |
cdlen += tempLen; |
} |