audio_processing/ns: Replaced WEBRTC_SPL_MUL_16_16 macro with *

The macro is in C defined as
#define WEBRTC_SPL_MUL_16_16(a, b) ((int32_t) (((int16_t)(a)) * ((int16_t)(b))))
(For definition on ARMv7 and MIPS, see common_audio/signal_processing/include/spl_inl_armv7.h and common_audio/signal_processing/include/spl_inl_mips.h)

The replacement consists of
- avoiding casts to int16_t if inputs already are int16_t
- adding explicit cast to <type> if result is assigned to <type> (other than int or int32_t)

BUG=3348, 3353
TESTED=locally on Mac and trybots
R=kwiberg@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/35619004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@8024 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
bjornv@webrtc.org 2015-01-08 17:34:33 +00:00
parent 5e5b32706a
commit dec649cbab
4 changed files with 25 additions and 29 deletions

View File

@ -316,8 +316,7 @@ static void UpdateNoiseEstimate(NoiseSuppressionFixedC* inst, int offset) {
for (i = 0; i < inst->magnLen; i++) {
// inst->quantile[i]=exp(inst->lquantile[offset+i]);
// in Q21
tmp32no2 = WEBRTC_SPL_MUL_16_16(kExp2Const,
inst->noiseEstLogQuantile[offset + i]);
tmp32no2 = kExp2Const * inst->noiseEstLogQuantile[offset + i];
tmp32no1 = (0x00200000 | (tmp32no2 & 0x001FFFFF)); // 2^21 + frac
tmp16 = (int16_t)(tmp32no2 >> 21);
tmp16 -= 21;// shift 21 to get result in Q0
@ -383,7 +382,7 @@ static void NoiseEstimationC(NoiseSuppressionFixedC* inst,
counter = inst->noiseEstCounter[s];
assert(counter < 201);
countDiv = WebRtcNsx_kCounterDiv[counter];
countProd = (int16_t)WEBRTC_SPL_MUL_16_16(counter, countDiv);
countProd = (int16_t)(counter * countDiv);
// quant_est(...)
for (i = 0; i < inst->magnLen; i++) {
@ -599,8 +598,7 @@ void WebRtcNsx_CalcParametricNoiseEstimate(NoiseSuppressionFixedC* inst,
// noise_estimate = 2^(pinkNoiseNumerator + pinkNoiseExp * log2(j))
assert(freq_index >= 0);
assert(freq_index < 129);
tmp32no2 = WEBRTC_SPL_MUL_16_16(pink_noise_exp_avg, kLogIndex[freq_index]); // Q26
tmp32no2 >>= 15; // Q11
tmp32no2 = (pink_noise_exp_avg * kLogIndex[freq_index]) >> 15; // Q11
tmp32no1 = pink_noise_num_avg - tmp32no2; // Q11
// Calculate output: 2^tmp32no1
@ -614,7 +612,7 @@ void WebRtcNsx_CalcParametricNoiseEstimate(NoiseSuppressionFixedC* inst,
// 'b' is given in Q11 and below stored in frac_part.
if (frac_part >> 10) {
// Upper fractional part
tmp32no2 = WEBRTC_SPL_MUL_16_16(2048 - frac_part, 1244); // Q21
tmp32no2 = (2048 - frac_part) * 1244; // Q21
tmp32no2 = 2048 - (tmp32no2 >> 10);
} else {
// Lower fractional part
@ -878,7 +876,7 @@ void WebRtcNsx_FeatureParameterExtraction(NoiseSuppressionFixedC* inst,
numHistLrt = 0;
for (i = 0; i < BIN_SIZE_LRT; i++) {
j = (2 * i + 1);
tmp32 = WEBRTC_SPL_MUL_16_16(inst->histLrt[i], j);
tmp32 = inst->histLrt[i] * j;
avgHistLrtFX += tmp32;
numHistLrt += inst->histLrt[i];
avgSquareHistLrtFX += tmp32 * j;
@ -886,7 +884,7 @@ void WebRtcNsx_FeatureParameterExtraction(NoiseSuppressionFixedC* inst,
avgHistLrtComplFX = avgHistLrtFX;
for (; i < HIST_PAR_EST; i++) {
j = (2 * i + 1);
tmp32 = WEBRTC_SPL_MUL_16_16(inst->histLrt[i], j);
tmp32 = inst->histLrt[i] * j;
avgHistLrtComplFX += tmp32;
avgSquareHistLrtFX += tmp32 * j;
}
@ -1130,7 +1128,7 @@ void WebRtcNsx_ComputeSpectralDifference(NoiseSuppressionFixedC* inst,
// Compute var and cov of magn and magn_pause
tmp16no1 = (int16_t)((int32_t)magnIn[i] - avgMagnFX);
tmp32no2 = inst->avgMagnPause[i] - avgPauseFX;
varMagnUFX += (uint32_t)WEBRTC_SPL_MUL_16_16(tmp16no1, tmp16no1); // Q(2*qMagn)
varMagnUFX += (uint32_t)(tmp16no1 * tmp16no1); // Q(2*qMagn)
tmp32no1 = tmp32no2 * tmp16no1; // Q(prevQMagn+qMagn)
covMagnPauseFX += tmp32no1; // Q(prevQMagn+qMagn)
tmp32no1 = tmp32no2 >> nShifts; // Q(prevQMagn-minPause).
@ -1251,9 +1249,9 @@ void WebRtcNsx_DataAnalysis(NoiseSuppressionFixedC* inst,
inst->real[0] = winData[0]; // Q(normData-stages)
inst->real[inst->anaLen2] = winData[inst->anaLen];
// Q(2*(normData-stages))
inst->magnEnergy = (uint32_t)WEBRTC_SPL_MUL_16_16(inst->real[0], inst->real[0]);
inst->magnEnergy += (uint32_t)WEBRTC_SPL_MUL_16_16(inst->real[inst->anaLen2],
inst->real[inst->anaLen2]);
inst->magnEnergy = (uint32_t)(inst->real[0] * inst->real[0]);
inst->magnEnergy += (uint32_t)(inst->real[inst->anaLen2] *
inst->real[inst->anaLen2]);
magnU16[0] = (uint16_t)WEBRTC_SPL_ABS_W16(inst->real[0]); // Q(normData-stages)
magnU16[inst->anaLen2] = (uint16_t)WEBRTC_SPL_ABS_W16(inst->real[inst->anaLen2]);
inst->sumMagn = (uint32_t)magnU16[0]; // Q(normData-stages)
@ -1265,8 +1263,8 @@ void WebRtcNsx_DataAnalysis(NoiseSuppressionFixedC* inst,
inst->imag[i] = -winData[j + 1];
// magnitude spectrum
// energy in Q(2*(normData-stages))
tmpU32no1 = (uint32_t)WEBRTC_SPL_MUL_16_16(winData[j], winData[j]);
tmpU32no1 += (uint32_t)WEBRTC_SPL_MUL_16_16(winData[j + 1], winData[j + 1]);
tmpU32no1 = (uint32_t)(winData[j] * winData[j]);
tmpU32no1 += (uint32_t)(winData[j + 1] * winData[j + 1]);
inst->magnEnergy += tmpU32no1; // Q(2*(normData-stages))
magnU16[i] = (uint16_t)WebRtcSpl_SqrtFloor(tmpU32no1); // Q(normData-stages)
@ -1299,15 +1297,15 @@ void WebRtcNsx_DataAnalysis(NoiseSuppressionFixedC* inst,
sum_log_magn = (int32_t)log2; // Q8
// sum_log_i_log_magn in Q17
sum_log_i_log_magn = (WEBRTC_SPL_MUL_16_16(kLogIndex[inst->anaLen2], log2) >> 3);
sum_log_i_log_magn = (kLogIndex[inst->anaLen2] * log2) >> 3;
for (i = 1, j = 2; i < inst->anaLen2; i += 1, j += 2) {
inst->real[i] = winData[j];
inst->imag[i] = -winData[j + 1];
// magnitude spectrum
// energy in Q(2*(normData-stages))
tmpU32no1 = (uint32_t)WEBRTC_SPL_MUL_16_16(winData[j], winData[j]);
tmpU32no1 += (uint32_t)WEBRTC_SPL_MUL_16_16(winData[j + 1], winData[j + 1]);
tmpU32no1 = (uint32_t)(winData[j] * winData[j]);
tmpU32no1 += (uint32_t)(winData[j + 1] * winData[j + 1]);
inst->magnEnergy += tmpU32no1; // Q(2*(normData-stages))
magnU16[i] = (uint16_t)WebRtcSpl_SqrtFloor(tmpU32no1); // Q(normData-stages)
@ -1333,7 +1331,7 @@ void WebRtcNsx_DataAnalysis(NoiseSuppressionFixedC* inst,
}
sum_log_magn += (int32_t)log2; // Q8
// sum_log_i_log_magn in Q17
sum_log_i_log_magn += (WEBRTC_SPL_MUL_16_16(kLogIndex[i], log2) >> 3);
sum_log_i_log_magn += (kLogIndex[i] * log2) >> 3;
}
}

View File

@ -107,7 +107,7 @@ void WebRtcNsx_SpeechNoiseProb(NoiseSuppressionFixedC* inst,
tmpIndFX = 8192 + tmp16no2; // Q14
}
}
indPriorFX = WEBRTC_SPL_MUL_16_16(inst->weightLogLrt, tmpIndFX); // 6*Q14
indPriorFX = inst->weightLogLrt * tmpIndFX; // 6*Q14
//spectral flatness feature
if (inst->weightSpecFlat) {
@ -139,7 +139,7 @@ void WebRtcNsx_SpeechNoiseProb(NoiseSuppressionFixedC* inst,
tmpIndFX = 8192 - tmp16no2; // Q14
}
}
indPriorFX += WEBRTC_SPL_MUL_16_16(inst->weightSpecFlat, tmpIndFX); // 6*Q14
indPriorFX += inst->weightSpecFlat * tmpIndFX; // 6*Q14
}
//for template spectral-difference
@ -187,7 +187,7 @@ void WebRtcNsx_SpeechNoiseProb(NoiseSuppressionFixedC* inst,
tmpIndFX = 8192 - tmp16no2;
}
}
indPriorFX += WEBRTC_SPL_MUL_16_16(inst->weightSpecDiff, tmpIndFX); // 6*Q14
indPriorFX += inst->weightSpecDiff * tmpIndFX; // 6*Q14
}
//combine the indicator function with the feature weights

View File

@ -141,7 +141,7 @@ void WebRtcNsx_SpeechNoiseProb(NoiseSuppressionFixedC* inst,
tmpIndFX = 8192 + tmp16no2; // Q14
}
}
indPriorFX = WEBRTC_SPL_MUL_16_16(inst->weightLogLrt, tmpIndFX); // 6*Q14
indPriorFX = inst->weightLogLrt * tmpIndFX; // 6*Q14
//spectral flatness feature
if (inst->weightSpecFlat) {
@ -173,7 +173,7 @@ void WebRtcNsx_SpeechNoiseProb(NoiseSuppressionFixedC* inst,
tmpIndFX = 8192 - tmp16no2; // Q14
}
}
indPriorFX += WEBRTC_SPL_MUL_16_16(inst->weightSpecFlat, tmpIndFX); // 6*Q14
indPriorFX += inst->weightSpecFlat * tmpIndFX; // 6*Q14
}
//for template spectral-difference
@ -221,7 +221,7 @@ void WebRtcNsx_SpeechNoiseProb(NoiseSuppressionFixedC* inst,
tmpIndFX = 8192 - tmp16no2;
}
}
indPriorFX += WEBRTC_SPL_MUL_16_16(inst->weightSpecDiff, tmpIndFX); // 6*Q14
indPriorFX += inst->weightSpecDiff * tmpIndFX; // 6*Q14
}
//combine the indicator function with the feature weights

View File

@ -80,8 +80,7 @@ static void UpdateNoiseEstimateNeon(NoiseSuppressionFixedC* inst, int offset) {
ptr_noiseEstQuantile < &inst->noiseEstQuantile[inst->magnLen - 3];
ptr_noiseEstQuantile += 4, ptr_noiseEstLogQuantile += 4) {
// tmp32no2 = WEBRTC_SPL_MUL_16_16(kExp2Const,
// inst->noiseEstLogQuantile[offset + i]);
// tmp32no2 = kExp2Const * inst->noiseEstLogQuantile[offset + i];
int16x4_t v16x4 = vld1_s16(ptr_noiseEstLogQuantile);
int32x4_t v32x4B = vmull_s16(v16x4, kExp2Const16x4);
@ -117,8 +116,7 @@ static void UpdateNoiseEstimateNeon(NoiseSuppressionFixedC* inst, int offset) {
// inst->quantile[i]=exp(inst->lquantile[offset+i]);
// in Q21
int32_t tmp32no2 = WEBRTC_SPL_MUL_16_16(kExp2Const,
*ptr_noiseEstLogQuantile);
int32_t tmp32no2 = kExp2Const * *ptr_noiseEstLogQuantile;
int32_t tmp32no1 = (0x00200000 | (tmp32no2 & 0x001FFFFF)); // 2^21 + frac
tmp16 = (int16_t)(tmp32no2 >> 21);
@ -194,7 +192,7 @@ void WebRtcNsx_NoiseEstimationNeon(NoiseSuppressionFixedC* inst,
counter = inst->noiseEstCounter[s];
assert(counter < 201);
countDiv = WebRtcNsx_kCounterDiv[counter];
countProd = (int16_t)WEBRTC_SPL_MUL_16_16(counter, countDiv);
countProd = (int16_t)(counter * countDiv);
// quant_est(...)
int16_t deltaBuff[8];