diff --git a/webrtc/modules/audio_coding/neteq/audio_decoder_impl.cc b/webrtc/modules/audio_coding/neteq/audio_decoder_impl.cc index c3f1dbbc8c..99ff95a2ec 100644 --- a/webrtc/modules/audio_coding/neteq/audio_decoder_impl.cc +++ b/webrtc/modules/audio_coding/neteq/audio_decoder_impl.cc @@ -163,9 +163,9 @@ int AudioDecoderIlbc::DecodeInternal(const uint8_t* encoded, SpeechType* speech_type) { DCHECK_EQ(sample_rate_hz, 8000); int16_t temp_type = 1; // Default is speech. - int16_t ret = WebRtcIlbcfix_Decode(dec_state_, encoded, - static_cast(encoded_len), decoded, - &temp_type); + int ret = WebRtcIlbcfix_Decode(dec_state_, encoded, + static_cast(encoded_len), decoded, + &temp_type); *speech_type = ConvertSpeechType(temp_type); return ret; } @@ -330,11 +330,11 @@ int AudioDecoderOpus::DecodeInternal(const uint8_t* encoded, SpeechType* speech_type) { DCHECK_EQ(sample_rate_hz, 48000); int16_t temp_type = 1; // Default is speech. - int16_t ret = WebRtcOpus_Decode(dec_state_, encoded, - static_cast(encoded_len), decoded, - &temp_type); + int ret = WebRtcOpus_Decode(dec_state_, encoded, + static_cast(encoded_len), decoded, + &temp_type); if (ret > 0) - ret *= static_cast(channels_); // Return total number of samples. + ret *= static_cast(channels_); // Return total number of samples. *speech_type = ConvertSpeechType(temp_type); return ret; } @@ -352,11 +352,11 @@ int AudioDecoderOpus::DecodeRedundantInternal(const uint8_t* encoded, DCHECK_EQ(sample_rate_hz, 48000); int16_t temp_type = 1; // Default is speech. - int16_t ret = WebRtcOpus_DecodeFec(dec_state_, encoded, - static_cast(encoded_len), decoded, - &temp_type); + int ret = WebRtcOpus_DecodeFec(dec_state_, encoded, + static_cast(encoded_len), decoded, + &temp_type); if (ret > 0) - ret *= static_cast(channels_); // Return total number of samples. + ret *= static_cast(channels_); // Return total number of samples. *speech_type = ConvertSpeechType(temp_type); return ret; } diff --git a/webrtc/modules/audio_coding/neteq/dsp_helper.cc b/webrtc/modules/audio_coding/neteq/dsp_helper.cc index 7451ae26f8..289e66d17c 100644 --- a/webrtc/modules/audio_coding/neteq/dsp_helper.cc +++ b/webrtc/modules/audio_coding/neteq/dsp_helper.cc @@ -272,7 +272,7 @@ void DspHelper::CrossFade(const int16_t* input1, const int16_t* input2, } void DspHelper::UnmuteSignal(const int16_t* input, size_t length, - int16_t* factor, int16_t increment, + int16_t* factor, int increment, int16_t* output) { uint16_t factor_16b = *factor; int32_t factor_32b = (static_cast(factor_16b) << 6) + 32; @@ -284,7 +284,7 @@ void DspHelper::UnmuteSignal(const int16_t* input, size_t length, *factor = factor_16b; } -void DspHelper::MuteSignal(int16_t* signal, int16_t mute_slope, size_t length) { +void DspHelper::MuteSignal(int16_t* signal, int mute_slope, size_t length) { int32_t factor = (16384 << 6) + 32; for (size_t i = 0; i < length; i++) { signal[i] = ((factor >> 6) * signal[i] + 8192) >> 14; diff --git a/webrtc/modules/audio_coding/neteq/dsp_helper.h b/webrtc/modules/audio_coding/neteq/dsp_helper.h index af4f4d6c88..f9032562f1 100644 --- a/webrtc/modules/audio_coding/neteq/dsp_helper.h +++ b/webrtc/modules/audio_coding/neteq/dsp_helper.h @@ -110,11 +110,11 @@ class DspHelper { // sample and increases the gain by |increment| (Q20) for each sample. The // result is written to |output|. |length| samples are processed. static void UnmuteSignal(const int16_t* input, size_t length, int16_t* factor, - int16_t increment, int16_t* output); + int increment, int16_t* output); // Starts at unity gain and gradually fades out |signal|. For each sample, // the gain is reduced by |mute_slope| (Q14). |length| samples are processed. - static void MuteSignal(int16_t* signal, int16_t mute_slope, size_t length); + static void MuteSignal(int16_t* signal, int mute_slope, size_t length); // Downsamples |input| from |sample_rate_hz| to 4 kHz sample rate. The input // has |input_length| samples, and the method will write |output_length| diff --git a/webrtc/modules/audio_coding/neteq/expand.cc b/webrtc/modules/audio_coding/neteq/expand.cc index bde655917f..10f6a9f5bf 100644 --- a/webrtc/modules/audio_coding/neteq/expand.cc +++ b/webrtc/modules/audio_coding/neteq/expand.cc @@ -239,14 +239,12 @@ int Expand::Process(AudioMultiVector* output) { if (consecutive_expands_ == 3) { // Let the mute factor decrease from 1.0 to 0.95 in 6.25 ms. // mute_slope = 0.0010 / fs_mult in Q20. - parameters.mute_slope = std::max(parameters.mute_slope, - static_cast(1049 / fs_mult)); + parameters.mute_slope = std::max(parameters.mute_slope, 1049 / fs_mult); } if (consecutive_expands_ == 7) { // Let the mute factor decrease from 1.0 to 0.90 in 6.25 ms. // mute_slope = 0.0020 / fs_mult in Q20. - parameters.mute_slope = std::max(parameters.mute_slope, - static_cast(2097 / fs_mult)); + parameters.mute_slope = std::max(parameters.mute_slope, 2097 / fs_mult); } // Mute segment according to slope value. @@ -368,7 +366,7 @@ void Expand::AnalyzeSignal(int16_t* random_vector) { InitializeForAnExpandPeriod(); // Calculate correlation in downsampled domain (4 kHz sample rate). - int16_t correlation_scale; + int correlation_scale; int correlation_length = 51; // TODO(hlundin): Legacy bit-exactness. // If it is decided to break bit-exactness |correlation_length| should be // initialized to the return value of Correlation(). @@ -445,7 +443,7 @@ void Expand::AnalyzeSignal(int16_t* random_vector) { correlation_length + start_index + correlation_lags - 1); correlation_scale = ((31 - WebRtcSpl_NormW32(signal_max * signal_max)) + (31 - WebRtcSpl_NormW32(correlation_length))) - 31; - correlation_scale = std::max(static_cast(0), correlation_scale); + correlation_scale = std::max(0, correlation_scale); // Calculate the correlation, store in |correlation_vector2|. WebRtcSpl_CrossCorrelation( @@ -472,7 +470,7 @@ void Expand::AnalyzeSignal(int16_t* random_vector) { // Calculate the correlation coefficient between the two portions of the // signal. - int16_t corr_coefficient; + int32_t corr_coefficient; if ((energy1 > 0) && (energy2 > 0)) { int energy1_scale = std::max(16 - WebRtcSpl_NormW32(energy1), 0); int energy2_scale = std::max(16 - WebRtcSpl_NormW32(energy2), 0); @@ -481,17 +479,17 @@ void Expand::AnalyzeSignal(int16_t* random_vector) { // If sum is odd, add 1 to make it even. energy1_scale += 1; } - int16_t scaled_energy1 = energy1 >> energy1_scale; - int16_t scaled_energy2 = energy2 >> energy2_scale; - int16_t sqrt_energy_product = WebRtcSpl_SqrtFloor( - scaled_energy1 * scaled_energy2); + int32_t scaled_energy1 = energy1 >> energy1_scale; + int32_t scaled_energy2 = energy2 >> energy2_scale; + int16_t sqrt_energy_product = static_cast( + WebRtcSpl_SqrtFloor(scaled_energy1 * scaled_energy2)); // Calculate max_correlation / sqrt(energy1 * energy2) in Q14. int cc_shift = 14 - (energy1_scale + energy2_scale) / 2; max_correlation = WEBRTC_SPL_SHIFT_W32(max_correlation, cc_shift); corr_coefficient = WebRtcSpl_DivW32W16(max_correlation, sqrt_energy_product); - corr_coefficient = std::min(static_cast(16384), - corr_coefficient); // Cap at 1.0 in Q14. + // Cap at 1.0 in Q14. + corr_coefficient = std::min(16384, corr_coefficient); } else { corr_coefficient = 0; } @@ -512,8 +510,8 @@ void Expand::AnalyzeSignal(int16_t* random_vector) { if ((energy1 / 4 < energy2) && (energy1 > energy2 / 4)) { // Energy constraint fulfilled. Use both vectors and scale them // accordingly. - int16_t scaled_energy2 = std::max(16 - WebRtcSpl_NormW32(energy2), 0); - int16_t scaled_energy1 = scaled_energy2 - 13; + int32_t scaled_energy2 = std::max(16 - WebRtcSpl_NormW32(energy2), 0); + int32_t scaled_energy1 = scaled_energy2 - 13; // Calculate scaled_energy1 / scaled_energy2 in Q13. int32_t energy_ratio = WebRtcSpl_DivW32W16( WEBRTC_SPL_SHIFT_W32(energy1, -scaled_energy1), @@ -682,7 +680,8 @@ void Expand::AnalyzeSignal(int16_t* random_vector) { // voice_mix_factor = 0; if (corr_coefficient > 7875) { int16_t x1, x2, x3; - x1 = corr_coefficient; // |corr_coefficient| is in Q14. + // |corr_coefficient| is in Q14. + x1 = static_cast(corr_coefficient); x2 = (x1 * x1) >> 14; // Shift 14 to keep result in Q14. x3 = (x1 * x2) >> 14; static const int kCoefficients[4] = { -5179, 19931, -16422, 5776 }; @@ -709,7 +708,7 @@ void Expand::AnalyzeSignal(int16_t* random_vector) { // the division. // Shift the denominator from Q13 to Q5 before the division. The result of // the division will then be in Q20. - int16_t temp_ratio = WebRtcSpl_DivW32W16( + int temp_ratio = WebRtcSpl_DivW32W16( (slope - 8192) << 12, static_cast((distortion_lag * slope) >> 8)); if (slope > 14746) { @@ -730,8 +729,7 @@ void Expand::AnalyzeSignal(int16_t* random_vector) { // Make sure the mute factor decreases from 1.0 to 0.9 in no more than // 6.25 ms. // mute_slope >= 0.005 / fs_mult in Q20. - parameters.mute_slope = std::max(static_cast(5243 / fs_mult), - parameters.mute_slope); + parameters.mute_slope = std::max(5243 / fs_mult, parameters.mute_slope); } else if (slope > 8028) { parameters.mute_slope = 0; } @@ -755,7 +753,7 @@ Expand::ChannelParameters::ChannelParameters() void Expand::Correlation(const int16_t* input, size_t input_length, int16_t* output, - int16_t* output_scale) const { + int* output_scale) const { // Set parameters depending on sample rate. const int16_t* filter_coefficients; int16_t num_coefficients; @@ -844,7 +842,7 @@ Expand* ExpandFactory::Create(BackgroundNoise* background_noise, // TODO(turajs): This can be moved to BackgroundNoise class. void Expand::GenerateBackgroundNoise(int16_t* random_vector, size_t channel, - int16_t mute_slope, + int mute_slope, bool too_many_expands, size_t num_noise_samples, int16_t* buffer) { @@ -887,7 +885,7 @@ void Expand::GenerateBackgroundNoise(int16_t* random_vector, bgn_mute_factor > 0) { // Fade BGN to zero. // Calculate muting slope, approximately -2^18 / fs_hz. - int16_t mute_slope; + int mute_slope; if (fs_hz_ == 8000) { mute_slope = -32; } else if (fs_hz_ == 16000) { diff --git a/webrtc/modules/audio_coding/neteq/expand.h b/webrtc/modules/audio_coding/neteq/expand.h index b015959e75..5fb117d519 100644 --- a/webrtc/modules/audio_coding/neteq/expand.h +++ b/webrtc/modules/audio_coding/neteq/expand.h @@ -72,7 +72,7 @@ class Expand { void GenerateBackgroundNoise(int16_t* random_vector, size_t channel, - int16_t mute_slope, + int mute_slope, bool too_many_expands, size_t num_noise_samples, int16_t* buffer); @@ -113,7 +113,7 @@ class Expand { AudioVector expand_vector0; AudioVector expand_vector1; bool onset; - int16_t mute_slope; /* Q20 */ + int mute_slope; /* Q20 */ }; // Calculate the auto-correlation of |input|, with length |input_length| @@ -123,7 +123,7 @@ class Expand { void Correlation(const int16_t* input, size_t input_length, int16_t* output, - int16_t* output_scale) const; + int* output_scale) const; void UpdateLagIndex(); diff --git a/webrtc/modules/audio_coding/neteq/merge.cc b/webrtc/modules/audio_coding/neteq/merge.cc index 8e686ba49b..2c515c14eb 100644 --- a/webrtc/modules/audio_coding/neteq/merge.cc +++ b/webrtc/modules/audio_coding/neteq/merge.cc @@ -314,7 +314,7 @@ int16_t Merge::CorrelateAndPeakSearch(int16_t expanded_max, int16_t input_max, const int max_corr_length = kMaxCorrelationLength; int stop_position_downsamp = std::min(max_corr_length, expand_->max_lag() / (fs_mult_ * 2) + 1); - int16_t correlation_shift = 0; + int correlation_shift = 0; if (expanded_max * input_max > 26843546) { correlation_shift = 3; } @@ -333,7 +333,7 @@ int16_t Merge::CorrelateAndPeakSearch(int16_t expanded_max, int16_t input_max, int16_t* correlation_ptr = &correlation16[pad_length]; int32_t max_correlation = WebRtcSpl_MaxAbsValueW32(correlation, stop_position_downsamp); - int16_t norm_shift = std::max(0, 17 - WebRtcSpl_NormW32(max_correlation)); + int norm_shift = std::max(0, 17 - WebRtcSpl_NormW32(max_correlation)); WebRtcSpl_VectorBitShiftW32ToW16(correlation_ptr, stop_position_downsamp, correlation, norm_shift); diff --git a/webrtc/modules/audio_coding/neteq/neteq_impl.cc b/webrtc/modules/audio_coding/neteq/neteq_impl.cc index 29b8d1a0b3..6598a790c5 100644 --- a/webrtc/modules/audio_coding/neteq/neteq_impl.cc +++ b/webrtc/modules/audio_coding/neteq/neteq_impl.cc @@ -1278,7 +1278,7 @@ int NetEqImpl::DecodeLoop(PacketList* packet_list, Operations* operation, *operation == kPreemptiveExpand); packet_list->pop_front(); size_t payload_length = packet->payload_length; - int16_t decode_length; + int decode_length; if (packet->sync_packet) { // Decode to silence with the same frame size as the last decode. LOG(LS_VERBOSE) << "Decoding sync-packet: " << diff --git a/webrtc/modules/audio_coding/neteq/normal.cc b/webrtc/modules/audio_coding/neteq/normal.cc index a0e5d2d6d4..bf455c974c 100644 --- a/webrtc/modules/audio_coding/neteq/normal.cc +++ b/webrtc/modules/audio_coding/neteq/normal.cc @@ -111,7 +111,7 @@ int Normal::Process(const int16_t* input, } // If muted increase by 0.64 for every 20 ms (NB/WB 0.0040/0.0020 in Q14). - int16_t increment = 64 / fs_mult; + int increment = static_cast(64 / fs_mult); for (size_t i = 0; i < length_per_channel; i++) { // Scale with mute factor. assert(channel_ix < output->Channels()); @@ -178,7 +178,7 @@ int Normal::Process(const int16_t* input, // Previous was neither of Expand, FadeToBGN or RFC3389_CNG, but we are // still ramping up from previous muting. // If muted increase by 0.64 for every 20 ms (NB/WB 0.0040/0.0020 in Q14). - int16_t increment = 64 / fs_mult; + int increment = static_cast(64 / fs_mult); size_t length_per_channel = length / output->Channels(); for (size_t i = 0; i < length_per_channel; i++) { for (size_t channel_ix = 0; channel_ix < output->Channels(); diff --git a/webrtc/modules/audio_coding/neteq/test/RTPencode.cc b/webrtc/modules/audio_coding/neteq/test/RTPencode.cc index f25a279f9c..1aacb401b7 100644 --- a/webrtc/modules/audio_coding/neteq/test/RTPencode.cc +++ b/webrtc/modules/audio_coding/neteq/test/RTPencode.cc @@ -1561,7 +1561,7 @@ int NetEQTest_encode(int coder, int useVAD, int bitrate, int numChannels) { - short cdlen = 0; + int cdlen = 0; int16_t* tempdata; static int first_cng = 1; int16_t tempLen;