From 64a7eab89183845e4a295c512bcf1c87a2424f86 Mon Sep 17 00:00:00 2001 From: flim Date: Fri, 12 Aug 2016 04:36:05 -0700 Subject: [PATCH] Update tests and DTX check for Opus 1.1.3. DTX is now indicated by packets that may have a size of up to 2 bytes. Ref: https://git.xiph.org/?p=opus.git;a=commit;h=1c311423c86b89eba27a494e17c79fefd7d75ab0 BUG= Review-Url: https://codereview.webrtc.org/2158293003 Cr-Commit-Position: refs/heads/master@{#13736} --- .../audio_coding_module_unittest_oldapi.cc | 20 +++++++++++-------- .../audio_coding/codecs/opus/opus_interface.c | 12 ++++++----- .../audio_coding/neteq/neteq_unittest.cc | 18 ++++++++--------- 3 files changed, 28 insertions(+), 22 deletions(-) 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 8fce2269c3..d95fcf8478 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 @@ -1418,22 +1418,22 @@ TEST_F(AcmSenderBitExactnessOldApi, MAYBE_G722_stereo_20ms) { } #endif -TEST_F(AcmSenderBitExactnessOldApi, DISABLED_Opus_stereo_20ms) { +TEST_F(AcmSenderBitExactnessOldApi, Opus_stereo_20ms) { ASSERT_NO_FATAL_FAILURE(SetUpTest("opus", 48000, 2, 120, 960, 960)); Run(AcmReceiverBitExactnessOldApi::PlatformChecksum( "855041f2490b887302bce9d544731849", "855041f2490b887302bce9d544731849", "9692eede45638eb425e0daf9c75b5c7a", - "c4faa472fbb0730370aaf34920381a09"), + "86d3552bb3492247f965cdd0e88a1c82"), AcmReceiverBitExactnessOldApi::PlatformChecksum( "d781cce1ab986b618d0da87226cdde30", "d781cce1ab986b618d0da87226cdde30", "8d6782b905c3230d4b0e3e83e1fc3439", - "8b0126eab82d9e4e367ab33ded2f1a8e"), + "798347a685fac7d0c2d8f748ffe66881"), 50, test::AcmReceiveTestOldApi::kStereoOutput); } -TEST_F(AcmSenderBitExactnessOldApi, DISABLED_Opus_stereo_20ms_voip) { +TEST_F(AcmSenderBitExactnessOldApi, Opus_stereo_20ms_voip) { ASSERT_NO_FATAL_FAILURE(SetUpTest("opus", 48000, 2, 120, 960, 960)); // If not set, default will be kAudio in case of stereo. EXPECT_EQ(0, send_test_->acm()->SetOpusApplication(kVoip)); @@ -1441,12 +1441,12 @@ TEST_F(AcmSenderBitExactnessOldApi, DISABLED_Opus_stereo_20ms_voip) { "9b9e12bc3cc793740966e11cbfa8b35b", "9b9e12bc3cc793740966e11cbfa8b35b", "0de6249018fdd316c21086db84e10610", - "fd21a19b6b1e891f5daea6c4a299c254"), + "9c4cb69db77b85841a5f8225bb8f508b"), AcmReceiverBitExactnessOldApi::PlatformChecksum( "c7340b1189652ab6b5e80dade7390cb4", "c7340b1189652ab6b5e80dade7390cb4", "95612864c954ee63e28cc6eebad56626", - "49954b0d5a5f705a8798e7071b0c6f36"), + "ae33ea2e43407cf9ebdabbbd6ca912a3"), 50, test::AcmReceiveTestOldApi::kStereoOutput); } @@ -1621,10 +1621,14 @@ TEST_F(AcmChangeBitRateOldApi, Opus_48khz_20ms_50kbps) { #endif // WEBRTC_ANDROID } -TEST_F(AcmChangeBitRateOldApi, DISABLED_Opus_48khz_20ms_100kbps) { +TEST_F(AcmChangeBitRateOldApi, Opus_48khz_20ms_100kbps) { ASSERT_NO_FATAL_FAILURE(SetUpTest("opus", 48000, 1, 107, 960, 960)); #if defined(WEBRTC_ANDROID) - Run(100000, 32200, 51480); + #if defined(WEBRTC_ARCH_ARM64) + Run(100000, 32200, 51152); + #else + Run(100000, 32200, 51248); + #endif // WEBRTC_ARCH_ARM64 #else Run(100000, 32200, 50584); #endif // WEBRTC_ANDROID diff --git a/webrtc/modules/audio_coding/codecs/opus/opus_interface.c b/webrtc/modules/audio_coding/codecs/opus/opus_interface.c index bcb0596644..9905735533 100644 --- a/webrtc/modules/audio_coding/codecs/opus/opus_interface.c +++ b/webrtc/modules/audio_coding/codecs/opus/opus_interface.c @@ -95,7 +95,11 @@ int WebRtcOpus_Encode(OpusEncInst* inst, encoded, (opus_int32)length_encoded_buffer); - if (res == 1) { + if (res <= 0) { + return -1; + } + + if (res <= 2) { // Indicates DTX since the packet has nothing but a header. In principle, // there is no need to send this packet. However, we do transmit the first // occurrence to let the decoder know that the encoder enters DTX mode. @@ -105,12 +109,10 @@ int WebRtcOpus_Encode(OpusEncInst* inst, inst->in_dtx_mode = 1; return 1; } - } else if (res > 1) { - inst->in_dtx_mode = 0; - return res; } - return -1; + inst->in_dtx_mode = 0; + return res; } int16_t WebRtcOpus_SetBitRate(OpusEncInst* inst, int32_t rate) { diff --git a/webrtc/modules/audio_coding/neteq/neteq_unittest.cc b/webrtc/modules/audio_coding/neteq/neteq_unittest.cc index 0510d70ee8..b59046ae24 100644 --- a/webrtc/modules/audio_coding/neteq/neteq_unittest.cc +++ b/webrtc/modules/audio_coding/neteq/neteq_unittest.cc @@ -492,21 +492,21 @@ TEST_F(NetEqDecodingTest, MAYBE_TestBitExactness) { #else #define MAYBE_TestOpusBitExactness DISABLED_TestOpusBitExactness #endif -TEST_F(NetEqDecodingTest, DISABLED_TestOpusBitExactness) { +TEST_F(NetEqDecodingTest, MAYBE_TestOpusBitExactness) { const std::string input_rtp_file = webrtc::test::ResourcePath("audio_coding/neteq_opus", "rtp"); const std::string output_checksum = PlatformChecksum( - "19ad24b4a1eb7a9620e6da09f98c49aa5792ade4", - "19ad24b4a1eb7a9620e6da09f98c49aa5792ade4", - "19ad24b4a1eb7a9620e6da09f98c49aa5792ade4", - "19ad24b4a1eb7a9620e6da09f98c49aa5792ade4"); + "9d7d52bc94e941d106aa518f324f16a58d231586", + "9d7d52bc94e941d106aa518f324f16a58d231586", + "9d7d52bc94e941d106aa518f324f16a58d231586", + "9d7d52bc94e941d106aa518f324f16a58d231586"); const std::string network_stats_checksum = PlatformChecksum( - "6eab76efbde753d4dde38983445ca16b4ce59b39", - "6eab76efbde753d4dde38983445ca16b4ce59b39", - "6eab76efbde753d4dde38983445ca16b4ce59b39", - "6eab76efbde753d4dde38983445ca16b4ce59b39"); + "191af29ed3b8b6dd4c4cc94dc3f33bdf48f055ef", + "191af29ed3b8b6dd4c4cc94dc3f33bdf48f055ef", + "191af29ed3b8b6dd4c4cc94dc3f33bdf48f055ef", + "191af29ed3b8b6dd4c4cc94dc3f33bdf48f055ef"); const std::string rtcp_stats_checksum = PlatformChecksum( "e37c797e3de6a64dda88c9ade7a013d022a2e1e0",