From bfde543f73681b7e4cb41edc0be0088b9068f29f Mon Sep 17 00:00:00 2001 From: kwiberg Date: Fri, 22 Apr 2016 00:32:02 -0700 Subject: [PATCH] Audio Coding Module: Use separate instances for 16 kHz and 32 kHz iSAC decoder This will allow us to fix the sample rate of each AudioDecoder at instantiation time. This change results in different checksums for the following tests: AcmReceiverBitExactnessOldApi.8kHzOutput AcmReceiverBitExactnessOldApi.16kHzOutput AcmReceiverBitExactnessOldApi.32kHzOutput AcmReceiverBitExactnessOldApi.48kHzOutputExternalDecoder AcmReceiverBitExactnessOldApi.48kHzOutput Because they make an ACM and then ask it to decode both 16 kHz and 32 kHz iSAC. (The arm32 and arm64 checksums didn't change, because the tests skip 32 kHz iSAC on arm.) BUG=webrtc:5801 Review URL: https://codereview.webrtc.org/1908923002 Cr-Commit-Position: refs/heads/master@{#12463} --- .../acm2/audio_coding_module_impl.cc | 8 +++++--- .../acm2/audio_coding_module_impl.h | 3 ++- .../audio_coding_module_unittest_oldapi.cc | 20 +++++++++---------- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/webrtc/modules/audio_coding/acm2/audio_coding_module_impl.cc b/webrtc/modules/audio_coding/acm2/audio_coding_module_impl.cc index f00b2432f2..1a1ae37a8a 100644 --- a/webrtc/modules/audio_coding/acm2/audio_coding_module_impl.cc +++ b/webrtc/modules/audio_coding/acm2/audio_coding_module_impl.cc @@ -719,10 +719,12 @@ int AudioCodingModuleImpl::RegisterReceiveCodecUnlocked( AudioDecoder* isac_decoder = nullptr; if (STR_CASE_CMP(codec.plname, "isac") == 0) { - if (!isac_decoder_) { - isac_decoder_ = isac_factory(); + std::unique_ptr& saved_isac_decoder = + codec.plfreq == 16000 ? isac_decoder_16k_ : isac_decoder_32k_; + if (!saved_isac_decoder) { + saved_isac_decoder = isac_factory(); } - isac_decoder = isac_decoder_.get(); + isac_decoder = saved_isac_decoder.get(); } return receiver_.AddCodec(*codec_index, codec.pltype, codec.channels, codec.plfreq, isac_decoder, codec.plname); diff --git a/webrtc/modules/audio_coding/acm2/audio_coding_module_impl.h b/webrtc/modules/audio_coding/acm2/audio_coding_module_impl.h index 63dfb81056..5ae6677cf9 100644 --- a/webrtc/modules/audio_coding/acm2/audio_coding_module_impl.h +++ b/webrtc/modules/audio_coding/acm2/audio_coding_module_impl.h @@ -268,7 +268,8 @@ class AudioCodingModuleImpl final : public AudioCodingModule { // RegisterEncoder. std::unique_ptr encoder_stack_ GUARDED_BY(acm_crit_sect_); - std::unique_ptr isac_decoder_ GUARDED_BY(acm_crit_sect_); + std::unique_ptr isac_decoder_16k_ GUARDED_BY(acm_crit_sect_); + std::unique_ptr isac_decoder_32k_ GUARDED_BY(acm_crit_sect_); // This is to keep track of CN instances where we can send DTMFs. uint8_t previous_pltype_ GUARDED_BY(acm_crit_sect_); diff --git a/webrtc/modules/audio_coding/acm2/audio_coding_module_unittest_oldapi.cc b/webrtc/modules/audio_coding/acm2/audio_coding_module_unittest_oldapi.cc index 6e004f9e28..503acdd65d 100644 --- a/webrtc/modules/audio_coding/acm2/audio_coding_module_unittest_oldapi.cc +++ b/webrtc/modules/audio_coding/acm2/audio_coding_module_unittest_oldapi.cc @@ -939,32 +939,32 @@ class AcmReceiverBitExactnessOldApi : public ::testing::Test { #if (defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)) && \ defined(WEBRTC_CODEC_ILBC) && defined(WEBRTC_CODEC_G722) TEST_F(AcmReceiverBitExactnessOldApi, 8kHzOutput) { - Run(8000, PlatformChecksum("d9334a99c7f185860028e6f08e5b7390", - "946803da293ef3fa39242d3059eac491", + Run(8000, PlatformChecksum("f34e5c0e4dd4cd6c82b23f6ed006dad0", + "67a1471049dc87e7498bc19bf130dd35", "efb5a07480bad8afb184c4150f4b3f3a", "51717ab374871cbfa2c6977ea2aa40f3"), std::vector()); } TEST_F(AcmReceiverBitExactnessOldApi, 16kHzOutput) { - Run(16000, PlatformChecksum("9ad7d5a5f3c9fac4e880a6fbfd9d3ac8", - "4fc1b82404ae33511c1cdb385774b2a4", + Run(16000, PlatformChecksum("5066b412805f3050f65154d676006964", + "887905a40d37f213b76f64296871473e", "f580bfd4e5e29f0399b61b7512d4e3b4", "5b2ae32c590b41d0c601179e14eaae96"), std::vector()); } TEST_F(AcmReceiverBitExactnessOldApi, 32kHzOutput) { - Run(32000, PlatformChecksum("08e6085ccb96494b242f0ecc4c8a2dc8", - "d1f853b1e046c67c9ee186786eaf2124", + Run(32000, PlatformChecksum("2cb4784af507c45b9121e2315def36f2", + "d2392b3247095d894a49b74a1106f281", "fdf5166b98c43235978685e40e28fea6", "7f620312f2fa74a10048bbb7739d4bf3"), std::vector()); } TEST_F(AcmReceiverBitExactnessOldApi, 48kHzOutput) { - Run(48000, PlatformChecksum("31343887b7ef70772df733d072b0dd00", - "f6893278d75dad42ac44bff77f674b33", + Run(48000, PlatformChecksum("ce63f874a198621fa35398e412640fcf", + "2cf0b8fe9784e8c96db307e125beb723", "71f89e87ee1bad594f529d6c036289ad", "b64c891e99eccc9ff45541ef67c9e9bf"), std::vector()); @@ -1021,8 +1021,8 @@ TEST_F(AcmReceiverBitExactnessOldApi, 48kHzOutputExternalDecoder) { std::vector external_decoders; external_decoders.push_back(ed); - Run(48000, PlatformChecksum("31343887b7ef70772df733d072b0dd00", - "f6893278d75dad42ac44bff77f674b33", + Run(48000, PlatformChecksum("ce63f874a198621fa35398e412640fcf", + "2cf0b8fe9784e8c96db307e125beb723", "71f89e87ee1bad594f529d6c036289ad", "b64c891e99eccc9ff45541ef67c9e9bf"), external_decoders);