diff --git a/src/modules/audio_processing/aec/aec.gypi b/src/modules/audio_processing/aec/aec.gypi index 1300d0e45..7ef89181a 100644 --- a/src/modules/audio_processing/aec/aec.gypi +++ b/src/modules/audio_processing/aec/aec.gypi @@ -11,6 +11,10 @@ { 'target_name': 'aec', 'type': '<(library)', + 'variables': { + # Outputs some low-level debug files. + 'aec_debug_dump%': 0, + }, 'dependencies': [ '<(webrtc_root)/common_audio/common_audio.gyp:signal_processing', 'apm_util' @@ -35,6 +39,11 @@ 'resampler.h', 'resampler.c', ], + 'conditions': [ + ['aec_debug_dump==1', { + 'defines': [ 'WEBRTC_AEC_DEBUG_DUMP', ], + }], + ], }, ], } diff --git a/src/modules/audio_processing/aec/aec_core.c b/src/modules/audio_processing/aec/aec_core.c index 3c78dfc3a..ac1859935 100644 --- a/src/modules/audio_processing/aec/aec_core.c +++ b/src/modules/audio_processing/aec/aec_core.c @@ -592,9 +592,9 @@ static void ProcessBlock(aec_t *aec, const short *farend, const float ramp = 1.0002f; const float gInitNoise[2] = {0.999f, 0.001f}; -#ifdef AEC_DEBUG - fwrite(farend, sizeof(short), PART_LEN, aec->farFile); - fwrite(nearend, sizeof(short), PART_LEN, aec->nearFile); +#ifdef WEBRTC_AEC_DEBUG_DUMP + fwrite(farend, sizeof(int16_t), PART_LEN, aec->farFile); + fwrite(nearend, sizeof(int16_t), PART_LEN, aec->nearFile); #endif memset(dH, 0, sizeof(dH)); @@ -760,13 +760,6 @@ static void ProcessBlock(aec_t *aec, const short *farend, WebRtcAec_FilterAdaptation(aec, fft, ef); NonLinearProcessing(aec, output, outputH); -#ifdef AEC_DEBUG - for (i = 0; i < PART_LEN; i++) { - eInt16[i] = (short)WEBRTC_SPL_SAT(WEBRTC_SPL_WORD16_MAX, e[i], - WEBRTC_SPL_WORD16_MIN); - } -#endif - if (aec->metricsMode == 1) { for (i = 0; i < PART_LEN; i++) { eInt16[i] = (short)WEBRTC_SPL_SAT(WEBRTC_SPL_WORD16_MAX, e[i], @@ -781,9 +774,14 @@ static void ProcessBlock(aec_t *aec, const short *farend, UpdateMetrics(aec); } -#ifdef AEC_DEBUG - fwrite(eInt16, sizeof(short), PART_LEN, aec->outLpFile); - fwrite(output, sizeof(short), PART_LEN, aec->outFile); +#ifdef WEBRTC_AEC_DEBUG_DUMP + for (i = 0; i < PART_LEN; i++) { + eInt16[i] = (int16_t)WEBRTC_SPL_SAT(WEBRTC_SPL_WORD16_MAX, e[i], + WEBRTC_SPL_WORD16_MIN); + } + + fwrite(eInt16, sizeof(int16_t), PART_LEN, aec->outLinearFile); + fwrite(output, sizeof(int16_t), PART_LEN, aec->outFile); #endif } diff --git a/src/modules/audio_processing/aec/aec_core.h b/src/modules/audio_processing/aec/aec_core.h index e69342585..78b53491e 100644 --- a/src/modules/audio_processing/aec/aec_core.h +++ b/src/modules/audio_processing/aec/aec_core.h @@ -20,8 +20,6 @@ #include "signal_processing_library.h" #include "typedefs.h" -//#define AEC_DEBUG // for recording files - #define FRAME_LEN 80 #define PART_LEN 64 // Length of partition #define PART_LEN1 (PART_LEN + 1) // Unique fft coefficients @@ -147,11 +145,11 @@ typedef struct { int delay_logging_enabled; void* delay_estimator; -#ifdef AEC_DEBUG +#ifdef WEBRTC_AEC_DEBUG_DUMP FILE *farFile; FILE *nearFile; FILE *outFile; - FILE *outLpFile; + FILE *outLinearFile; #endif } aec_t; diff --git a/src/modules/audio_processing/aec/echo_cancellation.c b/src/modules/audio_processing/aec/echo_cancellation.c index f35105f48..a3bad4969 100644 --- a/src/modules/audio_processing/aec/echo_cancellation.c +++ b/src/modules/audio_processing/aec/echo_cancellation.c @@ -14,7 +14,7 @@ #include "echo_cancellation.h" #include -#ifdef AEC_DEBUG +#ifdef WEBRTC_AEC_DEBUG_DUMP #include #endif #include @@ -71,13 +71,11 @@ typedef struct { int delayChange; short lastDelayDiff; -#ifdef AEC_DEBUG +#ifdef WEBRTC_AEC_DEBUG_DUMP FILE *bufFile; FILE *delayFile; FILE *skewFile; - FILE *preCompFile; - FILE *postCompFile; -#endif // AEC_DEBUG +#endif // Structures void *farendBuf; @@ -134,18 +132,15 @@ WebRtc_Word32 WebRtcAec_Create(void **aecInst) aecpc->initFlag = 0; aecpc->lastError = 0; -#ifdef AEC_DEBUG - aecpc->aec->farFile = fopen("aecFar.pcm","wb"); - aecpc->aec->nearFile = fopen("aecNear.pcm","wb"); - aecpc->aec->outFile = fopen("aecOut.pcm","wb"); - aecpc->aec->outLpFile = fopen("aecOutLp.pcm","wb"); - - aecpc->bufFile = fopen("aecBuf.dat", "wb"); - aecpc->skewFile = fopen("aecSkew.dat", "wb"); - aecpc->delayFile = fopen("aecDelay.dat", "wb"); - aecpc->preCompFile = fopen("preComp.pcm", "wb"); - aecpc->postCompFile = fopen("postComp.pcm", "wb"); -#endif // AEC_DEBUG +#ifdef WEBRTC_AEC_DEBUG_DUMP + aecpc->aec->farFile = fopen("aec_far.pcm","wb"); + aecpc->aec->nearFile = fopen("aec_near.pcm","wb"); + aecpc->aec->outFile = fopen("aec_out.pcm","wb"); + aecpc->aec->outLinearFile = fopen("aec_out_linear.pcm","wb"); + aecpc->bufFile = fopen("aec_buf.dat", "wb"); + aecpc->skewFile = fopen("aec_skew.dat", "wb"); + aecpc->delayFile = fopen("aec_delay.dat", "wb"); +#endif return 0; } @@ -158,18 +153,15 @@ WebRtc_Word32 WebRtcAec_Free(void *aecInst) return -1; } -#ifdef AEC_DEBUG +#ifdef WEBRTC_AEC_DEBUG_DUMP fclose(aecpc->aec->farFile); fclose(aecpc->aec->nearFile); fclose(aecpc->aec->outFile); - fclose(aecpc->aec->outLpFile); - + fclose(aecpc->aec->outLinearFile); fclose(aecpc->bufFile); fclose(aecpc->skewFile); fclose(aecpc->delayFile); - fclose(aecpc->preCompFile); - fclose(aecpc->postCompFile); -#endif // AEC_DEBUG +#endif WebRtcAec_FreeAec(aecpc->aec); WebRtcApm_FreeBuffer(aecpc->farendBuf); @@ -311,11 +303,6 @@ WebRtc_Word32 WebRtcAec_BufferFarend(void *aecInst, const WebRtc_Word16 *farend, skew, newFarend); WebRtcApm_WriteBuffer(aecpc->farendBuf, newFarend, newNrOfSamples); - -#ifdef AEC_DEBUG - fwrite(farend, 2, nrOfSamples, aecpc->preCompFile); - fwrite(newFarend, 2, newNrOfSamples, aecpc->postCompFile); -#endif } else { WebRtcApm_WriteBuffer(aecpc->farendBuf, farend, nrOfSamples); @@ -335,9 +322,6 @@ WebRtc_Word32 WebRtcAec_Process(void *aecInst, const WebRtc_Word16 *nearend, short nmbrOfFilledBuffers; short nBlocks10ms; short nFrames; -#ifdef AEC_DEBUG - short msInAECBuf; -#endif // Limit resampling to doubling/halving of signal const float minSkewEst = -0.5f; const float maxSkewEst = 1.0f; @@ -413,7 +397,7 @@ WebRtc_Word32 WebRtcAec_Process(void *aecInst, const WebRtc_Word16 *nearend, aecpc->skew = maxSkewEst; } -#ifdef AEC_DEBUG +#ifdef WEBRTC_AEC_DEBUG_DUMP fwrite(&aecpc->skew, sizeof(aecpc->skew), 1, aecpc->skewFile); #endif } @@ -523,10 +507,13 @@ WebRtc_Word32 WebRtcAec_Process(void *aecInst, const WebRtc_Word16 *nearend, } } -#ifdef AEC_DEBUG - msInAECBuf = WebRtcApm_get_buffer_size(aecpc->farendBuf) / (sampMsNb*aecpc->aec->mult); - fwrite(&msInAECBuf, 2, 1, aecpc->bufFile); - fwrite(&(aecpc->knownDelay), sizeof(aecpc->knownDelay), 1, aecpc->delayFile); +#ifdef WEBRTC_AEC_DEBUG_DUMP + { + short msInAECBuf = WebRtcApm_get_buffer_size(aecpc->farendBuf) / + (sampMsNb*aecpc->aec->mult); + fwrite(&msInAECBuf, 2, 1, aecpc->bufFile); + fwrite(&(aecpc->knownDelay), sizeof(aecpc->knownDelay), 1, aecpc->delayFile); + } #endif return retVal;