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

Unified Diff: webrtc/modules/audio_coding/neteq/test/RTPencode.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: Implicit conversion to ArrayView in TestSidErroneous 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
« no previous file with comments | « webrtc/modules/audio_coding/neteq/payload_splitter.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..149f2826582929d5454743c20bb5363df63893b8 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];
+webrtc::ComfortNoiseEncoder *CNG_encoder[2];
#endif
#ifdef CODEC_SPEEX_8
SPEEX_encinst_t* SPEEX8enc_inst[2];
@@ -928,18 +928,8 @@ 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);
- }
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] = new webrtc::ComfortNoiseEncoder(sampfreq, 200, 5);
}
#endif
@@ -1461,7 +1451,8 @@ 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]);
+ delete CNG_encoder[k];
+ CNG_encoder[k] = nullptr;
#endif
switch (coder) {
@@ -1600,7 +1591,7 @@ size_t NetEQTest_encode(webrtc::NetEqDecoder coder,
size_t numChannels) {
size_t cdlen = 0;
int16_t* tempdata;
- static int first_cng = 1;
+ static bool first_cng = true;
size_t tempLen;
*vad = 1;
@@ -1608,9 +1599,9 @@ size_t NetEQTest_encode(webrtc::NetEqDecoder coder,
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 size_t sampleRate_10 = static_cast<size_t>(10 * sampleRate / 1000);
+ const size_t sampleRate_20 = static_cast<size_t>(20 * sampleRate / 1000);
+ const size_t sampleRate_30 = static_cast<size_t>(30 * sampleRate / 1000);
for (size_t k = 0; k < numChannels; k++) {
tempLen = frameLen;
tempdata = &indata[k * frameLen];
@@ -1642,16 +1633,22 @@ size_t NetEQTest_encode(webrtc::NetEqDecoder coder,
if (!*vad) {
// all channels are silent
+ rtc::Buffer workaround;
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);
+ workaround.Clear();
+ tempLen = CNG_encoder[k]->Encode(
+ rtc::ArrayView<const int16_t>(
+ &indata[k * frameLen],
+ (frameLen <= 640 ? frameLen : 640) /* max 640 */),
+ first_cng,
+ &workaround);
+ memcpy(encoded, workaround.data(), tempLen);
encoded += tempLen;
cdlen += tempLen;
}
*vad = 0;
- first_cng = 0;
+ first_cng = false;
return (cdlen);
}
}
@@ -1734,7 +1731,7 @@ size_t NetEQTest_encode(webrtc::NetEqDecoder coder,
} // end for
- first_cng = 1;
+ first_cng = true;
return (totalLen);
}
« no previous file with comments | « webrtc/modules/audio_coding/neteq/payload_splitter.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698