Re-land "Switch to using AudioEncoderIsac instead of ACMISAC"

It should work now, after the fix in r8431.

Previously committed in r8342, reverted in r8372, committed in r8378,
and reverted in r8412.

COAUTHOR=henrik.lundin@webrtc.org
BUG=4228
TBR=henrik.lundin@webrtc.org

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

Cr-Commit-Position: refs/heads/master@{#8433}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8433 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
kwiberg@webrtc.org 2015-02-19 15:10:20 +00:00
parent 1ed6224eaf
commit be96bfb179
5 changed files with 26 additions and 27 deletions

View File

@ -23,6 +23,7 @@ namespace webrtc {
const int kIsacPayloadType = 103; const int kIsacPayloadType = 103;
const int kInvalidPayloadType = -1; const int kInvalidPayloadType = -1;
const int kDefaultBitRate = 32000;
template <typename T> template <typename T>
AudioEncoderDecoderIsacT<T>::Config::Config() AudioEncoderDecoderIsacT<T>::Config::Config()
@ -30,7 +31,7 @@ AudioEncoderDecoderIsacT<T>::Config::Config()
red_payload_type(kInvalidPayloadType), red_payload_type(kInvalidPayloadType),
sample_rate_hz(16000), sample_rate_hz(16000),
frame_size_ms(30), frame_size_ms(30),
bit_rate(32000), bit_rate(kDefaultBitRate),
max_bit_rate(-1), max_bit_rate(-1),
max_payload_size_bytes(-1) { max_payload_size_bytes(-1) {
} }
@ -48,7 +49,7 @@ bool AudioEncoderDecoderIsacT<T>::Config::IsOk() const {
if (max_payload_size_bytes > 400) if (max_payload_size_bytes > 400)
return false; return false;
return (frame_size_ms == 30 || frame_size_ms == 60) && return (frame_size_ms == 30 || frame_size_ms == 60) &&
bit_rate >= 10000 && bit_rate <= 32000; ((bit_rate >= 10000 && bit_rate <= 32000) || bit_rate == 0);
case 32000: case 32000:
case 48000: case 48000:
if (max_bit_rate > 160000) if (max_bit_rate > 160000)
@ -56,7 +57,8 @@ bool AudioEncoderDecoderIsacT<T>::Config::IsOk() const {
if (max_payload_size_bytes > 600) if (max_payload_size_bytes > 600)
return false; return false;
return T::has_swb && return T::has_swb &&
(frame_size_ms == 30 && bit_rate >= 10000 && bit_rate <= 56000); (frame_size_ms == 30 &&
((bit_rate >= 10000 && bit_rate <= 56000) || bit_rate == 0));
default: default:
return false; return false;
} }
@ -68,7 +70,7 @@ AudioEncoderDecoderIsacT<T>::ConfigAdaptive::ConfigAdaptive()
red_payload_type(kInvalidPayloadType), red_payload_type(kInvalidPayloadType),
sample_rate_hz(16000), sample_rate_hz(16000),
initial_frame_size_ms(30), initial_frame_size_ms(30),
initial_bit_rate(32000), initial_bit_rate(kDefaultBitRate),
max_bit_rate(-1), max_bit_rate(-1),
enforce_frame_size(false), enforce_frame_size(false),
max_payload_size_bytes(-1) { max_payload_size_bytes(-1) {
@ -114,7 +116,9 @@ AudioEncoderDecoderIsacT<T>::AudioEncoderDecoderIsacT(const Config& config)
CHECK_EQ(0, T::Create(&isac_state_)); CHECK_EQ(0, T::Create(&isac_state_));
CHECK_EQ(0, T::EncoderInit(isac_state_, 1)); CHECK_EQ(0, T::EncoderInit(isac_state_, 1));
CHECK_EQ(0, T::SetEncSampRate(isac_state_, config.sample_rate_hz)); CHECK_EQ(0, T::SetEncSampRate(isac_state_, config.sample_rate_hz));
CHECK_EQ(0, T::Control(isac_state_, config.bit_rate, config.frame_size_ms)); CHECK_EQ(0, T::Control(isac_state_, config.bit_rate == 0 ? kDefaultBitRate
: config.bit_rate,
config.frame_size_ms));
// When config.sample_rate_hz is set to 48000 Hz (iSAC-fb), the decoder is // When config.sample_rate_hz is set to 48000 Hz (iSAC-fb), the decoder is
// still set to 32000 Hz, since there is no full-band mode in the decoder. // still set to 32000 Hz, since there is no full-band mode in the decoder.
CHECK_EQ(0, T::SetDecSampRate(isac_state_, CHECK_EQ(0, T::SetDecSampRate(isac_state_,

View File

@ -575,7 +575,9 @@ ACMGenericCodec* ACMCodecDB::CreateCodecInstance(const CodecInst& codec_inst,
// All we have support for right now. // All we have support for right now.
if (!STR_CASE_CMP(codec_inst.plname, "ISAC")) { if (!STR_CASE_CMP(codec_inst.plname, "ISAC")) {
#if (defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)) #if (defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX))
return new ACMISAC(kISAC, enable_red); return new ACMGenericCodecWrapper(codec_inst, cng_pt_nb, cng_pt_wb,
cng_pt_swb, cng_pt_fb, enable_red,
red_payload_type);
#endif #endif
} else if (!STR_CASE_CMP(codec_inst.plname, "PCMU") || } else if (!STR_CASE_CMP(codec_inst.plname, "PCMU") ||
!STR_CASE_CMP(codec_inst.plname, "PCMA")) { !STR_CASE_CMP(codec_inst.plname, "PCMA")) {

View File

@ -270,7 +270,6 @@ int32_t AudioCodingModuleImpl::Process() {
FrameType frame_type = kAudioFrameSpeech; FrameType frame_type = kAudioFrameSpeech;
uint8_t current_payload_type = 0; uint8_t current_payload_type = 0;
bool has_data_to_send = false; bool has_data_to_send = false;
bool red_active = false;
RTPFragmentationHeader my_fragmentation; RTPFragmentationHeader my_fragmentation;
// Keep the scope of the ACM critical section limited. // Keep the scope of the ACM critical section limited.
@ -302,36 +301,32 @@ int32_t AudioCodingModuleImpl::Process() {
} }
case kActiveNormalEncoded: case kActiveNormalEncoded:
case kPassiveNormalEncoded: { case kPassiveNormalEncoded: {
current_payload_type = static_cast<uint8_t>(send_codec_inst_.pltype);
frame_type = kAudioFrameSpeech; frame_type = kAudioFrameSpeech;
break; break;
} }
case kPassiveDTXNB: { case kPassiveDTXNB: {
current_payload_type = cng_nb_pltype_;
frame_type = kAudioFrameCN; frame_type = kAudioFrameCN;
is_first_red_ = true; is_first_red_ = true;
break; break;
} }
case kPassiveDTXWB: { case kPassiveDTXWB: {
current_payload_type = cng_wb_pltype_;
frame_type = kAudioFrameCN; frame_type = kAudioFrameCN;
is_first_red_ = true; is_first_red_ = true;
break; break;
} }
case kPassiveDTXSWB: { case kPassiveDTXSWB: {
current_payload_type = cng_swb_pltype_;
frame_type = kAudioFrameCN; frame_type = kAudioFrameCN;
is_first_red_ = true; is_first_red_ = true;
break; break;
} }
case kPassiveDTXFB: { case kPassiveDTXFB: {
current_payload_type = cng_fb_pltype_;
frame_type = kAudioFrameCN; frame_type = kAudioFrameCN;
is_first_red_ = true; is_first_red_ = true;
break; break;
} }
} }
has_data_to_send = true; has_data_to_send = true;
current_payload_type = encoded_info.payload_type;
previous_pltype_ = current_payload_type; previous_pltype_ = current_payload_type;
ConvertEncodedInfoToFragmentationHeader(encoded_info, &my_fragmentation); ConvertEncodedInfoToFragmentationHeader(encoded_info, &my_fragmentation);
@ -348,8 +343,9 @@ int32_t AudioCodingModuleImpl::Process() {
// have been switched to the new AudioEncoder interface. // have been switched to the new AudioEncoder interface.
if ((codecs_[current_send_codec_idx_]->ExternalRedNeeded()) && if ((codecs_[current_send_codec_idx_]->ExternalRedNeeded()) &&
((encoding_type == kActiveNormalEncoded) || ((encoding_type == kActiveNormalEncoded) ||
(encoding_type == kPassiveNormalEncoded))) { (encoding_type == kPassiveNormalEncoded))) {
DCHECK(encoded_info.redundant.empty()); DCHECK(encoded_info.redundant.empty());
FATAL() << "Don't go here!";
// RED is enabled within this scope. // RED is enabled within this scope.
// //
// Note that, a special solution exists for iSAC since it is the only // Note that, a special solution exists for iSAC since it is the only
@ -389,7 +385,6 @@ int32_t AudioCodingModuleImpl::Process() {
// //
// Hence, even if every second packet is dropped, perfect // Hence, even if every second packet is dropped, perfect
// reconstruction is possible. // reconstruction is possible.
red_active = true;
has_data_to_send = false; has_data_to_send = false;
// Skip the following part for the first packet in a RED session. // Skip the following part for the first packet in a RED session.
@ -457,7 +452,7 @@ int32_t AudioCodingModuleImpl::Process() {
CriticalSectionScoped lock(callback_crit_sect_); CriticalSectionScoped lock(callback_crit_sect_);
if (packetization_callback_ != NULL) { if (packetization_callback_ != NULL) {
if (red_active || my_fragmentation.fragmentationVectorSize > 0) { if (my_fragmentation.fragmentationVectorSize > 0) {
// Callback with payload data, including redundant data (RED). // Callback with payload data, including redundant data (RED).
packetization_callback_->SendData(frame_type, current_payload_type, packetization_callback_->SendData(frame_type, current_payload_type,
rtp_timestamp, stream, length_bytes, rtp_timestamp, stream, length_bytes,

View File

@ -809,15 +809,14 @@ TEST_F(AcmSenderBitExactness, DISABLED_ON_ANDROID(IsacSwb30ms)) {
ASSERT_NO_FATAL_FAILURE( ASSERT_NO_FATAL_FAILURE(
SetUpTest(acm2::ACMCodecDB::kISACSWB, 1, 104, 960, 960)); SetUpTest(acm2::ACMCodecDB::kISACSWB, 1, 104, 960, 960));
Run(AcmReceiverBitExactness::PlatformChecksum( Run(AcmReceiverBitExactness::PlatformChecksum(
"98d960600eb4ddb3fcbe11f5057ddfd7", "2b3c387d06f00b7b7aad4c9be56fb83d",
"", "",
"2f6dfe142f735f1d96f6bd86d2526f42"), "5683b58da0fbf2063c7adc2e6bfb3fb8"),
AcmReceiverBitExactness::PlatformChecksum( AcmReceiverBitExactness::PlatformChecksum(
"cc9d2d86a71d6f99f97680a5c27e2762", "bcc2041e7744c7ebd9f701866856849c",
"", "",
"7b214fc3a5e33d68bf30e77969371f31"), "ce86106a93419aefb063097108ec94ab"),
33, 33, test::AcmReceiveTest::kMonoOutput);
test::AcmReceiveTest::kMonoOutput);
} }
TEST_F(AcmSenderBitExactness, Pcm16_8000khz_10ms) { TEST_F(AcmSenderBitExactness, Pcm16_8000khz_10ms) {

View File

@ -960,15 +960,14 @@ TEST_F(AcmSenderBitExactnessOldApi, MAYBE_IsacWb60ms) {
TEST_F(AcmSenderBitExactnessOldApi, DISABLED_ON_ANDROID(IsacSwb30ms)) { TEST_F(AcmSenderBitExactnessOldApi, DISABLED_ON_ANDROID(IsacSwb30ms)) {
ASSERT_NO_FATAL_FAILURE(SetUpTest("ISAC", 32000, 1, 104, 960, 960)); ASSERT_NO_FATAL_FAILURE(SetUpTest("ISAC", 32000, 1, 104, 960, 960));
Run(AcmReceiverBitExactnessOldApi::PlatformChecksum( Run(AcmReceiverBitExactnessOldApi::PlatformChecksum(
"98d960600eb4ddb3fcbe11f5057ddfd7", "2b3c387d06f00b7b7aad4c9be56fb83d",
"", "",
"2f6dfe142f735f1d96f6bd86d2526f42"), "5683b58da0fbf2063c7adc2e6bfb3fb8"),
AcmReceiverBitExactnessOldApi::PlatformChecksum( AcmReceiverBitExactnessOldApi::PlatformChecksum(
"cc9d2d86a71d6f99f97680a5c27e2762", "bcc2041e7744c7ebd9f701866856849c",
"", "",
"7b214fc3a5e33d68bf30e77969371f31"), "ce86106a93419aefb063097108ec94ab"),
33, 33, test::AcmReceiveTestOldApi::kMonoOutput);
test::AcmReceiveTestOldApi::kMonoOutput);
} }
TEST_F(AcmSenderBitExactnessOldApi, Pcm16_8000khz_10ms) { TEST_F(AcmSenderBitExactnessOldApi, Pcm16_8000khz_10ms) {