Update sampling rate and number of channels of NetEq4 if decoder is changed.
We encounter a sample-underrun if NetEq is initialized with a sampling rate fs =16000 and receive Opus packets with frame-size less than 5 ms. The reason is as follows. Let say NetEq buffer has 4 packets of Opus each of size 2.5ms this means that internally timestamp of packets incremented by 80 (internally Opus treated as 32 kHz codec). Given the initial sampling rate of NetEq, at the first time that it wants to fetch packets, it targets to fetch 160 samples. Therefore, it will only extracts 2 packets. Decoding these packets give us exactly 160 samples (5 ms at 32 kHz), however, upon decoding the first packet the internal sampling rate will be updated to 32 kHz. So it is expected that sync buffer to deliver 320 samples while it does only have 160 samples (or maybe few more as it starts with some zeros). And we encounter and under-run. Even if we ignore the under-run "assert(sync_buffer_->FutureLength() >= expand_->overlap_length())" (neteq_impl.cc::811) is trigered. I'm not sure what happens if we remove this assert perhaps NetEq will work fine in subsequent calls. However the first under-run is blocking ACM2 test to pass. Here I have a solution to update sample rate as soon as a packet is inserted, if required. It not a very efficient approach as we do the same reset in NetEqImpl::Decode(). It is a bit tricky to reproduce this because the TOT ACM tests do not run ACM2. In https://webrtc-codereview.appspot.com/2192005/ I have a patch to run both ACMs. To reproduce the problem, one can patch that CL and run $ out/Debug/modules_tests --gtest_filter=AudioCodingModuleTest.TestOpus Note that we would not encounter any problem if NetEq4 is initiated with 32000 Hz sampling rate. You can test this by setting |kNeteqInitSampleRateHz| to 32000 in webrtc/modules/audio_coding/main/acm2/acm_receiver.cc BUG= R=andrew@webrtc.org, henrik.lundin@webrtc.org, kjellander@webrtc.org Review URL: https://webrtc-codereview.appspot.com/2306004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@4896 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "gflags/gflags.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "webrtc/modules/audio_coding/neteq4/test/NETEQTEST_RTPpacket.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/pcm16b/include/pcm16b.h"
|
||||
@@ -28,6 +29,8 @@
|
||||
#include "webrtc/test/testsupport/gtest_disable.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
DEFINE_bool(gen_ref, false, "Generate reference files.");
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
static bool IsAllZero(const int16_t* buf, int buf_length) {
|
||||
@@ -313,7 +316,7 @@ void NetEqDecodingTest::DecodeAndCompare(const std::string &rtp_file,
|
||||
|
||||
std::string ref_out_file = "";
|
||||
if (ref_file.empty()) {
|
||||
ref_out_file = webrtc::test::OutputPath() + "neteq_out.pcm";
|
||||
ref_out_file = webrtc::test::OutputPath() + "neteq_universal_ref.pcm";
|
||||
}
|
||||
RefFiles ref_files(ref_file, ref_out_file);
|
||||
|
||||
@@ -508,12 +511,17 @@ TEST_F(NetEqDecodingTest, DISABLED_ON_ANDROID(MAYBE_TestBitExactness)) {
|
||||
// For Visual Studio 2012 and later, we will have to use the generic reference
|
||||
// file, rather than the windows-specific one.
|
||||
const std::string kInputRefFile = webrtc::test::ProjectRootPath() +
|
||||
"resources/audio_coding/neteq_universal_ref.pcm";
|
||||
"resources/audio_coding/neteq4_universal_ref.pcm";
|
||||
#else
|
||||
const std::string kInputRefFile =
|
||||
webrtc::test::ResourcePath("audio_coding/neteq_universal_ref", "pcm");
|
||||
webrtc::test::ResourcePath("audio_coding/neteq4_universal_ref", "pcm");
|
||||
#endif
|
||||
DecodeAndCompare(kInputRtpFile, kInputRefFile);
|
||||
|
||||
if (FLAGS_gen_ref) {
|
||||
DecodeAndCompare(kInputRtpFile, "");
|
||||
} else {
|
||||
DecodeAndCompare(kInputRtpFile, kInputRefFile);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(NetEqDecodingTest, DISABLED_ON_ANDROID(TestNetworkStatistics)) {
|
||||
@@ -523,14 +531,18 @@ TEST_F(NetEqDecodingTest, DISABLED_ON_ANDROID(TestNetworkStatistics)) {
|
||||
// For Visual Studio 2012 and later, we will have to use the generic reference
|
||||
// file, rather than the windows-specific one.
|
||||
const std::string kNetworkStatRefFile = webrtc::test::ProjectRootPath() +
|
||||
"resources/audio_coding/neteq_network_stats.dat";
|
||||
"resources/audio_coding/neteq4_network_stats.dat";
|
||||
#else
|
||||
const std::string kNetworkStatRefFile =
|
||||
webrtc::test::ResourcePath("audio_coding/neteq_network_stats", "dat");
|
||||
webrtc::test::ResourcePath("audio_coding/neteq4_network_stats", "dat");
|
||||
#endif
|
||||
const std::string kRtcpStatRefFile =
|
||||
webrtc::test::ResourcePath("audio_coding/neteq_rtcp_stats", "dat");
|
||||
DecodeAndCheckStats(kInputRtpFile, kNetworkStatRefFile, kRtcpStatRefFile);
|
||||
webrtc::test::ResourcePath("audio_coding/neteq4_rtcp_stats", "dat");
|
||||
if (FLAGS_gen_ref) {
|
||||
DecodeAndCheckStats(kInputRtpFile, "", "");
|
||||
} else {
|
||||
DecodeAndCheckStats(kInputRtpFile, kNetworkStatRefFile, kRtcpStatRefFile);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(hlundin): Re-enable test once the statistics interface is up and again.
|
||||
|
||||
Reference in New Issue
Block a user