Changed OLA window for neteq. Old code didnt work well with 48khz

fixing white spaces

updated authors file

Changed OLA window to use Q14 as Q5 dosnt work with 48khz. 1 ms @ 48 khz is > 2^5

BUG=webrtc:1361

Review-Url: https://codereview.webrtc.org/2763273003
Cr-Commit-Position: refs/heads/master@{#17611}
This commit is contained in:
soren
2017-04-10 02:22:46 -07:00
committed by Commit bot
parent c547e84ec5
commit 9f2c18e237
5 changed files with 80 additions and 61 deletions

View File

@ -443,10 +443,10 @@ TEST_F(NetEqDecodingTest, MAYBE_TestBitExactness) {
webrtc::test::ResourcePath("audio_coding/neteq_universal_new", "rtp");
const std::string output_checksum = PlatformChecksum(
"5a8184bc60c0d7dddb50af8966360675476a8d8b",
"be982d2c5685dd1ca4ea5d352283df50e8e5b46d",
"5a8184bc60c0d7dddb50af8966360675476a8d8b",
"c86aec95439748f4949de95b50c94be291118615");
"09fa7646e2ad032a0b156177b95f09012430f81f",
"1c64eb8b55ce8878676c6a1e6ddd78f48de0668b",
"09fa7646e2ad032a0b156177b95f09012430f81f",
"759fef89a5de52bd17e733dc255c671ce86be909");
const std::string network_stats_checksum = PlatformChecksum(
"f59b3dfdb9b1b8bbb61abedd7c8cf3fc47c21f5f",
@ -480,10 +480,10 @@ TEST_F(NetEqDecodingTest, MAYBE_TestOpusBitExactness) {
webrtc::test::ResourcePath("audio_coding/neteq_opus", "rtp");
const std::string output_checksum = PlatformChecksum(
"9d7d52bc94e941d106aa518f324f16a58d231586",
"9d7d52bc94e941d106aa518f324f16a58d231586",
"9d7d52bc94e941d106aa518f324f16a58d231586",
"9d7d52bc94e941d106aa518f324f16a58d231586");
"6237dd113ad80d7764fe4c90b55b2ec035eae64e",
"6237dd113ad80d7764fe4c90b55b2ec035eae64e",
"6237dd113ad80d7764fe4c90b55b2ec035eae64e",
"6237dd113ad80d7764fe4c90b55b2ec035eae64e");
const std::string network_stats_checksum = PlatformChecksum(
"d8379381d5a619f0616bb3c0a8a9eea1704a8ab8",

View File

@ -130,23 +130,25 @@ int Normal::Process(const int16_t* input,
// Interpolate the expanded data into the new vector.
// (NB/WB/SWB32/SWB48 8/16/32/48 samples.)
RTC_DCHECK_LT(fs_shift, 3); // Will always be 0, 1, or, 2.
increment = 4 >> fs_shift;
int fraction = increment;
// Don't interpolate over more samples than what is in output. When this
// cap strikes, the interpolation will likely sound worse, but this is an
// emergency operation in response to unexpected input.
const size_t interp_len_samples =
std::min(static_cast<size_t>(8 * fs_mult), output->Size());
for (size_t i = 0; i < interp_len_samples; ++i) {
// TODO(hlundin): Add 16 instead of 8 for correct rounding. Keeping 8
// now for legacy bit-exactness.
RTC_DCHECK_LT(channel_ix, output->Channels());
RTC_DCHECK_LT(i, output->Size());
size_t win_length = samples_per_ms_;
int16_t win_slope_Q14 = default_win_slope_Q14_;
RTC_DCHECK_LT(channel_ix, output->Channels());
if (win_length > output->Size()) {
win_length = output->Size();
win_slope_Q14 = (1 << 14) / static_cast<int16_t>(win_length);
}
int16_t win_up_Q14 = 0;
for (size_t i = 0; i < win_length; i++) {
win_up_Q14 += win_slope_Q14;
(*output)[channel_ix][i] =
static_cast<int16_t>((fraction * (*output)[channel_ix][i] +
(32 - fraction) * expanded[channel_ix][i] + 8) >> 5);
fraction += increment;
(win_up_Q14 * (*output)[channel_ix][i] +
((1 << 14) - win_up_Q14) * expanded[channel_ix][i] + (1 << 13)) >>
14;
}
if (fs_hz_ == 48000) {
RTC_DCHECK_EQ(win_up_Q14, (1 << 14) - 16);
} else {
RTC_DCHECK_EQ(win_up_Q14, 1 << 14);
}
}
} else if (last_mode == kModeRfc3389Cng) {
@ -171,15 +173,24 @@ int Normal::Process(const int16_t* input,
}
// Interpolate the CNG into the new vector.
// (NB/WB/SWB32/SWB48 8/16/32/48 samples.)
RTC_DCHECK_LT(fs_shift, 3); // Will always be 0, 1, or, 2.
int16_t increment = 4 >> fs_shift;
int16_t fraction = increment;
for (size_t i = 0; i < static_cast<size_t>(8 * fs_mult); i++) {
// TODO(hlundin): Add 16 instead of 8 for correct rounding. Keeping 8 now
// for legacy bit-exactness.
(*output)[0][i] = (fraction * (*output)[0][i] +
(32 - fraction) * cng_output[i] + 8) >> 5;
fraction += increment;
size_t win_length = samples_per_ms_;
int16_t win_slope_Q14 = default_win_slope_Q14_;
if (win_length > kCngLength) {
win_length = kCngLength;
win_slope_Q14 = (1 << 14) / static_cast<int16_t>(win_length);
}
int16_t win_up_Q14 = 0;
for (size_t i = 0; i < win_length; i++) {
win_up_Q14 += win_slope_Q14;
(*output)[0][i] =
(win_up_Q14 * (*output)[0][i] +
((1 << 14) - win_up_Q14) * cng_output[i] + (1 << 13)) >>
14;
}
if (fs_hz_ == 48000) {
RTC_DCHECK_EQ(win_up_Q14, (1 << 14) - 16);
} else {
RTC_DCHECK_EQ(win_up_Q14, 1 << 14);
}
} else if (external_mute_factor_array[0] < 16384) {
// Previous was neither of Expand, FadeToBGN or RFC3389_CNG, but we are

View File

@ -15,7 +15,9 @@
#include <vector>
#include "webrtc/base/checks.h"
#include "webrtc/base/constructormagic.h"
#include "webrtc/base/safe_conversions.h"
#include "webrtc/modules/audio_coding/neteq/audio_multi_vector.h"
#include "webrtc/modules/audio_coding/neteq/defines.h"
#include "webrtc/typedefs.h"
@ -32,14 +34,17 @@ class Expand;
// no other "special circumstances" are at hand.
class Normal {
public:
Normal(int fs_hz, DecoderDatabase* decoder_database,
Normal(int fs_hz,
DecoderDatabase* decoder_database,
const BackgroundNoise& background_noise,
Expand* expand)
: fs_hz_(fs_hz),
decoder_database_(decoder_database),
background_noise_(background_noise),
expand_(expand) {
}
expand_(expand),
samples_per_ms_(rtc::CheckedDivExact(fs_hz_, 1000)),
default_win_slope_Q14_(
rtc::dchecked_cast<uint16_t>((1 << 14) / samples_per_ms_)) {}
virtual ~Normal() {}
@ -60,6 +65,8 @@ class Normal {
DecoderDatabase* decoder_database_;
const BackgroundNoise& background_noise_;
Expand* expand_;
const size_t samples_per_ms_;
const int16_t default_win_slope_Q14_;
RTC_DISALLOW_COPY_AND_ASSIGN(Normal);
};