Re-organizing ACM tests

The ACM tests needed re-writing, because all tests were not individual gtests, and the result was difficult to interpret.

While doing the re-write, I discovered a bug related to 48 kHz CNG. We can't have the 48 kHz CNG active at the moment. The bug is fixed in this CL.

I also needed to rewrite parts of the VAD/DTX implementation, so that the status of VAD and DTX (enabled or not) is propagated back from the function SetVAD().

BUG=issue2173
R=minyue@webrtc.org, turaj@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/1961004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@4625 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
tina.legrand@webrtc.org
2013-08-27 07:33:51 +00:00
parent d6fef9d380
commit ee92b664b3
19 changed files with 496 additions and 1038 deletions

View File

@@ -491,7 +491,11 @@ int16_t ACMGenericCodec::ResetEncoderSafe() {
DisableVAD();
// Set DTX/VAD.
return SetVADSafe(enable_dtx, enable_vad, mode);
int status = SetVADSafe(&enable_dtx, &enable_vad, &mode);
vad_enabled_ = enable_dtx;
dtx_enabled_ = enable_vad;
vad_mode_ = mode;
return status;
}
int16_t ACMGenericCodec::InternalResetEncoder() {
@@ -579,8 +583,8 @@ int16_t ACMGenericCodec::InitEncoderSafe(WebRtcACMCodecParams* codec_params,
}
is_audio_buff_fresh_ = true;
}
status = SetVADSafe(codec_params->enable_dtx, codec_params->enable_vad,
codec_params->vad_mode);
status = SetVADSafe(&codec_params->enable_dtx, &codec_params->enable_vad,
&codec_params->vad_mode);
return status;
}
@@ -856,70 +860,76 @@ uint32_t ACMGenericCodec::EarliestTimestamp() const {
return in_timestamp_[0];
}
int16_t ACMGenericCodec::SetVAD(const bool enable_dtx,
const bool enable_vad,
const ACMVADMode mode) {
int16_t ACMGenericCodec::SetVAD(bool* enable_dtx, bool* enable_vad,
ACMVADMode* mode) {
WriteLockScoped cs(codec_wrapper_lock_);
return SetVADSafe(enable_dtx, enable_vad, mode);
}
int16_t ACMGenericCodec::SetVADSafe(const bool enable_dtx,
const bool enable_vad,
const ACMVADMode mode) {
if (enable_dtx) {
int16_t ACMGenericCodec::SetVADSafe(bool* enable_dtx, bool* enable_vad,
ACMVADMode* mode) {
if (!STR_CASE_CMP(encoder_params_.codec_inst.plname, "OPUS") ||
encoder_params_.codec_inst.channels == 2 ) {
// VAD/DTX is not supported for Opus (even if sending mono), or other
// stereo codecs.
DisableDTX();
DisableVAD();
*enable_dtx = false;
*enable_vad = false;
return 0;
}
if (*enable_dtx) {
// Make G729 AnnexB a special case.
if (!STR_CASE_CMP(encoder_params_.codec_inst.plname, "G729")
&& !has_internal_dtx_) {
if (ACMGenericCodec::EnableDTX() < 0) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"SetVADSafe: error in enable DTX");
*enable_dtx = false;
*enable_vad = vad_enabled_;
return -1;
}
} else {
if (EnableDTX() < 0) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"SetVADSafe: error in enable DTX");
*enable_dtx = false;
*enable_vad = vad_enabled_;
return -1;
}
}
if (has_internal_dtx_) {
// Codec has internal DTX, practically we don't need WebRtc VAD, however,
// we let the user to turn it on if they need call-backs on silence.
// Store VAD mode for future even if VAD is off.
vad_mode_ = mode;
return (enable_vad) ? EnableVAD(mode) : DisableVAD();
} else {
// Codec does not have internal DTX so enabling DTX requires an active
// VAD. 'enable_dtx == true' overwrites VAD status.
if (EnableVAD(mode) < 0) {
// If we cannot create VAD we have to disable DTX.
if (!vad_enabled_) {
DisableDTX();
}
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"SetVADSafe: error in enable VAD");
return -1;
}
// Return '1', to let the caller know VAD was turned on, even if the
// function was called with VAD='false'.
if (enable_vad == false) {
return 1;
} else {
return 0;
}
// If codec does not have internal DTX (normal case) enabling DTX requires
// an active VAD. '*enable_dtx == true' overwrites VAD status.
// If codec has internal DTX, practically we don't need WebRtc VAD, however,
// we let the user to turn it on if they need call-backs on silence.
if (!has_internal_dtx_) {
// DTX is enabled, and VAD will be activated.
*enable_vad = true;
}
} else {
// Make G729 AnnexB a special case.
if (!STR_CASE_CMP(encoder_params_.codec_inst.plname, "G729")
&& !has_internal_dtx_) {
ACMGenericCodec::DisableDTX();
*enable_dtx = false;
} else {
DisableDTX();
*enable_dtx = false;
}
return (enable_vad) ? EnableVAD(mode) : DisableVAD();
}
int16_t status = (*enable_vad) ? EnableVAD(*mode) : DisableVAD();
if (status < 0) {
// Failed to set VAD, disable DTX.
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"SetVADSafe: error in enable VAD");
DisableDTX();
*enable_dtx = false;
*enable_vad = false;
}
return status;
}
int16_t ACMGenericCodec::EnableDTX() {