Chromium Code Reviews| Index: webrtc/modules/audio_coding/neteq/normal.cc |
| diff --git a/webrtc/modules/audio_coding/neteq/normal.cc b/webrtc/modules/audio_coding/neteq/normal.cc |
| index 3dee39a8bc54e0ed2e176b80f64b83e0f9a9d40d..44a5a779fd3dbb4f64d01b879bcc414e73594fcc 100644 |
| --- a/webrtc/modules/audio_coding/neteq/normal.cc |
| +++ b/webrtc/modules/audio_coding/neteq/normal.cc |
| @@ -130,23 +130,20 @@ 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()); |
| + int win_length = ola_win_length_ ; |
|
hlundin-webrtc
2017/03/23 11:41:50
int -> size_t
squashingskak
2017/03/27 10:24:59
Acknowledged.
|
| + int16_t win_slope_Q14 = ola_win_slope_Q14_; |
| + int16_t win_up_Q14 = win_slope_Q14; |
|
hlundin-webrtc
2017/03/23 11:41:51
Move declaration of win_up_Q14 to after the if sta
squashingskak
2017/03/27 10:24:59
Acknowledged.
|
| + assert(channel_ix < output->Channels()); |
|
hlundin-webrtc
2017/03/23 11:41:50
RTC_DCHECK_LT(channel_ix, output->Channels());
squashingskak
2017/03/27 10:24:59
Acknowledged.
|
| + if(win_length > (int)output->Size()){ |
|
hlundin-webrtc
2017/03/23 11:41:51
Don't cast; both sides should be size_t. Also, whe
squashingskak
2017/03/27 10:24:59
Acknowledged.
|
| + win_length = length; |
| + win_slope_Q14 = (1 << 14)/length; |
|
hlundin-webrtc
2017/03/23 11:41:51
Add spaces on both sides of /
squashingskak
2017/03/27 10:24:59
Acknowledged.
|
| + win_up_Q14 = win_slope_Q14; |
| + } |
| + for (int i = 0; i < win_length; i++) { |
|
hlundin-webrtc
2017/03/23 11:41:51
size_t i
squashingskak
2017/03/27 10:24:59
Acknowledged.
|
| (*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; |
| + win_up_Q14 += win_slope_Q14; |
| } |
|
hlundin-webrtc
2017/03/23 11:41:51
After this for loop, we expect the value of win_up
squashingskak
2017/03/27 10:24:59
1 << 14 / 48 = 341. 341 * 48 = 16384 = 1<< 14 - 16
hlundin-webrtc
2017/03/27 10:44:27
OK. Please, add a DCHECK.
if (fs_hz_ == 48000) {
|
| } |
| } else if (last_mode == kModeRfc3389Cng) { |
| @@ -171,15 +168,18 @@ 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; |
| + int win_length = ola_win_length_; |
|
hlundin-webrtc
2017/03/23 11:41:50
All the above comments that apply here.
squashingskak
2017/03/27 10:24:59
Acknowledged.
|
| + int16_t win_slope_Q14 = ola_win_slope_Q14_; |
| + int16_t win_up_Q14 = win_slope_Q14; |
| + if(win_length > (int)kCngLength){ |
| + win_length = (int)kCngLength; |
| + win_slope_Q14 = (1 << 14)/kCngLength; |
| + win_up_Q14 = win_slope_Q14; |
| + } |
| + for (int i = 0; i < win_length; i++) { |
| + (*output)[0][i] = (win_up_Q14 * (*output)[0][i] + |
| + ((1 << 14) - win_up_Q14) * cng_output[i] + (1 << 13)) >> 14; |
| + win_up_Q14 += win_slope_Q14; |
| } |
| } else if (external_mute_factor_array[0] < 16384) { |
| // Previous was neither of Expand, FadeToBGN or RFC3389_CNG, but we are |