audio_coding/codecs/isac/fix: Replaced macro WEBRTC_SPL_RSHIFT_W32 with >>"

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

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

git-svn-id: http://webrtc.googlecode.com/svn/trunk@7544 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
bjornv@webrtc.org 2014-10-28 13:05:43 +00:00
parent 67ca26e087
commit a296725d0e
19 changed files with 237 additions and 258 deletions

View File

@ -72,11 +72,10 @@ int16_t WebRtcIsacfix_EncTerminate(Bitstr_enc *streamData)
}
/* write remaining data to bitstream, if "full == 0" first byte has data */
if (streamData->full == 0) {
*streamPtr++ += (uint16_t) WEBRTC_SPL_RSHIFT_W32(streamData->streamval, 24);
*streamPtr++ += (uint16_t)(streamData->streamval >> 24);
streamData->full = 1;
} else {
*streamPtr = (uint16_t) WEBRTC_SPL_LSHIFT_W32(
WEBRTC_SPL_RSHIFT_W32(streamData->streamval, 24), 8);
*streamPtr = (uint16_t)((streamData->streamval >> 24) << 8);
streamData->full = 0;
}
}
@ -111,11 +110,10 @@ int16_t WebRtcIsacfix_EncTerminate(Bitstr_enc *streamData)
}
/* write remaining data (2 bytes) to bitstream */
if (streamData->full) {
*streamPtr++ = (uint16_t) WEBRTC_SPL_RSHIFT_W32(streamData->streamval, 16);
*streamPtr++ = (uint16_t)(streamData->streamval >> 16);
} else {
*streamPtr++ |= (uint16_t) WEBRTC_SPL_RSHIFT_W32(streamData->streamval, 24);
*streamPtr = (uint16_t) WEBRTC_SPL_RSHIFT_W32(streamData->streamval, 8)
& 0xFF00;
*streamPtr++ |= (uint16_t)(streamData->streamval >> 24);
*streamPtr = (uint16_t)(streamData->streamval >> 8) & 0xFF00;
}
}

View File

@ -65,7 +65,7 @@ int WebRtcIsacfix_EncHistMulti(Bitstr_enc *streamData,
/* update interval */
W_upper_LSB = W_upper & 0x0000FFFF;
W_upper_MSB = WEBRTC_SPL_RSHIFT_W32(W_upper, 16);
W_upper_MSB = W_upper >> 16;
W_lower = WEBRTC_SPL_UMUL(W_upper_MSB, cdfLo);
W_lower += ((W_upper_LSB * cdfLo) >> 16);
W_upper = WEBRTC_SPL_UMUL(W_upper_MSB, cdfHi);
@ -103,11 +103,10 @@ int WebRtcIsacfix_EncHistMulti(Bitstr_enc *streamData,
{
W_upper = WEBRTC_SPL_LSHIFT_W32(W_upper, 8);
if (streamData->full == 0) {
*streamPtr++ += (uint16_t) WEBRTC_SPL_RSHIFT_W32(streamData->streamval, 24);
*streamPtr++ += (uint16_t)(streamData->streamval >> 24);
streamData->full = 1;
} else {
*streamPtr = (uint16_t) WEBRTC_SPL_LSHIFT_W32(
WEBRTC_SPL_RSHIFT_W32(streamData->streamval, 24), 8);
*streamPtr = (uint16_t)((streamData->streamval >> 24) << 8);
streamData->full = 0;
}
@ -185,7 +184,7 @@ int16_t WebRtcIsacfix_DecHistBisectMulti(int16_t *data,
{
/* find the integer *data for which streamval lies in [W_lower+1, W_upper] */
W_upper_LSB = W_upper & 0x0000FFFF;
W_upper_MSB = WEBRTC_SPL_RSHIFT_W32(W_upper, 16);
W_upper_MSB = W_upper >> 16;
/* start halfway the cdf range */
sizeTmp = *cdfSize++ / 2;

View File

@ -71,7 +71,7 @@ static __inline uint16_t WebRtcIsacfix_Piecewise(int32_t xinQ15) {
/* Find index for x-value */
qtmp1 = WEBRTC_SPL_SAT(kHistEdges[50],xinQ15,kHistEdges[0]);
ind = WEBRTC_SPL_MUL(5, qtmp1 - kHistEdges[0]);
ind = WEBRTC_SPL_RSHIFT_W32(ind, 16);
ind >>= 16;
/* Calculate corresponding y-value ans return*/
qtmp1 = qtmp1 - kHistEdges[ind];

View File

@ -200,8 +200,8 @@ int32_t WebRtcIsacfix_UpdateUplinkBwImpl(BwEstimatorstr *bweStr,
}
/* kBitsByteSec is in Q15 */
recRtpRate = (int16_t)WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(kBitsByteSec,
(int32_t)pksize), 15) + bweStr->recHeaderRate;
recRtpRate = (int16_t)((kBitsByteSec * pksize) >> 15) +
bweStr->recHeaderRate;
} else {
/* If frameSize changed since last call, from 60 to 30, recalculate some values */
@ -215,8 +215,8 @@ int32_t WebRtcIsacfix_UpdateUplinkBwImpl(BwEstimatorstr *bweStr,
}
/* kBitsByteSec is in Q14 */
recRtpRate = (uint16_t)WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(kBitsByteSec,
(int32_t)pksize), 14) + bweStr->recHeaderRate;
recRtpRate = (uint16_t)((kBitsByteSec * pksize) >> 14) +
bweStr->recHeaderRate;
}
@ -293,7 +293,7 @@ int32_t WebRtcIsacfix_UpdateUplinkBwImpl(BwEstimatorstr *bweStr,
if ( reductionFactor != 0 ) {
bweStr->recBwInv = WEBRTC_SPL_MUL((int32_t)bweStr->recBwInv, (int32_t)reductionFactor);
bweStr->recBwInv = WEBRTC_SPL_RSHIFT_W32((int32_t)bweStr->recBwInv, 13);
bweStr->recBwInv = (int32_t)bweStr->recBwInv >> 13;
} else {
static const uint32_t kInitRate = INIT_BN_EST + INIT_HDR_RATE;
@ -345,8 +345,8 @@ int32_t WebRtcIsacfix_UpdateUplinkBwImpl(BwEstimatorstr *bweStr,
}
}
if ((bweStr->prevRtpRate > WEBRTC_SPL_RSHIFT_W32((int32_t) bweStr->recBwAvg, 5)) &&
(recRtpRate > WEBRTC_SPL_RSHIFT_W32((int32_t)bweStr->recBwAvg, 5)) &&
if ((bweStr->prevRtpRate > (int32_t)bweStr->recBwAvg >> 5) &&
(recRtpRate > (int32_t)bweStr->recBwAvg >> 5) &&
!bweStr->inWaitPeriod) {
/* test if still in initiation period and increment counter */
@ -356,7 +356,7 @@ int32_t WebRtcIsacfix_UpdateUplinkBwImpl(BwEstimatorstr *bweStr,
} else {
/* weight decreases with number of updates, 1/countUpdates in Q13 */
weight = (uint16_t) WebRtcSpl_DivW32W16(
(int32_t)(8192 + WEBRTC_SPL_RSHIFT_W32((int32_t) bweStr->countUpdates, 1)),
8192 + (bweStr->countUpdates >> 1),
(int16_t)bweStr->countUpdates);
}
@ -374,8 +374,8 @@ int32_t WebRtcIsacfix_UpdateUplinkBwImpl(BwEstimatorstr *bweStr,
/* compute inverse receiving rate for last packet, in Q19 */
numBytesInv = (uint16_t) WebRtcSpl_DivW32W16(
(int32_t)(524288 + WEBRTC_SPL_RSHIFT_W32(((int32_t)pksize + HEADER_SIZE), 1)),
(int16_t)(pksize + HEADER_SIZE));
524288 + ((pksize + HEADER_SIZE) >> 1),
pksize + HEADER_SIZE);
/* 8389 is ~ 1/128000 in Q30 */
byteSecondsPerBit = WEBRTC_SPL_MUL_16_16(arrTimeDiff, 8389);
@ -445,12 +445,12 @@ int32_t WebRtcIsacfix_UpdateUplinkBwImpl(BwEstimatorstr *bweStr,
arrTimeNoiseAbs = arrTimeNoise;
/* long term averaged absolute jitter, Q15 */
weight = WEBRTC_SPL_RSHIFT_W32(weight, 3);
weight >>= 3;
bweStr->recJitter = WEBRTC_SPL_MUL(weight, WEBRTC_SPL_LSHIFT_W32(arrTimeNoiseAbs, 5))
+ WEBRTC_SPL_MUL(1024 - weight, bweStr->recJitter);
/* remove the fractional portion */
bweStr->recJitter = WEBRTC_SPL_RSHIFT_W32(bweStr->recJitter, 10);
bweStr->recJitter >>= 10;
/* Maximum jitter is 10 msec in Q15 */
if (bweStr->recJitter > (int32_t)327680) {
@ -461,7 +461,7 @@ int32_t WebRtcIsacfix_UpdateUplinkBwImpl(BwEstimatorstr *bweStr,
/* Calculation in Q13 products in Q23 */
bweStr->recJitterShortTermAbs = WEBRTC_SPL_MUL(51, WEBRTC_SPL_LSHIFT_W32(arrTimeNoiseAbs, 3)) +
WEBRTC_SPL_MUL(973, bweStr->recJitterShortTermAbs);
bweStr->recJitterShortTermAbs = WEBRTC_SPL_RSHIFT_W32(bweStr->recJitterShortTermAbs , 10);
bweStr->recJitterShortTermAbs >>= 10;
/* short term averaged jitter */
/* Calculation in Q13 products in Q23 */
@ -470,10 +470,10 @@ int32_t WebRtcIsacfix_UpdateUplinkBwImpl(BwEstimatorstr *bweStr,
if (bweStr->recJitterShortTerm < 0) {
temp = -bweStr->recJitterShortTerm;
temp = WEBRTC_SPL_RSHIFT_W32(temp, 12);
temp >>= 12;
bweStr->recJitterShortTerm = -temp;
} else {
bweStr->recJitterShortTerm = WEBRTC_SPL_RSHIFT_W32(bweStr->recJitterShortTerm, 12);
bweStr->recJitterShortTerm >>= 12;
}
}
}
@ -558,7 +558,7 @@ int16_t WebRtcIsacfix_UpdateUplinkBwRec(BwEstimatorstr *bweStr,
/* sendMaxDelayAvg = 0.9 * sendMaxDelayAvg + 0.1 * MAX_ISAC_MD */
bweStr->sendMaxDelayAvg = WEBRTC_SPL_MUL(461, bweStr->sendMaxDelayAvg) +
WEBRTC_SPL_MUL(51, WEBRTC_SPL_LSHIFT_W32((int32_t)MAX_ISAC_MD, 9));
bweStr->sendMaxDelayAvg = WEBRTC_SPL_RSHIFT_W32(bweStr->sendMaxDelayAvg, 9);
bweStr->sendMaxDelayAvg >>= 9;
} else {
RateInd = Index;
@ -566,7 +566,7 @@ int16_t WebRtcIsacfix_UpdateUplinkBwRec(BwEstimatorstr *bweStr,
/* sendMaxDelayAvg = 0.9 * sendMaxDelayAvg + 0.1 * MIN_ISAC_MD */
bweStr->sendMaxDelayAvg = WEBRTC_SPL_MUL(461, bweStr->sendMaxDelayAvg) +
WEBRTC_SPL_MUL(51, WEBRTC_SPL_LSHIFT_W32((int32_t)MIN_ISAC_MD,9));
bweStr->sendMaxDelayAvg = WEBRTC_SPL_RSHIFT_W32(bweStr->sendMaxDelayAvg, 9);
bweStr->sendMaxDelayAvg >>= 9;
}
@ -644,7 +644,7 @@ uint16_t WebRtcIsacfix_GetDownlinkBwIndexImpl(BwEstimatorstr *bweStr)
/* 0.9 times recBwAvgQ in Q16 */
/* 461/512 - 25/65536 =0.900009 */
tempTerm1 = WEBRTC_SPL_MUL(bweStr->recBwAvgQ, 25);
tempTerm1 = WEBRTC_SPL_RSHIFT_W32(tempTerm1, 7);
tempTerm1 >>= 7;
tempTermX = WEBRTC_SPL_UMUL(461, bweStr->recBwAvgQ) - tempTerm1;
/* rate in Q16 */
@ -667,7 +667,7 @@ uint16_t WebRtcIsacfix_GetDownlinkBwIndexImpl(BwEstimatorstr *bweStr)
tempTermX += KQRate01[rateInd];
/* Shift back to Q7 */
bweStr->recBwAvgQ = WEBRTC_SPL_RSHIFT_W32(tempTermX, 9);
bweStr->recBwAvgQ = tempTermX >> 9;
/* Count consecutive received bandwidth above 28000 kbps (28000 in Q7 = 3584000) */
/* If 66 high estimates in a row, set highSpeedRec to one */
@ -700,13 +700,13 @@ uint16_t WebRtcIsacfix_GetDownlinkBwIndexImpl(BwEstimatorstr *bweStr)
tempTerm1 = tempTermX + tempMin;
/* update quantized average, shift back to Q9 */
bweStr->recMaxDelayAvgQ = WEBRTC_SPL_RSHIFT_W32(tempTerm1, 9);
bweStr->recMaxDelayAvgQ = tempTerm1 >> 9;
} else {
maxDelayBit = 12;
tempTerm1 = tempTermX + tempMax;
/* update quantized average, shift back to Q9 */
bweStr->recMaxDelayAvgQ = WEBRTC_SPL_RSHIFT_W32(tempTerm1, 9);
bweStr->recMaxDelayAvgQ = tempTerm1 >> 9;
}
/* Return bandwitdh and jitter index (0..23) */
@ -727,39 +727,41 @@ uint16_t WebRtcIsacfix_GetDownlinkBandwidth(const BwEstimatorstr *bweStr)
rec_jitter_short_term_abs_inv = 0x80000000u / bweStr->recJitterShortTermAbs;
/* Q27 = 9 + 18 */
jitter_sign = WEBRTC_SPL_MUL(WEBRTC_SPL_RSHIFT_W32(bweStr->recJitterShortTerm, 4), (int32_t)rec_jitter_short_term_abs_inv);
jitter_sign = (bweStr->recJitterShortTerm >> 4) *
rec_jitter_short_term_abs_inv;
if (jitter_sign < 0) {
temp = -jitter_sign;
temp = WEBRTC_SPL_RSHIFT_W32(temp, 19);
temp >>= 19;
jitter_sign = -temp;
} else {
jitter_sign = WEBRTC_SPL_RSHIFT_W32(jitter_sign, 19);
jitter_sign >>= 19;
}
/* adjust bw proportionally to negative average jitter sign */
//bw_adjust = 1.0f - jitter_sign * (0.15f + 0.15f * jitter_sign * jitter_sign);
//Q8 -> Q16 .15 +.15 * jitter^2 first term is .15 in Q16 latter term is Q8*Q8*Q8
//38 in Q8 ~.15 9830 in Q16 ~.15
temp = 9830 + WEBRTC_SPL_RSHIFT_W32((WEBRTC_SPL_MUL(38, WEBRTC_SPL_MUL(jitter_sign, jitter_sign))), 8);
temp = 9830 + ((38 * jitter_sign * jitter_sign) >> 8);
if (jitter_sign < 0) {
temp = WEBRTC_SPL_MUL(jitter_sign, temp);
temp = -temp;
temp = WEBRTC_SPL_RSHIFT_W32(temp, 8);
temp >>= 8;
bw_adjust = (uint32_t)65536 + temp; /* (1 << 16) + temp; */
} else {
bw_adjust = (uint32_t)65536 - WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(jitter_sign, temp), 8);/* (1 << 16) - ((jitter_sign * temp) >> 8); */
/* (1 << 16) - ((jitter_sign * temp) >> 8); */
bw_adjust = 65536 - ((jitter_sign * temp) >> 8);
}
//make sure following multiplication won't overflow
//bw adjust now Q14
bw_adjust = WEBRTC_SPL_RSHIFT_W32(bw_adjust, 2);//see if good resolution is maintained
bw_adjust >>= 2; // See if good resolution is maintained.
/* adjust Rate if jitter sign is mostly constant */
recBw = WEBRTC_SPL_UMUL(bweStr->recBw, bw_adjust);
recBw = WEBRTC_SPL_RSHIFT_W32(recBw, 14);
recBw >>= 14;
/* limit range of bottle neck rate */
if (recBw < MIN_ISAC_BW) {
@ -774,9 +776,7 @@ uint16_t WebRtcIsacfix_GetDownlinkBandwidth(const BwEstimatorstr *bweStr)
/* Returns the mmax delay (in ms) */
int16_t WebRtcIsacfix_GetDownlinkMaxDelay(const BwEstimatorstr *bweStr)
{
int16_t recMaxDelay;
recMaxDelay = (int16_t) WEBRTC_SPL_RSHIFT_W32(bweStr->recMaxDelay, 15);
int16_t recMaxDelay = (int16_t)(bweStr->recMaxDelay >> 15);
/* limit range of jitter estimate */
if (recMaxDelay < MIN_ISAC_MD) {
@ -810,9 +810,7 @@ int16_t WebRtcIsacfix_GetUplinkBandwidth(const BwEstimatorstr *bweStr)
/* Returns the max delay value from the other side in ms */
int16_t WebRtcIsacfix_GetUplinkMaxDelay(const BwEstimatorstr *bweStr)
{
int16_t send_max_delay;
send_max_delay = (int16_t) WEBRTC_SPL_RSHIFT_W32(bweStr->sendMaxDelayAvg, 9);
int16_t send_max_delay = (int16_t)(bweStr->sendMaxDelayAvg >> 9);
/* limit range of jitter estimate */
if (send_max_delay < MIN_ISAC_MD) {
@ -858,17 +856,19 @@ uint16_t WebRtcIsacfix_GetMinBytes(RateModel *State,
(((512 - 512 / BURST_LEN) * DelayBuildUp) >> 9)) {
/* max bps derived from BottleNeck and DelayBuildUp values */
inv_Q12 = 4096 / (BURST_LEN * FrameSamples);
MinRate = WEBRTC_SPL_MUL(512 + WEBRTC_SPL_MUL(SAMPLES_PER_MSEC, WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(DelayBuildUp, inv_Q12), 3)), BottleNeck);
MinRate = (512 + SAMPLES_PER_MSEC * ((DelayBuildUp * inv_Q12) >> 3)) *
BottleNeck;
} else {
/* max bps derived from StillBuffered and DelayBuildUp values */
inv_Q12 = 4096 / FrameSamples;
if (DelayBuildUp > State->StillBuffered) {
MinRate = WEBRTC_SPL_MUL(512 + WEBRTC_SPL_MUL(SAMPLES_PER_MSEC, WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(DelayBuildUp - State->StillBuffered, inv_Q12), 3)), BottleNeck);
MinRate = (512 + SAMPLES_PER_MSEC * (((DelayBuildUp -
State->StillBuffered) * inv_Q12) >> 3)) * BottleNeck;
} else if ((den = WEBRTC_SPL_MUL(SAMPLES_PER_MSEC, (State->StillBuffered - DelayBuildUp))) >= FrameSamples) {
/* MinRate will be negative here */
MinRate = 0;
} else {
MinRate = WEBRTC_SPL_MUL((512 - WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(den, inv_Q12), 3)), BottleNeck);
MinRate = (512 - ((den * inv_Q12) >> 3)) * BottleNeck;
}
//if (MinRate < 1.04 * BottleNeck)
// MinRate = 1.04 * BottleNeck;
@ -886,7 +886,7 @@ uint16_t WebRtcIsacfix_GetMinBytes(RateModel *State,
/* convert rate from bits/second to bytes/packet */
//round and shift before conversion
MinRate += 256;
MinRate = WEBRTC_SPL_RSHIFT_W32(MinRate, 9);
MinRate >>= 9;
MinBytes = MinRate * FrameSamples / FS8;
/* StreamSize will be adjusted if less than MinBytes */

View File

@ -54,7 +54,7 @@ int16_t WebRtcIsacfix_DecodeImpl(int16_t *signal_out16,
int16_t AvgPitchGain_Q12;
int16_t tmp_1, tmp_2;
int32_t tmp32a, tmp32b;
int32_t tmp32a;
int16_t gainQ13;
@ -113,7 +113,8 @@ int16_t WebRtcIsacfix_DecodeImpl(int16_t *signal_out16,
WebRtcIsacfix_Spec2Time(Vector_Word16_1, Vector_Word16_2, Vector_Word32_1, Vector_Word32_2);
for (k=0; k<FRAMESAMPLES/2; k++) {
Vector_Word16_1[k] = (int16_t)WEBRTC_SPL_RSHIFT_W32(Vector_Word32_1[k]+64, 7); //Q16 -> Q9
// Q16 -> Q9.
Vector_Word16_1[k] = (int16_t)((Vector_Word32_1[k] + 64) >> 7);
}
/* ---- If this is recovery frame ---- */
@ -176,8 +177,7 @@ int16_t WebRtcIsacfix_DecodeImpl(int16_t *signal_out16,
/* reduce gain to compensate for pitch enhancer */
/* gain = 1.0f - 0.45f * AvgPitchGain; */
tmp32a = WEBRTC_SPL_MUL_16_16_RSFT(AvgPitchGain_Q12, 29, 0); // Q18
tmp32b = 262144 - tmp32a; // Q18
gainQ13 = (int16_t) WEBRTC_SPL_RSHIFT_W32(tmp32b, 5); // Q13
gainQ13 = (int16_t)((262144 - tmp32a) >> 5); // Q18 -> Q13.
for (k = 0; k < FRAMESAMPLES/2; k++)
{

View File

@ -71,7 +71,7 @@ static int16_t plc_filterma_Fast(
o = WEBRTC_SPL_SAT((int32_t)lim, o, (int32_t)-lim);
/* o should be in the range of int16_t */
o = WEBRTC_SPL_RSHIFT_W32( o, rshift );
o >>= rshift;
/* decay the output signal; this is specific to plc */
*Out++ = (int16_t)WEBRTC_SPL_MUL_16_16_RSFT( (int16_t)o, decay, 15); // ((o + (int32_t)2048) >> 12);
@ -97,7 +97,7 @@ static __inline int32_t log2_Q8_T( uint32_t x ) {
int16_t frac;
zeros=WebRtcSpl_NormU32(x);
frac=(int16_t)WEBRTC_SPL_RSHIFT_W32(((uint32_t)WEBRTC_SPL_LSHIFT_W32(x, zeros)&0x7FFFFFFF), 23);
frac = (int16_t)(((x << zeros) & 0x7FFFFFFF) >> 23);
/* log2(magn(i)) */
return ((31 - zeros) << 8) + frac;
@ -145,7 +145,7 @@ static void MemshipValQ15( int16_t in, int16_t *A, int16_t *B )
WEBRTC_SPL_MUL_16_16_RSFT( in, 983, 12) );
/* b = x^2 / 2 {in Q15} so a shift of 16 is required to
be in correct domain and one more for the division by 2 */
*B = (int16_t)WEBRTC_SPL_RSHIFT_W32( WEBRTC_SPL_MUL_16_16( x, x ) + 0x00010000, 17 );
*B = (int16_t)((x * x + 0x00010000) >> 17);
*A = WEBRTC_SPL_WORD16_MAX - *B;
}
else
@ -164,7 +164,7 @@ static void MemshipValQ15( int16_t in, int16_t *A, int16_t *B )
WEBRTC_SPL_MUL_16_16_RSFT( in, 983, 12) );
/* b = x^2 / 2 {in Q15} so a shift of 16 is required to
be in correct domain and one more for the division by 2 */
*A = (int16_t)WEBRTC_SPL_RSHIFT_W32( WEBRTC_SPL_MUL_16_16( x, x ) + 0x00010000, 17 );
*A = (int16_t)((x * x + 0x00010000) >> 17);
*B = WEBRTC_SPL_WORD16_MAX - *A;
}
@ -501,14 +501,13 @@ int16_t WebRtcIsacfix_DecodePlcImpl(int16_t *signal_out16,
rshift = 0;
while( maxCoeff > WEBRTC_SPL_WORD16_MAX )
{
maxCoeff = WEBRTC_SPL_RSHIFT_W32(maxCoeff, 1);
maxCoeff >>= 1;
rshift++;
}
for( i = 0; i < NOISE_FILTER_LEN; i++ ) {
Vector_Word16_1[ FRAMESAMPLES_HALF - NOISE_FILTER_LEN + i] =
(int16_t)WEBRTC_SPL_RSHIFT_W32(
(ISACdec_obj->plcstr_obj).prevHP[
PITCH_MAX_LAG + 10 - NOISE_FILTER_LEN + i], rshift);
Vector_Word16_1[FRAMESAMPLES_HALF - NOISE_FILTER_LEN + i] =(int16_t)(
ISACdec_obj->plcstr_obj.prevHP[PITCH_MAX_LAG + 10 - NOISE_FILTER_LEN +
i] >> rshift);
}
(ISACdec_obj->plcstr_obj).decayCoeffNoise = plc_filterma_Fast(
Vector_Word16_2,

View File

@ -194,7 +194,8 @@ int WebRtcIsacfix_EncodeImpl(int16_t *in,
}
return status;
}
AvgPitchGain_Q12 = WEBRTC_SPL_RSHIFT_W32(PitchGains_Q12[0] + PitchGains_Q12[1] + PitchGains_Q12[2] + PitchGains_Q12[3], 2);
AvgPitchGain_Q12 = (PitchGains_Q12[0] + PitchGains_Q12[1] +
PitchGains_Q12[2] + PitchGains_Q12[3]) >> 2;
/* find coefficients for perceptual pre-filters */
WebRtcIsacfix_GetLpcCoef(LPandHP, HP16a+QLOOKAHEAD, &ISACenc_obj->maskfiltstr_obj,

View File

@ -72,13 +72,7 @@ enum matrixprod_init_case {
*/
static __inline int32_t CalcLrIntQ(int32_t fixVal, int16_t qDomain) {
int32_t intgr;
int32_t roundVal;
roundVal = WEBRTC_SPL_LSHIFT_W32((int32_t)1, qDomain-1);
intgr = WEBRTC_SPL_RSHIFT_W32(fixVal+roundVal, qDomain);
return intgr;
return (fixVal + (1 << (qDomain - 1))) >> qDomain;
}
/*
@ -154,10 +148,10 @@ static int32_t CalcExpN(int16_t x) {
ax = -ax;
axINT = 1 + (ax >> 8); //Q0
axFRAC = 0x00FF - (ax&0x00FF);
exp16 = (int16_t) WEBRTC_SPL_RSHIFT_W32(32768, axINT); //Q15
exp16 = (int16_t)(32768 >> axINT); // Q15
axFRAC = axFRAC+256; //Q8
exp = WEBRTC_SPL_MUL_16_16(exp16, axFRAC); // Q15*Q8 = Q23
exp = WEBRTC_SPL_RSHIFT_W32(exp, 6); //Q17
exp >>= 6; // Q17
}
return exp;
@ -173,8 +167,8 @@ static void CalcCorrelation(int32_t *PSpecQ12, int32_t *CorrQ7)
int k, n;
for (k = 0; k < FRAMESAMPLES/8; k++) {
summ[k] = WEBRTC_SPL_RSHIFT_W32(PSpecQ12[k] + PSpecQ12[FRAMESAMPLES/4-1 - k] + 16, 5);
diff[k] = WEBRTC_SPL_RSHIFT_W32(PSpecQ12[k] - PSpecQ12[FRAMESAMPLES/4-1 - k] + 16, 5);
summ[k] = (PSpecQ12[k] + PSpecQ12[FRAMESAMPLES / 4 - 1 - k] + 16) >> 5;
diff[k] = (PSpecQ12[k] - PSpecQ12[FRAMESAMPLES / 4 - 1 - k] + 16) >> 5;
}
sum = 2;
@ -185,14 +179,14 @@ static void CalcCorrelation(int32_t *PSpecQ12, int32_t *CorrQ7)
for (k = 0; k < AR_ORDER; k += 2) {
sum = 0;
for (n = 0; n < FRAMESAMPLES/8; n++)
sum += WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(WebRtcIsacfix_kCos[k][n], diff[n]) + 256, 9);
sum += (WebRtcIsacfix_kCos[k][n] * diff[n] + 256) >> 9;
CorrQ7[k+1] = sum;
}
for (k=1; k<AR_ORDER; k+=2) {
sum = 0;
for (n = 0; n < FRAMESAMPLES/8; n++)
sum += WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(WebRtcIsacfix_kCos[k][n], summ[n]) + 256, 9);
sum += (WebRtcIsacfix_kCos[k][n] * summ[n] + 256) >> 9;
CorrQ7[k+1] = sum;
}
}
@ -213,12 +207,12 @@ static void CalcInvArSpec(const int16_t *ARCoefQ12,
sum = 0;
for (n = 0; n < AR_ORDER+1; n++)
sum += WEBRTC_SPL_MUL(ARCoefQ12[n], ARCoefQ12[n]); /* Q24 */
sum = WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(WEBRTC_SPL_RSHIFT_W32(sum, 6), 65) + 32768, 16); /* result in Q8 */
CorrQ11[0] = WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(sum, gainQ10) + 256, 9);
sum = ((sum >> 6) * 65 + 32768) >> 16; /* Result in Q8. */
CorrQ11[0] = (sum * gainQ10 + 256) >> 9;
/* To avoid overflow, we shift down gainQ10 if it is large. We will not lose any precision */
if(gainQ10>400000){
tmpGain = WEBRTC_SPL_RSHIFT_W32(gainQ10, 3);
tmpGain = gainQ10 >> 3;
round = 32;
shftVal = 6;
} else {
@ -231,8 +225,8 @@ static void CalcInvArSpec(const int16_t *ARCoefQ12,
sum = 16384;
for (n = k; n < AR_ORDER+1; n++)
sum += WEBRTC_SPL_MUL(ARCoefQ12[n-k], ARCoefQ12[n]); /* Q24 */
sum = WEBRTC_SPL_RSHIFT_W32(sum, 15);
CorrQ11[k] = WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(sum, tmpGain) + round, shftVal);
sum >>= 15;
CorrQ11[k] = (sum * tmpGain + round) >> shftVal;
}
sum = WEBRTC_SPL_LSHIFT_W32(CorrQ11[0], 7);
for (n = 0; n < FRAMESAMPLES/8; n++)
@ -240,7 +234,7 @@ static void CalcInvArSpec(const int16_t *ARCoefQ12,
for (k = 1; k < AR_ORDER; k += 2) {
for (n = 0; n < FRAMESAMPLES/8; n++)
CurveQ16[n] += WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(WebRtcIsacfix_kCos[k][n], CorrQ11[k+1]) + 2, 2);
CurveQ16[n] += (WebRtcIsacfix_kCos[k][n] * CorrQ11[k + 1] + 2) >> 2;
}
CS_ptrQ9 = WebRtcIsacfix_kCos[0];
@ -256,11 +250,11 @@ static void CalcInvArSpec(const int16_t *ARCoefQ12,
shftVal = 0;
for (n = 0; n < FRAMESAMPLES/8; n++)
diffQ16[n] = WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(CS_ptrQ9[n], WEBRTC_SPL_RSHIFT_W32(CorrQ11[1], shftVal)) + 2, 2);
diffQ16[n] = (CS_ptrQ9[n] * (CorrQ11[1] >> shftVal) + 2) >> 2;
for (k = 2; k < AR_ORDER; k += 2) {
CS_ptrQ9 = WebRtcIsacfix_kCos[k];
for (n = 0; n < FRAMESAMPLES/8; n++)
diffQ16[n] += WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(CS_ptrQ9[n], WEBRTC_SPL_RSHIFT_W32(CorrQ11[k+1], shftVal)) + 2, 2);
diffQ16[n] += (CS_ptrQ9[n] * (CorrQ11[k + 1] >> shftVal) + 2) >> 2;
}
for (k=0; k<FRAMESAMPLES/8; k++) {
@ -286,12 +280,12 @@ static void CalcRootInvArSpec(const int16_t *ARCoefQ12,
sum = 0;
for (n = 0; n < AR_ORDER+1; n++)
sum += WEBRTC_SPL_MUL(ARCoefQ12[n], ARCoefQ12[n]); /* Q24 */
sum = WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(WEBRTC_SPL_RSHIFT_W32(sum, 6), 65) + 32768, 16); /* result in Q8 */
CorrQ11[0] = WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(sum, gainQ10) + 256, 9);
sum = ((sum >> 6) * 65 + 32768) >> 16; /* Result in Q8. */
CorrQ11[0] = (sum * gainQ10 + 256) >> 9;
/* To avoid overflow, we shift down gainQ10 if it is large. We will not lose any precision */
if(gainQ10>400000){
tmpGain = WEBRTC_SPL_RSHIFT_W32(gainQ10, 3);
tmpGain = gainQ10 >> 3;
round = 32;
shftVal = 6;
} else {
@ -304,8 +298,8 @@ static void CalcRootInvArSpec(const int16_t *ARCoefQ12,
sum = 16384;
for (n = k; n < AR_ORDER+1; n++)
sum += WEBRTC_SPL_MUL(ARCoefQ12[n-k], ARCoefQ12[n]); /* Q24 */
sum = WEBRTC_SPL_RSHIFT_W32(sum, 15);
CorrQ11[k] = WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(sum, tmpGain) + round, shftVal);
sum >>= 15;
CorrQ11[k] = (sum * tmpGain + round) >> shftVal;
}
sum = WEBRTC_SPL_LSHIFT_W32(CorrQ11[0], 7);
for (n = 0; n < FRAMESAMPLES/8; n++)
@ -329,11 +323,11 @@ static void CalcRootInvArSpec(const int16_t *ARCoefQ12,
shftVal = 0;
for (n = 0; n < FRAMESAMPLES/8; n++)
diffQ16[n] = WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(CS_ptrQ9[n], WEBRTC_SPL_RSHIFT_W32(CorrQ11[1], shftVal)) + 2, 2);
diffQ16[n] = (CS_ptrQ9[n] * (CorrQ11[1] >> shftVal) + 2) >> 2;
for (k = 2; k < AR_ORDER; k += 2) {
CS_ptrQ9 = WebRtcIsacfix_kCos[k];
for (n = 0; n < FRAMESAMPLES/8; n++)
diffQ16[n] += WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(CS_ptrQ9[n], WEBRTC_SPL_RSHIFT_W32(CorrQ11[k+1], shftVal)) + 2, 2);
diffQ16[n] += (CS_ptrQ9[n] * (CorrQ11[k + 1] >> shftVal) + 2) >> 2;
}
in_sqrt = summQ16[0] + WEBRTC_SPL_LSHIFT_W32(diffQ16[0], shftVal);
@ -399,13 +393,13 @@ static void GenerateDitherQ7(int16_t *bufQ7,
seed = WEBRTC_SPL_UMUL(seed, 196314165) + 907633515;
/* fixed-point dither sample between -64 and 64 (Q7) */
dither1_Q7 = (int16_t)WEBRTC_SPL_RSHIFT_W32((int32_t)seed + 16777216, 25); // * 128/4294967295
dither1_Q7 = (int16_t)(((int32_t)seed + 16777216) >> 25);
/* new random unsigned int32_t */
seed = WEBRTC_SPL_UMUL(seed, 196314165) + 907633515;
/* fixed-point dither sample between -64 and 64 */
dither2_Q7 = (int16_t)WEBRTC_SPL_RSHIFT_W32(seed + 16777216, 25);
dither2_Q7 = (int16_t)((seed + 16777216) >> 25);
shft = (int16_t)(WEBRTC_SPL_RSHIFT_U32(seed, 25) & 15);
if (shft < 5)
@ -439,12 +433,12 @@ static void GenerateDitherQ7(int16_t *bufQ7,
seed = WEBRTC_SPL_UMUL(seed, 196314165) + 907633515;
/* fixed-point dither sample between -64 and 64 */
dither1_Q7 = (int16_t)WEBRTC_SPL_RSHIFT_W32((int32_t)seed + 16777216, 25);
dither1_Q7 = (int16_t)(((int32_t)seed + 16777216) >> 25);
/* dither sample is placed in either even or odd index */
shft = (int16_t)(WEBRTC_SPL_RSHIFT_U32(seed, 25) & 1); /* either 0 or 1 */
bufQ7[k + shft] = (int16_t)WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(dither_gain_Q14, dither1_Q7) + 8192, 14);
bufQ7[k + shft] = (int16_t)((dither_gain_Q14 * dither1_Q7 + 8192) >> 14);
bufQ7[k + 1 - shft] = 0;
}
}
@ -501,10 +495,10 @@ int16_t WebRtcIsacfix_DecodeSpec(Bitstr_dec *streamdata,
{
gainQ10 = WebRtcSpl_DivW32W16ResW16(WEBRTC_SPL_LSHIFT_W32((int32_t)30, 10),
(int16_t)WEBRTC_SPL_RSHIFT_U32(invARSpec2_Q16[k>>2] + (uint32_t)2195456, 16));
*frQ7++ = (int16_t)WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(data[ k ], gainQ10) + 512, 10);
*fiQ7++ = (int16_t)WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(data[k+1], gainQ10) + 512, 10);
*frQ7++ = (int16_t)WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(data[k+2], gainQ10) + 512, 10);
*fiQ7++ = (int16_t)WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(data[k+3], gainQ10) + 512, 10);
*frQ7++ = (int16_t)((data[k] * gainQ10 + 512) >> 10);
*fiQ7++ = (int16_t)((data[k + 1] * gainQ10 + 512) >> 10);
*frQ7++ = (int16_t)((data[k + 2] * gainQ10 + 512) >> 10);
*fiQ7++ = (int16_t)((data[k + 3] * gainQ10 + 512) >> 10);
}
}
else
@ -513,10 +507,10 @@ int16_t WebRtcIsacfix_DecodeSpec(Bitstr_dec *streamdata,
{
gainQ10 = WebRtcSpl_DivW32W16ResW16(WEBRTC_SPL_LSHIFT_W32((int32_t)36, 10),
(int16_t)WEBRTC_SPL_RSHIFT_U32(invARSpec2_Q16[k>>2] + (uint32_t)2654208, 16));
*frQ7++ = (int16_t)WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(data[ k ], gainQ10) + 512, 10);
*fiQ7++ = (int16_t)WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(data[k+1], gainQ10) + 512, 10);
*frQ7++ = (int16_t)WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(data[k+2], gainQ10) + 512, 10);
*fiQ7++ = (int16_t)WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(data[k+3], gainQ10) + 512, 10);
*frQ7++ = (int16_t)((data[k] * gainQ10 + 512) >> 10);
*fiQ7++ = (int16_t)((data[k + 1] * gainQ10 + 512) >> 10);
*frQ7++ = (int16_t)((data[k + 2] * gainQ10 + 512) >> 10);
*fiQ7++ = (int16_t)((data[k + 3] * gainQ10 + 512) >> 10);
}
}
@ -584,7 +578,7 @@ int WebRtcIsacfix_EncodeSpec(const int16_t *fr,
CorrQ7_norm[k] = WEBRTC_SPL_LSHIFT_W32(CorrQ7[k], lft_shft);
} else {
for (k=0; k<AR_ORDER+1; k++)
CorrQ7_norm[k] = WEBRTC_SPL_RSHIFT_W32(CorrQ7[k], -lft_shft);
CorrQ7_norm[k] = CorrQ7[k] >> -lft_shft;
}
/* find RC coefficients */
@ -603,20 +597,22 @@ int WebRtcIsacfix_EncodeSpec(const int16_t *fr,
nrg = 0;
for (j = 0; j <= AR_ORDER; j++) {
for (n = 0; n <= j; n++)
nrg += WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(ARCoefQ12[j], WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(CorrQ7_norm[j-n], ARCoefQ12[n]) + 256, 9)) + 4, 3);
nrg += (ARCoefQ12[j] * ((CorrQ7_norm[j - n] * ARCoefQ12[n] + 256) >> 9) +
4) >> 3;
for (n = j+1; n <= AR_ORDER; n++)
nrg += WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(ARCoefQ12[j], WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(CorrQ7_norm[n-j], ARCoefQ12[n]) + 256, 9)) + 4, 3);
nrg += (ARCoefQ12[j] * ((CorrQ7_norm[n - j] * ARCoefQ12[n] + 256) >> 9) +
4) >> 3;
}
if (lft_shft > 0)
nrg = WEBRTC_SPL_RSHIFT_W32(nrg, lft_shft);
nrg >>= lft_shft;
else
nrg = WEBRTC_SPL_LSHIFT_W32(nrg, -lft_shft);
if(nrg>131072)
gain2_Q10 = WebRtcSpl_DivResultInQ31(FRAMESAMPLES >> 2, nrg); /* also shifts 31 bits to the left! */
else
gain2_Q10 = WEBRTC_SPL_RSHIFT_W32(FRAMESAMPLES, 2);
gain2_Q10 = FRAMESAMPLES >> 2;
/* quantize & code gain2_Q10 */
if (WebRtcIsacfix_EncodeGain2(&gain2_Q10, streamdata))
@ -715,20 +711,20 @@ static void Lar2RcFix(const int32_t *larQ17, int16_t *rcQ15, int16_t order) {
for (k = 0; k < order; k++) {
larAbsQ11 = (int16_t) WEBRTC_SPL_ABS_W32(WEBRTC_SPL_RSHIFT_W32(larQ17[k]+32,6)); //Q11
larAbsQ11 = (int16_t)WEBRTC_SPL_ABS_W32((larQ17[k] + 32) >> 6); // Q11
if (larAbsQ11<4097) { //2.000012018559 in Q11
// Q11*Q16>>12 = Q15
rc = WEBRTC_SPL_MUL_16_16_RSFT(larAbsQ11, 24957, 12);
} else if (larAbsQ11<6393) { //3.121320351712 in Q11
// (Q11*Q17 + Q13)>>13 = Q15
rc = WEBRTC_SPL_RSHIFT_W32((WEBRTC_SPL_MUL_16_16(larAbsQ11, 17993) + 130738688), 13);
rc = (larAbsQ11 * 17993 + 130738688) >> 13;
} else if (larAbsQ11<11255) { //5.495270168700 in Q11
// (Q11*Q19 + Q30)>>15 = Q15
rc = WEBRTC_SPL_RSHIFT_W32((WEBRTC_SPL_MUL_16_16(larAbsQ11, 16850) + 875329820), 15);
rc = (larAbsQ11 * 16850 + 875329820) >> 15;
} else {
// (Q11*Q24>>16 + Q19)>>4 = Q15
rc = WEBRTC_SPL_RSHIFT_W32(((WEBRTC_SPL_MUL_16_16_RSFT(larAbsQ11, 24433, 16)) + 515804), 4);
rc = (((larAbsQ11 * 24433) >> 16) + 515804) >> 4;
}
if (larQ17[k]<=0) {
@ -1020,14 +1016,16 @@ int WebRtcIsacfix_DecodeLpcCoef(Bitstr_dec *streamdata,
for (k=0; k<SUBFRAMES; k++) {
/* log gains */
sumQQ16 = (int16_t) WEBRTC_SPL_RSHIFT_W32(tmpcoeffs_gQ17[posg], 2+9); //Divide by 4 and get Q17 to Q8, i.e. shift 2+9
// Divide by 4 and get Q17 to Q8, i.e. shift 2+9.
sumQQ16 = (int16_t)(tmpcoeffs_gQ17[posg] >> 11);
sumQQ16 += WebRtcIsacfix_kMeansGainQ8[model][posg];
sumQQ = CalcExpN(sumQQ16); // Q8 in and Q17 out
gain_lo_hiQ17[gainpos] = sumQQ; //Q17
gainpos++;
posg++;
sumQQ16 = (int16_t) WEBRTC_SPL_RSHIFT_W32(tmpcoeffs_gQ17[posg], 2+9); //Divide by 4 and get Q17 to Q8, i.e. shift 2+9
// Divide by 4 and get Q17 to Q8, i.e. shift 2+9.
sumQQ16 = (int16_t)(tmpcoeffs_gQ17[posg] >> 11);
sumQQ16 += WebRtcIsacfix_kMeansGainQ8[model][posg];
sumQQ = CalcExpN(sumQQ16); // Q8 in and Q17 out
gain_lo_hiQ17[gainpos] = sumQQ; //Q17
@ -1321,7 +1319,8 @@ static int EstCodeLpcCoef(int32_t *LPCCoefQ17,
gainpos = 0;
for (k=0; k<2*SUBFRAMES; k++) {
sumQQ16 = (int16_t) WEBRTC_SPL_RSHIFT_W32(tmpcoeffs_gQ17[posg], 2+9); //Divide by 4 and get Q17 to Q8, i.e. shift 2+9
// Divide by 4 and get Q17 to Q8, i.e. shift 2+9.
sumQQ16 = (int16_t)(tmpcoeffs_gQ17[posg] >> 11);
sumQQ16 += WebRtcIsacfix_kMeansGainQ8[0][posg];
sumQQ = CalcExpN(sumQQ16); // Q8 in and Q17 out
gain_lo_hiQ17[gainpos] = sumQQ; //Q17
@ -1687,7 +1686,7 @@ int WebRtcIsacfix_DecodePitchLag(Bitstr_dec *streamdata,
for (k = 0; k < 4; k++)
meangainQ12 += PitchGain_Q12[k];
meangainQ12 = WEBRTC_SPL_RSHIFT_W32(meangainQ12, 2); // Get average
meangainQ12 >>= 2; // Get average.
/* voicing classificiation */
if (meangainQ12 <= 819) { // mean_gain < 0.2
@ -1731,21 +1730,21 @@ int WebRtcIsacfix_DecodePitchLag(Bitstr_dec *streamdata,
CQ11 = WEBRTC_SPL_SHIFT_W32(CQ11,11-shft); // Scale with StepSize, Q11
for (k=0; k<PITCH_SUBFRAMES; k++) {
tmp32a = WEBRTC_SPL_MUL_16_32_RSFT11(WebRtcIsacfix_kTransform[0][k], CQ11);
tmp16a = (int16_t) WEBRTC_SPL_RSHIFT_W32(tmp32a, 5);
tmp16a = (int16_t)(tmp32a >> 5);
PitchLags_Q7[k] = tmp16a;
}
CQ10 = mean_val2Q10[index[1]];
for (k=0; k<PITCH_SUBFRAMES; k++) {
tmp32b = (int32_t) WEBRTC_SPL_MUL_16_16_RSFT((int16_t) WebRtcIsacfix_kTransform[1][k], (int16_t) CQ10,10);
tmp16c = (int16_t) WEBRTC_SPL_RSHIFT_W32(tmp32b, 5);
tmp16c = (int16_t)(tmp32b >> 5);
PitchLags_Q7[k] += tmp16c;
}
CQ10 = mean_val4Q10[index[3]];
for (k=0; k<PITCH_SUBFRAMES; k++) {
tmp32b = (int32_t) WEBRTC_SPL_MUL_16_16_RSFT((int16_t) WebRtcIsacfix_kTransform[3][k], (int16_t) CQ10,10);
tmp16c = (int16_t) WEBRTC_SPL_RSHIFT_W32(tmp32b, 5);
tmp16c = (int16_t)(tmp32b >> 5);
PitchLags_Q7[k] += tmp16c;
}
@ -1775,7 +1774,7 @@ int WebRtcIsacfix_EncodePitchLag(int16_t *PitchLagsQ7,int16_t *PitchGain_Q12,
for (k = 0; k < 4; k++)
meangainQ12 += PitchGain_Q12[k];
meangainQ12 = WEBRTC_SPL_RSHIFT_W32(meangainQ12, 2);
meangainQ12 >>= 2;
/* Save data for creation of multiple bitstreams */
if (encData != NULL) {
@ -1817,7 +1816,7 @@ int WebRtcIsacfix_EncodePitchLag(int16_t *PitchLagsQ7,int16_t *PitchGain_Q12,
CQ17 = WEBRTC_SPL_SHIFT_W32(CQ17,shft); // Scale with StepSize
/* quantize */
tmp16b = (int16_t) WEBRTC_SPL_RSHIFT_W32(CQ17 + 65536, 17 );
tmp16b = (int16_t)((CQ17 + 65536) >> 17);
index[k] = tmp16b;
/* check that the index is not outside the boundaries of the table */
@ -1837,21 +1836,21 @@ int WebRtcIsacfix_EncodePitchLag(int16_t *PitchLagsQ7,int16_t *PitchGain_Q12,
for (k=0; k<PITCH_SUBFRAMES; k++) {
tmp32a = WEBRTC_SPL_MUL_16_32_RSFT11(WebRtcIsacfix_kTransform[0][k], CQ11); // Q12
tmp16a = (int16_t) WEBRTC_SPL_RSHIFT_W32(tmp32a, 5);// Q7
tmp16a = (int16_t)(tmp32a >> 5); // Q7.
PitchLagsQ7[k] = tmp16a;
}
CQ10 = mean_val2Q10[index[1]];
for (k=0; k<PITCH_SUBFRAMES; k++) {
tmp32b = (int32_t) WEBRTC_SPL_MUL_16_16_RSFT((int16_t) WebRtcIsacfix_kTransform[1][k], (int16_t) CQ10,10);
tmp16c = (int16_t) WEBRTC_SPL_RSHIFT_W32(tmp32b, 5); // Q7
tmp16c = (int16_t)(tmp32b >> 5); // Q7.
PitchLagsQ7[k] += tmp16c;
}
CQ10 = mean_val4Q10[index[3]];
for (k=0; k<PITCH_SUBFRAMES; k++) {
tmp32b = (int32_t) WEBRTC_SPL_MUL_16_16_RSFT((int16_t) WebRtcIsacfix_kTransform[3][k], (int16_t) CQ10,10);
tmp16c = (int16_t) WEBRTC_SPL_RSHIFT_W32(tmp32b, 5); // Q7
tmp16c = (int16_t)(tmp32b >> 5); // Q7.
PitchLagsQ7[k] += tmp16c;
}

View File

@ -141,7 +141,7 @@ void WebRtcIsacfix_HighpassFilterFixDec32C(int16_t *io,
(WEBRTC_SPL_MUL_16_32_RSFT16(coefficient[2], state1) >> 16);
#endif
c = ((int32_t)in) + WEBRTC_SPL_RSHIFT_W32(a1+b1, 7); // Q0
c = in + ((a1 + b1) >> 7); // Q0.
io[k] = (int16_t)WebRtcSpl_SatW32ToW16(c); // Write output as Q0.
c = WEBRTC_SPL_LSHIFT_W32((int32_t)in, 2) - a2 - b2; // In Q2.
@ -223,9 +223,9 @@ void WebRtcIsacfix_SplitAndFilter1(int16_t *pin,
int32_t tmp1, tmp2, tmp3;
tmp1 = (int32_t)tempin_ch1[k]; // Q0 -> Q0
tmp2 = (int32_t)tempin_ch2[k]; // Q0 -> Q0
tmp3 = (int32_t)WEBRTC_SPL_RSHIFT_W32((tmp1 + tmp2), 1);/* low pass signal*/
tmp3 = (tmp1 + tmp2) >> 1; /* Low pass signal. */
LP16[k] = (int16_t)WebRtcSpl_SatW32ToW16(tmp3); /*low pass */
tmp3 = (int32_t)WEBRTC_SPL_RSHIFT_W32((tmp1 - tmp2), 1);/* high pass signal*/
tmp3 = (tmp1 - tmp2) >> 1; /* High pass signal. */
HP16[k] = (int16_t)WebRtcSpl_SatW32ToW16(tmp3); /*high pass */
}
@ -282,9 +282,9 @@ void WebRtcIsacfix_SplitAndFilter2(int16_t *pin,
int32_t tmp1, tmp2, tmp3;
tmp1 = (int32_t)tempin_ch1[k]; // Q0 -> Q0
tmp2 = (int32_t)tempin_ch2[k]; // Q0 -> Q0
tmp3 = (int32_t)WEBRTC_SPL_RSHIFT_W32((tmp1 + tmp2), 1);/* low pass signal*/
tmp3 = (tmp1 + tmp2) >> 1; /* Low pass signal. */
LP16[k] = (int16_t)WebRtcSpl_SatW32ToW16(tmp3); /*low pass */
tmp3 = (int32_t)WEBRTC_SPL_RSHIFT_W32((tmp1 - tmp2), 1);/* high pass signal*/
tmp3 = (tmp1 - tmp2) >> 1; /* High pass signal. */
HP16[k] = (int16_t)WebRtcSpl_SatW32ToW16(tmp3); /*high pass */
}

View File

@ -76,13 +76,12 @@ static void AllpassFilterForDec32(int16_t *InOut16, //Q0
a = WEBRTC_SPL_MUL_16_32_RSFT16(InOut16[n], APSectionFactors[j]); //Q0*Q31=Q31 shifted 16 gives Q15
a = WEBRTC_SPL_LSHIFT_W32(a, 1); // Q15 -> Q16
b = WebRtcSpl_AddSatW32(a, FilterState[j]); //Q16+Q16=Q16
a = WEBRTC_SPL_MUL_16_32_RSFT16(
(int16_t) WEBRTC_SPL_RSHIFT_W32(b, 16),
-APSectionFactors[j]); //Q0*Q31=Q31 shifted 16 gives Q15
// |a| in Q15 (Q0*Q31=Q31 shifted 16 gives Q15).
a = WEBRTC_SPL_MUL_16_32_RSFT16(b >> 16, -APSectionFactors[j]);
FilterState[j] = WebRtcSpl_AddSatW32(
WEBRTC_SPL_LSHIFT_W32(a,1),
WEBRTC_SPL_LSHIFT_W32((uint32_t)InOut16[n], 16)); // Q15<<1 + Q0<<16 = Q16 + Q16 = Q16
InOut16[n] = (int16_t) WEBRTC_SPL_RSHIFT_W32(b, 16); //Save as Q0
InOut16[n] = (int16_t)(b >> 16); // Save as Q0.
}
}
}
@ -102,7 +101,7 @@ void WebRtcIsacfix_DecimateAllpass32(const int16_t *in,
memcpy(data_vec+1, in, WEBRTC_SPL_MUL_16_16(sizeof(int16_t), (N-1)));
data_vec[0] = (int16_t) WEBRTC_SPL_RSHIFT_W32(state_in[WEBRTC_SPL_MUL_16_16(2, ALLPASSSECTIONS)],16); //the z^(-1) state
data_vec[0] = (int16_t)(state_in[2 * ALLPASSSECTIONS] >> 16); // z^-1 state.
state_in[WEBRTC_SPL_MUL_16_16(2, ALLPASSSECTIONS)] = WEBRTC_SPL_LSHIFT_W32((uint32_t)in[N-1],16);

View File

@ -136,7 +136,7 @@ void WebRtcIsacfix_NormLatticeFilterMa(int16_t orderCoef,
gain32 = WEBRTC_SPL_MUL_16_32_RSFT15(cthQ15[k], gain32); //Q15*Q(17+gain_sh)>>15 = Q(17+gain_sh)
inv_cthQ16[k] = WebRtcSpl_DivW32W16((int32_t)2147483647, cthQ15[k]); // 1/cth[k] in Q31/Q15 = Q16
}
gain16 = (int16_t) WEBRTC_SPL_RSHIFT_W32(gain32, 16); //Q(1+gain_sh)
gain16 = (int16_t)(gain32 >> 16); // Q(1+gain_sh).
/* normalized lattice filter */
/*****************************/
@ -158,7 +158,7 @@ void WebRtcIsacfix_NormLatticeFilterMa(int16_t orderCoef,
tmp32 = WEBRTC_SPL_MUL_16_32_RSFT15(sthQ15[i-1], stateGQ15[i-1]);//Q15*Q15>>15 = Q15
tmp32b= fQtmp + tmp32; //Q15+Q15=Q15
tmp32 = inv_cthQ16[i-1]; //Q16
t16a = (int16_t) WEBRTC_SPL_RSHIFT_W32(tmp32, 16);
t16a = (int16_t)(tmp32 >> 16);
t16b = (int16_t) (tmp32-WEBRTC_SPL_LSHIFT_W32(((int32_t)t16a), 16));
if (t16b<0) t16a++;
tmp32 = LATTICE_MUL_32_32_RSFT16(t16a, t16b, tmp32b);
@ -186,7 +186,7 @@ void WebRtcIsacfix_NormLatticeFilterMa(int16_t orderCoef,
for(n=0;n<HALF_SUBFRAMELEN;n++)
{
//gain32 = WEBRTC_SPL_RSHIFT_W32(gain32, gain_sh); // Q(17+gain_sh) -> Q17
//gain32 >>= gain_sh; // Q(17+gain_sh) -> Q17
tmp32 = WEBRTC_SPL_MUL_16_32_RSFT16(gain16, fQ15vec[n]); //Q(1+gain_sh)*Q15>>16 = Q(gain_sh)
sh = 9-gain_sh; //number of needed shifts to reach Q9
t16a = (int16_t) WEBRTC_SPL_SHIFT_W32(tmp32, sh);
@ -267,7 +267,7 @@ void WebRtcIsacfix_NormLatticeFilterAr(int16_t orderCoef,
inv_gain32 = WebRtcSpl_DivW32W16((int32_t)2147483647, den16); // 1/gain in Q31/Q(sh+11) = Q(20-sh)
//initial conditions
inv_gain16 = (int16_t) WEBRTC_SPL_RSHIFT_W32(inv_gain32, 2); // 1/gain in Q(20-sh-2) = Q(18-sh)
inv_gain16 = (int16_t)(inv_gain32 >> 2); // 1/gain in Q(20-sh-2) = Q(18-sh)
for (i=0;i<HALF_SUBFRAMELEN;i++)
{
@ -281,10 +281,10 @@ void WebRtcIsacfix_NormLatticeFilterAr(int16_t orderCoef,
for (i=orderCoef-1;i>=0;i--) //get the state of f&g for the first input, for all orders
{
tmp32 = WEBRTC_SPL_RSHIFT_W32(((WEBRTC_SPL_MUL_16_16(cthQ15[i],ARfQ0vec[0])) - (WEBRTC_SPL_MUL_16_16(sthQ15[i],stateGQ0[i])) + 16384), 15);
tmp32 = (cthQ15[i] * ARfQ0vec[0] - sthQ15[i] * stateGQ0[i] + 16384) >> 15;
tmpAR = (int16_t)WebRtcSpl_SatW32ToW16(tmp32); // Q0
tmp32 = WEBRTC_SPL_RSHIFT_W32(((WEBRTC_SPL_MUL_16_16(sthQ15[i],ARfQ0vec[0])) + (WEBRTC_SPL_MUL_16_16(cthQ15[i], stateGQ0[i])) + 16384), 15);
tmp32 = (sthQ15[i] * ARfQ0vec[0] + cthQ15[i] * stateGQ0[i] + 16384) >> 15;
ARgQ0vec[i+1] = (int16_t)WebRtcSpl_SatW32ToW16(tmp32); // Q0
ARfQ0vec[0] = tmpAR;
}

View File

@ -36,10 +36,8 @@ void WebRtcIsacfix_FilterArLoop(int16_t* ar_g_Q0, // Input samples
tmpAR = ar_f_Q0[n + 1];
for (k = order_coef - 1; k >= 0; k--) {
tmp32 = WEBRTC_SPL_RSHIFT_W32(((WEBRTC_SPL_MUL_16_16(cth_Q15[k], tmpAR))
- (WEBRTC_SPL_MUL_16_16(sth_Q15[k], ar_g_Q0[k])) + 16384), 15);
tmp32_2 = WEBRTC_SPL_RSHIFT_W32(((WEBRTC_SPL_MUL_16_16(sth_Q15[k], tmpAR))
+ (WEBRTC_SPL_MUL_16_16(cth_Q15[k], ar_g_Q0[k])) + 16384), 15);
tmp32 = (cth_Q15[k] * tmpAR - sth_Q15[k] * ar_g_Q0[k] + 16384) >> 15;
tmp32_2 = (sth_Q15[k] * tmpAR + cth_Q15[k] * ar_g_Q0[k] + 16384) >> 15;
tmpAR = (int16_t)WebRtcSpl_SatW32ToW16(tmp32);
ar_g_Q0[k + 1] = (int16_t)WebRtcSpl_SatW32ToW16(tmp32_2);
}

View File

@ -39,7 +39,7 @@ void WebRtcSpl_AToK_JSK(
for (m=useOrder-1; m>0; m--) {
tmp_inv_denum32 = ((int32_t) 1073741823) - WEBRTC_SPL_MUL_16_16(k16[m], k16[m]); // (1 - k^2) in Q30
tmp_inv_denum16 = (int16_t) WEBRTC_SPL_RSHIFT_W32(tmp_inv_denum32, 15); // (1 - k^2) in Q15
tmp_inv_denum16 = (int16_t)(tmp_inv_denum32 >> 15); // (1 - k^2) in Q15.
for (k=1; k<=m; k++) {
tmp32b = WEBRTC_SPL_LSHIFT_W32((int32_t)a16[k], 16) -
@ -49,7 +49,7 @@ void WebRtcSpl_AToK_JSK(
}
for (k=1; k<m; k++) {
a16[k] = (int16_t) WEBRTC_SPL_RSHIFT_W32(tmp32[k], 1); //Q12>>1 => Q11
a16[k] = (int16_t)(tmp32[k] >> 1); // Q12>>1 => Q11
}
tmp32[m] = WEBRTC_SPL_SAT(4092, tmp32[m], -4092);
@ -90,8 +90,8 @@ int16_t WebRtcSpl_LevinsonW32_JSK(
for (i=order;i>=0;i--) {
temp1W32 = WEBRTC_SPL_LSHIFT_W32(R[i], norm);
/* Put R in hi and low format */
R_hi[i] = (int16_t) WEBRTC_SPL_RSHIFT_W32(temp1W32, 16);
R_low[i] = (int16_t)WEBRTC_SPL_RSHIFT_W32((temp1W32 - WEBRTC_SPL_LSHIFT_W32((int32_t)R_hi[i], 16)), 1);
R_hi[i] = (int16_t)(temp1W32 >> 16);
R_low[i] = (int16_t)((temp1W32 - ((int32_t)R_hi[i] << 16)) >> 1);
}
/* K = A[1] = -R[1] / R[0] */
@ -106,41 +106,39 @@ int16_t WebRtcSpl_LevinsonW32_JSK(
}
/* Put K in hi and low format */
K_hi = (int16_t) WEBRTC_SPL_RSHIFT_W32(temp1W32, 16);
K_low = (int16_t)WEBRTC_SPL_RSHIFT_W32((temp1W32 - WEBRTC_SPL_LSHIFT_W32((int32_t)K_hi, 16)), 1);
K_hi = (int16_t)(temp1W32 >> 16);
K_low = (int16_t)((temp1W32 - ((int32_t)K_hi << 16)) >> 1);
/* Store first reflection coefficient */
K[0] = K_hi;
temp1W32 = WEBRTC_SPL_RSHIFT_W32(temp1W32, 4); /* A[1] in Q27 */
temp1W32 >>= 4; /* A[1] in Q27. */
/* Put A[1] in hi and low format */
A_hi[1] = (int16_t) WEBRTC_SPL_RSHIFT_W32(temp1W32, 16);
A_low[1] = (int16_t)WEBRTC_SPL_RSHIFT_W32((temp1W32 - WEBRTC_SPL_LSHIFT_W32((int32_t)A_hi[1], 16)), 1);
A_hi[1] = (int16_t)(temp1W32 >> 16);
A_low[1] = (int16_t)((temp1W32 - ((int32_t)A_hi[1] << 16)) >> 1);
/* Alpha = R[0] * (1-K^2) */
temp1W32 = WEBRTC_SPL_LSHIFT_W32((WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL_16_16(K_hi, K_low), 14) +
WEBRTC_SPL_MUL_16_16(K_hi, K_hi)), 1); /* temp1W32 = k^2 in Q31 */
temp1W32 = (((K_hi * K_low) >> 14) + K_hi * K_hi) << 1; /* = k^2 in Q31 */
temp1W32 = WEBRTC_SPL_ABS_W32(temp1W32); /* Guard against <0 */
temp1W32 = (int32_t)0x7fffffffL - temp1W32; /* temp1W32 = (1 - K[0]*K[0]) in Q31 */
/* Store temp1W32 = 1 - K[0]*K[0] on hi and low format */
tmp_hi = (int16_t) WEBRTC_SPL_RSHIFT_W32(temp1W32, 16);
tmp_low = (int16_t)WEBRTC_SPL_RSHIFT_W32((temp1W32 - WEBRTC_SPL_LSHIFT_W32((int32_t)tmp_hi, 16)), 1);
tmp_hi = (int16_t)(temp1W32 >> 16);
tmp_low = (int16_t)((temp1W32 - ((int32_t)tmp_hi << 16)) >> 1);
/* Calculate Alpha in Q31 */
temp1W32 = WEBRTC_SPL_LSHIFT_W32((WEBRTC_SPL_MUL_16_16(R_hi[0], tmp_hi) +
WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL_16_16(R_hi[0], tmp_low), 15) +
WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL_16_16(R_low[0], tmp_hi), 15) ), 1);
temp1W32 = (R_hi[0] * tmp_hi + ((R_hi[0] * tmp_low) >> 15) +
((R_low[0] * tmp_hi) >> 15)) << 1;
/* Normalize Alpha and put it in hi and low format */
Alpha_exp = WebRtcSpl_NormW32(temp1W32);
temp1W32 = WEBRTC_SPL_LSHIFT_W32(temp1W32, Alpha_exp);
Alpha_hi = (int16_t) WEBRTC_SPL_RSHIFT_W32(temp1W32, 16);
Alpha_low = (int16_t)WEBRTC_SPL_RSHIFT_W32((temp1W32 - WEBRTC_SPL_LSHIFT_W32((int32_t)Alpha_hi, 16)), 1);
Alpha_hi = (int16_t)(temp1W32 >> 16);
Alpha_low = (int16_t)((temp1W32 - ((int32_t)Alpha_hi<< 16)) >> 1);
/* Perform the iterative calculations in the
Levinson Durbin algorithm */
@ -150,7 +148,7 @@ int16_t WebRtcSpl_LevinsonW32_JSK(
/* ----
\
temp1W32 = R[i] + > R[j]*A[i-j]
temp1W32 = R[i] + > R[j]*A[i-j]
/
----
j=1..i-1
@ -160,9 +158,9 @@ int16_t WebRtcSpl_LevinsonW32_JSK(
for(j=1; j<i; j++) {
/* temp1W32 is in Q31 */
temp1W32 += (WEBRTC_SPL_LSHIFT_W32(WEBRTC_SPL_MUL_16_16(R_hi[j], A_hi[i-j]), 1) +
WEBRTC_SPL_LSHIFT_W32(( WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL_16_16(R_hi[j], A_low[i-j]), 15) +
WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL_16_16(R_low[j], A_hi[i-j]), 15) ), 1));
temp1W32 += ((R_hi[j] * A_hi[i - j]) << 1) +
((((R_hi[j] * A_low[i - j]) >> 15) +
((R_low[j] * A_hi[i - j]) >> 15)) << 1);
}
temp1W32 = WEBRTC_SPL_LSHIFT_W32(temp1W32, 4);
@ -193,8 +191,8 @@ int16_t WebRtcSpl_LevinsonW32_JSK(
}
/* Put K on hi and low format */
K_hi = (int16_t) WEBRTC_SPL_RSHIFT_W32(temp3W32, 16);
K_low = (int16_t)WEBRTC_SPL_RSHIFT_W32((temp3W32 - WEBRTC_SPL_LSHIFT_W32((int32_t)K_hi, 16)), 1);
K_hi = (int16_t)(temp3W32 >> 16);
K_low = (int16_t)((temp3W32 - ((int32_t)K_hi << 16)) >> 1);
/* Store Reflection coefficient in Q15 */
K[i-1] = K_hi;
@ -218,45 +216,42 @@ int16_t WebRtcSpl_LevinsonW32_JSK(
temp1W32 = WEBRTC_SPL_LSHIFT_W32((int32_t)A_hi[j],16) +
WEBRTC_SPL_LSHIFT_W32((int32_t)A_low[j],1); /* temp1W32 = A[j] in Q27 */
temp1W32 += WEBRTC_SPL_LSHIFT_W32(( WEBRTC_SPL_MUL_16_16(K_hi, A_hi[i-j]) +
WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL_16_16(K_hi, A_low[i-j]), 15) +
WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL_16_16(K_low, A_hi[i-j]), 15) ), 1); /* temp1W32 += K*A[i-j] in Q27 */
temp1W32 += (K_hi * A_hi[i - j] + ((K_hi * A_low[i - j]) >> 15) +
((K_low * A_hi[i - j]) >> 15)) << 1; // temp1W32 += K*A[i-j] in Q27.
/* Put Anew in hi and low format */
A_upd_hi[j] = (int16_t) WEBRTC_SPL_RSHIFT_W32(temp1W32, 16);
A_upd_low[j] = (int16_t)WEBRTC_SPL_RSHIFT_W32((temp1W32 - WEBRTC_SPL_LSHIFT_W32((int32_t)A_upd_hi[j], 16)), 1);
A_upd_hi[j] = (int16_t)(temp1W32 >> 16);
A_upd_low[j] = (int16_t)((temp1W32 - ((int32_t)A_upd_hi[j] << 16)) >> 1);
}
temp3W32 = WEBRTC_SPL_RSHIFT_W32(temp3W32, 4); /* temp3W32 = K in Q27 (Convert from Q31 to Q27) */
temp3W32 >>= 4; /* temp3W32 = K in Q27 (Convert from Q31 to Q27) */
/* Store Anew in hi and low format */
A_upd_hi[i] = (int16_t) WEBRTC_SPL_RSHIFT_W32(temp3W32, 16);
A_upd_low[i] = (int16_t)WEBRTC_SPL_RSHIFT_W32((temp3W32 - WEBRTC_SPL_LSHIFT_W32((int32_t)A_upd_hi[i], 16)), 1);
A_upd_hi[i] = (int16_t)(temp3W32 >> 16);
A_upd_low[i] = (int16_t)((temp3W32 - ((int32_t)A_upd_hi[i] << 16)) >> 1);
/* Alpha = Alpha * (1-K^2) */
temp1W32 = WEBRTC_SPL_LSHIFT_W32((WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL_16_16(K_hi, K_low), 14) +
WEBRTC_SPL_MUL_16_16(K_hi, K_hi)), 1); /* K*K in Q31 */
temp1W32 = (((K_hi * K_low) >> 14) + K_hi * K_hi) << 1; /* K*K in Q31 */
temp1W32 = WEBRTC_SPL_ABS_W32(temp1W32); /* Guard against <0 */
temp1W32 = (int32_t)0x7fffffffL - temp1W32; /* 1 - K*K in Q31 */
/* Convert 1- K^2 in hi and low format */
tmp_hi = (int16_t) WEBRTC_SPL_RSHIFT_W32(temp1W32, 16);
tmp_low = (int16_t)WEBRTC_SPL_RSHIFT_W32((temp1W32 - WEBRTC_SPL_LSHIFT_W32((int32_t)tmp_hi, 16)), 1);
tmp_hi = (int16_t)(temp1W32 >> 16);
tmp_low = (int16_t)((temp1W32 - ((int32_t)tmp_hi << 16)) >> 1);
/* Calculate Alpha = Alpha * (1-K^2) in Q31 */
temp1W32 = WEBRTC_SPL_LSHIFT_W32(( WEBRTC_SPL_MUL_16_16(Alpha_hi, tmp_hi) +
WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL_16_16(Alpha_hi, tmp_low), 15) +
WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL_16_16(Alpha_low, tmp_hi), 15)), 1);
temp1W32 = (Alpha_hi * tmp_hi + ((Alpha_hi * tmp_low) >> 15) +
((Alpha_low * tmp_hi) >> 15)) << 1;
/* Normalize Alpha and store it on hi and low format */
norm = WebRtcSpl_NormW32(temp1W32);
temp1W32 = WEBRTC_SPL_LSHIFT_W32(temp1W32, norm);
Alpha_hi = (int16_t) WEBRTC_SPL_RSHIFT_W32(temp1W32, 16);
Alpha_low = (int16_t)WEBRTC_SPL_RSHIFT_W32((temp1W32 - WEBRTC_SPL_LSHIFT_W32((int32_t)Alpha_hi, 16)), 1);
Alpha_hi = (int16_t)(temp1W32 >> 16);
Alpha_low = (int16_t)((temp1W32 - ((int32_t)Alpha_hi << 16)) >> 1);
/* Update the total nomalization of Alpha */
Alpha_exp = Alpha_exp + norm;
@ -282,7 +277,7 @@ int16_t WebRtcSpl_LevinsonW32_JSK(
temp1W32 = WEBRTC_SPL_LSHIFT_W32((int32_t)A_hi[i], 16) +
WEBRTC_SPL_LSHIFT_W32((int32_t)A_low[i], 1);
/* Round and store upper word */
A[i] = (int16_t)WEBRTC_SPL_RSHIFT_W32(temp1W32+(int32_t)32768, 16);
A[i] = (int16_t)((temp1W32 + 32768) >> 16);
}
return(1); /* Stable filters */
}
@ -350,7 +345,7 @@ static __inline int32_t log2_Q8_LPC( uint32_t x ) {
int16_t frac;
zeros=WebRtcSpl_NormU32(x);
frac=(int16_t)WEBRTC_SPL_RSHIFT_W32(((uint32_t)WEBRTC_SPL_LSHIFT_W32(x, zeros)&0x7FFFFFFF), 23);
frac = (int16_t)(((x << zeros) & 0x7FFFFFFF) >> 23);
/* log2(x) */
return ((31 - zeros) << 8) + frac;
@ -601,9 +596,7 @@ void WebRtcIsacfix_GetLpcCoef(int16_t *inLoQ0,
With 0.35 in Q16 (0.35 ~= 22938/65536.0 = 0.3500061) and varscaleQ14 in Q14,
we get Q16*Q14>>16 = Q14
*/
aaQ14 = (int16_t) WEBRTC_SPL_RSHIFT_W32(
(WEBRTC_SPL_MUL_16_16(22938, (8192 + WEBRTC_SPL_RSHIFT_W32(varscaleQ14, 1)))
+ ((int32_t)32768)), 16);
aaQ14 = (int16_t)((22938 * (8192 + (varscaleQ14 >> 1)) + 32768) >> 16);
/* Calculate tmp = (1.0 + aa*aa); in Q12 */
tmp16 = (int16_t) WEBRTC_SPL_MUL_16_16_RSFT(aaQ14, aaQ14, 15); //Q14*Q14>>15 = Q13
@ -673,16 +666,16 @@ void WebRtcIsacfix_GetLpcCoef(int16_t *inLoQ0,
/* less noise for lower frequencies, by filtering/scaling autocorrelation sequences */
/* Calculate corrlo2[0] = tmpQQlo * corrlo[0] - 2.0*tmpQQlo * corrlo[1];*/
corrlo2QQ[0] = WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL_16_32_RSFT16(tmpQQlo, corrloQQ[0]), 1)- // Q(12+QdomLO-16)>>1 = Q(QdomLO-5)
WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL_16_32_RSFT16(aaQ14, corrloQQ[1]), 2); // 2*Q(14+QdomLO-16)>>3 = Q(QdomLO-2)>>2 = Q(QdomLO-5)
// |corrlo2QQ| in Q(QdomLO-5).
corrlo2QQ[0] = (WEBRTC_SPL_MUL_16_32_RSFT16(tmpQQlo, corrloQQ[0]) >> 1) -
(WEBRTC_SPL_MUL_16_32_RSFT16(aaQ14, corrloQQ[1]) >> 2);
/* Calculate corrlo2[n] = tmpQQlo * corrlo[n] - tmpQQlo * (corrlo[n-1] + corrlo[n+1]);*/
for (n = 1; n <= ORDERLO; n++) {
tmp32 = WEBRTC_SPL_RSHIFT_W32(corrloQQ[n-1], 1) + WEBRTC_SPL_RSHIFT_W32(corrloQQ[n+1], 1); // Q(QdomLO-1)
corrlo2QQ[n] = WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL_16_32_RSFT16(tmpQQlo, corrloQQ[n]), 1)- // Q(12+QdomLO-16)>>1 = Q(QdomLO-5)
WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL_16_32_RSFT16(aaQ14, tmp32), 2); // Q(14+QdomLO-1-16)>>2 = Q(QdomLO-3)>>2 = Q(QdomLO-5)
tmp32 = (corrloQQ[n - 1] >> 1) + (corrloQQ[n + 1] >> 1); // Q(QdomLO-1).
corrlo2QQ[n] = (WEBRTC_SPL_MUL_16_32_RSFT16(tmpQQlo, corrloQQ[n]) >> 1) -
(WEBRTC_SPL_MUL_16_32_RSFT16(aaQ14, tmp32) >> 2);
}
QdomLO -= 5;
@ -705,12 +698,12 @@ void WebRtcIsacfix_GetLpcCoef(int16_t *inLoQ0,
/* corrlo2QQ is in Q(QdomLO) and corrhiQQ is in Q(QdomHI) before the following
code segment, where we want to make sure we get a 1-bit margin */
for (n = 0; n <= ORDERLO; n++) {
corrlo2QQ[n] = WEBRTC_SPL_RSHIFT_W32(corrlo2QQ[n], 1); // Make sure we have a 1-bit margin
corrlo2QQ[n] >>= 1; // Make sure we have a 1-bit margin.
}
QdomLO -= 1; // Now, corrlo2QQ is in Q(QdomLO), with a 1-bit margin
for (n = 0; n <= ORDERHI; n++) {
corrhiQQ[n] = WEBRTC_SPL_RSHIFT_W32(corrhiQQ[n], 1); // Make sure we have a 1-bit margin
corrhiQQ[n] >>= 1; // Make sure we have a 1-bit margin.
}
QdomHI -= 1; // Now, corrhiQQ is in Q(QdomHI), with a 1-bit margin
@ -738,7 +731,7 @@ void WebRtcIsacfix_GetLpcCoef(int16_t *inLoQ0,
// Shift |alpha| as much as possible without overflow the number of
// times required to get |tmp| in QdomLO.
tmp = WEBRTC_SPL_MUL_16_32_RSFT15(alpha << 6, tmp);
tmpCorr = WEBRTC_SPL_RSHIFT_W32(corrloQQ[n], sh-shMem-6);
tmpCorr = corrloQQ[n] >> (sh - shMem - 6);
tmp = tmp + tmpCorr;
maskdata->CorrBufLoQQ[n] = tmp;
newQdomLO = QdomLO-(sh-shMem-6);
@ -759,7 +752,7 @@ void WebRtcIsacfix_GetLpcCoef(int16_t *inLoQ0,
if( newQdomLO!=QdomLO) {
for (n = 0; n <= ORDERLO; n++) {
if (maskdata->CorrBufLoQdom[n] != newQdomLO)
corrloQQ[n] = WEBRTC_SPL_RSHIFT_W32(corrloQQ[n], maskdata->CorrBufLoQdom[n]-newQdomLO);
corrloQQ[n] >>= maskdata->CorrBufLoQdom[n] - newQdomLO;
}
QdomLO = newQdomLO;
}
@ -795,7 +788,7 @@ void WebRtcIsacfix_GetLpcCoef(int16_t *inLoQ0,
// Shift |alpha| as much as possible without overflow the number of
// times required to get |tmp| in QdomHI.
tmp = WEBRTC_SPL_MUL_16_32_RSFT15(alpha << 6, tmp);
tmpCorr = WEBRTC_SPL_RSHIFT_W32(corrhiQQ[n], sh-shMem-6);
tmpCorr = corrhiQQ[n] >> (sh - shMem - 6);
tmp = tmp + tmpCorr;
maskdata->CorrBufHiQQ[n] = tmp;
newQdomHI = QdomHI-(sh-shMem-6);
@ -816,7 +809,7 @@ void WebRtcIsacfix_GetLpcCoef(int16_t *inLoQ0,
if( newQdomHI!=QdomHI) {
for (n = 0; n <= ORDERHI; n++) {
if (maskdata->CorrBufHiQdom[n] != newQdomHI)
corrhiQQ[n] = WEBRTC_SPL_RSHIFT_W32(corrhiQQ[n], maskdata->CorrBufHiQdom[n]-newQdomHI);
corrhiQQ[n] >>= maskdata->CorrBufHiQdom[n] - newQdomHI;
}
QdomHI = newQdomHI;
}
@ -867,7 +860,7 @@ void WebRtcIsacfix_GetLpcCoef(int16_t *inLoQ0,
WebRtcSpl_AToK_JSK(a_LOQ11, ORDERLO, rcQ15_lo);
if (sh_lo & 0x0001) {
res_nrgQQ=WEBRTC_SPL_RSHIFT_W32(res_nrgQQ, 1);
res_nrgQQ >>= 1;
sh_lo-=1;
}
@ -916,7 +909,7 @@ void WebRtcIsacfix_GetLpcCoef(int16_t *inLoQ0,
WebRtcSpl_LpcToReflCoef(polyHI, ORDERHI, rcQ15_hi);
if (sh_hi & 0x0001) {
res_nrgQQ=WEBRTC_SPL_RSHIFT_W32(res_nrgQQ, 1);
res_nrgQQ >>= 1;
sh_hi-=1;
}
@ -930,9 +923,9 @@ void WebRtcIsacfix_GetLpcCoef(int16_t *inLoQ0,
/* hi_coeff = varscale * S_N_R / (sqrt_nrg + varscale * H_T_H); */
//tmp32a=WEBRTC_SPL_MUL_16_16_RSFT(varscaleQ14, H_T_HQ19, 17); // Q14
tmp32a=WEBRTC_SPL_RSHIFT_W32((int32_t) varscaleQ14,1); // H_T_HQ19=65536 (16-17=-1)
tmp32a = varscaleQ14 >> 1; // H_T_HQ19=65536 (16-17=-1)
ssh= WEBRTC_SPL_RSHIFT_W32(sh_hi, 1); // sqrt_nrg is in Qssh
ssh = sh_hi >> 1; // |sqrt_nrg| is in Qssh.
sh = ssh - 14;
tmp32b = WEBRTC_SPL_SHIFT_W32(tmp32a, sh); // Q14->Qssh
tmp32c = sqrt_nrg + tmp32b; // Qssh (denominator)

View File

@ -32,7 +32,7 @@ int32_t WebRtcIsacfix_Log2Q8(uint32_t x) {
int16_t frac;
zeros=WebRtcSpl_NormU32(x);
frac=(int16_t)WEBRTC_SPL_RSHIFT_W32(((uint32_t)(WEBRTC_SPL_LSHIFT_W32(x, zeros))&0x7FFFFFFF), 23);
frac = (int16_t)(((x << zeros) & 0x7FFFFFFF) >> 23);
/* log2(magn(i)) */
lg2= (WEBRTC_SPL_LSHIFT_W32((31-zeros), 8)+frac);
@ -77,7 +77,7 @@ static __inline void Intrp1DQ8(int32_t *x, int32_t *fx, int32_t *y, int32_t *fy)
/* t in Q31, without signs */
t32 = WebRtcSpl_DivResultInQ31(nom32 * sign1, den32 * sign2);
t16=(int16_t)WEBRTC_SPL_RSHIFT_W32(t32, 23); /* Q8 */
t16 = (int16_t)(t32 >> 23); /* Q8 */
t16=t16*sign1*sign2; /* t in Q8 with signs */
*y = x[0]+t16; /* Q8 */
@ -327,7 +327,7 @@ void WebRtcIsacfix_InitialPitch(const int16_t *in, /* Q0 */
/* Bias towards constant pitch */
tmp32a = lagsQ8[0] - PITCH_MIN_LAG_Q8;
ratq = WEBRTC_SPL_RSHIFT_W32(tmp32a, 1) + OFFSET_Q8;
ratq = (tmp32a >> 1) + OFFSET_Q8;
for (k = 1; k <= PITCH_LAG_SPAN2; k++)
{
@ -335,7 +335,7 @@ void WebRtcIsacfix_InitialPitch(const int16_t *in, /* Q0 */
tmp32b = (int32_t) (WEBRTC_SPL_LSHIFT_W32(tmp32a, 1)) - ratq; // Q8
tmp32c = WEBRTC_SPL_MUL_16_16_RSFT((int16_t) tmp32b, (int16_t) tmp32b, 8); // Q8
tmp32b = (int32_t)tmp32c + (int32_t)WEBRTC_SPL_RSHIFT_W32(ratq, 1);
tmp32b = tmp32c + (ratq >> 1);
// (k-r)^2 + 0.5 * r Q8
tmp32c = WebRtcIsacfix_Log2Q8((uint32_t)tmp32a) - 2048;
// offset 8*2^8 , log2(0.5*k) Q8
@ -343,7 +343,7 @@ void WebRtcIsacfix_InitialPitch(const int16_t *in, /* Q0 */
// offset 8*2^8 , log2(0.5*k) Q8
tmp32e = tmp32c - tmp32d;
cv2q[k] += WEBRTC_SPL_RSHIFT_W32(tmp32e, 1);
cv2q[k] += tmp32e >> 1;
}
@ -401,12 +401,10 @@ void WebRtcIsacfix_InitialPitch(const int16_t *in, /* Q0 */
lagsQ8[3] = lagsQ8[0];
}
lagsQ7[0]=(int16_t) WEBRTC_SPL_RSHIFT_W32(lagsQ8[0], 1);
lagsQ7[1]=(int16_t) WEBRTC_SPL_RSHIFT_W32(lagsQ8[1], 1);
lagsQ7[2]=(int16_t) WEBRTC_SPL_RSHIFT_W32(lagsQ8[2], 1);
lagsQ7[3]=(int16_t) WEBRTC_SPL_RSHIFT_W32(lagsQ8[3], 1);
lagsQ7[0] = (int16_t)(lagsQ8[0] >> 1);
lagsQ7[1] = (int16_t)(lagsQ8[1] >> 1);
lagsQ7[2] = (int16_t)(lagsQ8[2] >> 1);
lagsQ7[3] = (int16_t)(lagsQ8[3] >> 1);
}

View File

@ -44,8 +44,7 @@ void WebRtcIsacfix_PCorr2Q32(const int16_t* in, int32_t* logcorQ8) {
scaling); // Q0
}
logcorQ8 += PITCH_LAG_SPAN2 - 1;
lys = WebRtcIsacfix_Log2Q8((uint32_t)ysum32); // Q8
lys = WEBRTC_SPL_RSHIFT_W32(lys, 1); //sqrt(ysum);
lys = WebRtcIsacfix_Log2Q8((uint32_t)ysum32) >> 1; // Q8, sqrt(ysum)
if (csum32 > 0) {
lcs = WebRtcIsacfix_Log2Q8((uint32_t)csum32); // 2log(csum) in Q8
if (lcs > (lys + oneQ8)) { // csum/sqrt(ysum) > 2 in Q8
@ -105,8 +104,7 @@ void WebRtcIsacfix_PCorr2Q32(const int16_t* in, int32_t* logcorQ8) {
logcorQ8--;
lys = WebRtcIsacfix_Log2Q8((uint32_t)ysum32); // Q8
lys = WEBRTC_SPL_RSHIFT_W32(lys, 1); //sqrt(ysum);
lys = WebRtcIsacfix_Log2Q8((uint32_t)ysum32) >> 1; // Q8, sqrt(ysum)
if (csum32 > 0) {
lcs = WebRtcIsacfix_Log2Q8((uint32_t)csum32); // 2log(csum) in Q8

View File

@ -86,8 +86,7 @@ void WebRtcIsacfix_PCorr2Q32(const int16_t* in, int32_t* logcorQ8) {
);
}
logcorQ8 += PITCH_LAG_SPAN2 - 1;
lys = WebRtcIsacfix_Log2Q8((uint32_t)ysum32); // Q8
lys = WEBRTC_SPL_RSHIFT_W32(lys, 1); //sqrt(ysum);
lys = WebRtcIsacfix_Log2Q8((uint32_t)ysum32) >> 1; // Q8, sqrt(ysum)
if (csum32 > 0) {
lcs = WebRtcIsacfix_Log2Q8((uint32_t)csum32); // 2log(csum) in Q8
if (lcs > (lys + oneQ8)) { // csum/sqrt(ysum) > 2 in Q8
@ -180,8 +179,7 @@ void WebRtcIsacfix_PCorr2Q32(const int16_t* in, int32_t* logcorQ8) {
);
logcorQ8--;
lys = WebRtcIsacfix_Log2Q8((uint32_t)ysum32); // Q8
lys = WEBRTC_SPL_RSHIFT_W32(lys, 1); //sqrt(ysum);
lys = WebRtcIsacfix_Log2Q8((uint32_t)ysum32) >> 1; // Q8, sqrt(ysum)
if (csum32 > 0) {
lcs = WebRtcIsacfix_Log2Q8((uint32_t)csum32); // 2log(csum) in Q8
if (lcs > (lys + oneQ8)) { // csum/sqrt(ysum) > 2

View File

@ -53,7 +53,7 @@ static __inline int32_t CalcLrIntQ(int32_t fixVal,
int32_t roundVal;
roundVal = WEBRTC_SPL_LSHIFT_W32((int32_t)1, qDomain - 1);
intgr = WEBRTC_SPL_RSHIFT_W32(fixVal + roundVal, qDomain);
intgr = (fixVal + roundVal) >> qDomain;
return intgr;
}
@ -132,8 +132,7 @@ void WebRtcIsacfix_PitchFilter(int16_t* indatQQ, // Q10 if type is 1 or 4,
indW32 = CalcLrIntQ(curLagQ7, 7);
tmpW32 = WEBRTC_SPL_LSHIFT_W32(indW32, 7);
tmpW32 -= curLagQ7;
frcQQ = WEBRTC_SPL_RSHIFT_W32(tmpW32, 4);
frcQQ += 4;
frcQQ = (tmpW32 >> 4) + 4;
if (frcQQ == PITCH_FRACS) {
frcQQ = 0;
@ -228,19 +227,17 @@ void WebRtcIsacfix_PitchFilterGains(const int16_t* indatQ0,
tmp2W32 = WEBRTC_SPL_MUL_16_32_RSFT14(indatQ0[ind], tmpW32);
tmpW32 += 8192;
tmpW16 = (int16_t)WEBRTC_SPL_RSHIFT_W32(tmpW32, 14);
tmpW16 = (int16_t)(tmpW32 >> 14);
tmpW32 = WEBRTC_SPL_MUL_16_16(tmpW16, tmpW16);
if ((tmp2W32 > 1073700000) || (csum1QQ > 1073700000) ||
(tmpW32 > 1073700000) || (esumxQQ > 1073700000)) { // 2^30
scale++;
csum1QQ = WEBRTC_SPL_RSHIFT_W32(csum1QQ, 1);
esumxQQ = WEBRTC_SPL_RSHIFT_W32(esumxQQ, 1);
csum1QQ >>= 1;
esumxQQ >>= 1;
}
tmp2W32 = WEBRTC_SPL_RSHIFT_W32(tmp2W32, scale);
csum1QQ += tmp2W32;
tmpW32 = WEBRTC_SPL_RSHIFT_W32(tmpW32, scale);
esumxQQ += tmpW32;
csum1QQ += tmp2W32 >> scale;
esumxQQ += tmpW32 >> scale;
ind++;
pos++;
@ -252,7 +249,7 @@ void WebRtcIsacfix_PitchFilterGains(const int16_t* indatQ0,
tmp2W32 = WebRtcSpl_DivResultInQ31(csum1QQ, esumxQQ);
// Gain should be half the correlation.
tmpW32 = WEBRTC_SPL_RSHIFT_W32(tmp2W32, 20);
tmpW32 = tmp2W32 >> 20;
} else {
tmpW32 = 4096;
}

View File

@ -41,7 +41,7 @@ void WebRtcIsacfix_PitchFilterCore(int loopNumber,
/* Saturate to avoid overflow in tmpW16. */
tmpW32 = WEBRTC_SPL_SAT(536862719, tmpW32, -536879104);
tmpW32 += 8192;
tmpW16 = (int16_t)WEBRTC_SPL_RSHIFT_W32(tmpW32, 14);
tmpW16 = (int16_t)(tmpW32 >> 14);
/* Shift low pass filter state. */
memmove(&inputState[1], &inputState[0],
@ -60,7 +60,7 @@ void WebRtcIsacfix_PitchFilterCore(int loopNumber,
/* Saturate to avoid overflow in tmpW16. */
tmpW32 = WEBRTC_SPL_SAT(1073725439, tmpW32, -1073758208);
tmpW32 += 16384;
tmpW16 = (int16_t)WEBRTC_SPL_RSHIFT_W32(tmpW32, 15);
tmpW16 = (int16_t)(tmpW32 >> 15);
/* Subtract from input and update buffer. */
tmpW32 = inputBuf[*index2] - WEBRTC_SPL_MUL_16_16(sign, tmpW16);
@ -71,4 +71,3 @@ void WebRtcIsacfix_PitchFilterCore(int loopNumber,
(*index2)++;
}
}

View File

@ -45,10 +45,11 @@ void WebRtcIsacfix_Time2SpecC(int16_t *inre1Q9,
for (k = 0; k < FRAMESAMPLES/2; k++) {
tmp1rQ14 = WebRtcIsacfix_kCosTab1[k];
tmp1iQ14 = WebRtcIsacfix_kSinTab1[k];
xrQ16 = WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL_16_16(tmp1rQ14, inre1Q9[k]) + WEBRTC_SPL_MUL_16_16(tmp1iQ14, inre2Q9[k]), 7);
xiQ16 = WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL_16_16(tmp1rQ14, inre2Q9[k]) - WEBRTC_SPL_MUL_16_16(tmp1iQ14, inre1Q9[k]), 7);
tmpreQ16[k] = WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL_16_32_RSFT16(factQ19, xrQ16)+4, 3); // (Q16*Q19>>16)>>3 = Q16
tmpimQ16[k] = WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL_16_32_RSFT16(factQ19, xiQ16)+4, 3); // (Q16*Q19>>16)>>3 = Q16
xrQ16 = (tmp1rQ14 * inre1Q9[k] + tmp1iQ14 * inre2Q9[k]) >> 7;
xiQ16 = (tmp1rQ14 * inre2Q9[k] - tmp1iQ14 * inre1Q9[k]) >> 7;
// Q-domains below: (Q16*Q19>>16)>>3 = Q16
tmpreQ16[k] = (WEBRTC_SPL_MUL_16_32_RSFT16(factQ19, xrQ16) + 4) >> 3;
tmpimQ16[k] = (WEBRTC_SPL_MUL_16_32_RSFT16(factQ19, xiQ16) + 4) >> 3;
}
@ -71,8 +72,8 @@ void WebRtcIsacfix_Time2SpecC(int16_t *inre1Q9,
} else {
int32_t round = WEBRTC_SPL_LSHIFT_W32((int32_t)1, -sh-1);
for (k=0; k<FRAMESAMPLES/2; k++) {
inre1Q9[k] = (int16_t) WEBRTC_SPL_RSHIFT_W32(tmpreQ16[k]+round, -sh); //Q(16+sh)
inre2Q9[k] = (int16_t) WEBRTC_SPL_RSHIFT_W32(tmpimQ16[k]+round, -sh); //Q(16+sh)
inre1Q9[k] = (int16_t)((tmpreQ16[k] + round) >> -sh); // Q(16+sh)
inre2Q9[k] = (int16_t)((tmpimQ16[k] + round) >> -sh); // Q(16+sh)
}
}
@ -82,8 +83,8 @@ void WebRtcIsacfix_Time2SpecC(int16_t *inre1Q9,
//"Fastest" vectors
if (sh>=0) {
for (k=0; k<FRAMESAMPLES/2; k++) {
tmpreQ16[k] = WEBRTC_SPL_RSHIFT_W32((int32_t)inre1Q9[k], sh); //Q(16+sh) -> Q16
tmpimQ16[k] = WEBRTC_SPL_RSHIFT_W32((int32_t)inre2Q9[k], sh); //Q(16+sh) -> Q16
tmpreQ16[k] = inre1Q9[k] >> sh; // Q(16+sh) -> Q16
tmpimQ16[k] = inre2Q9[k] >> sh; // Q(16+sh) -> Q16
}
} else {
for (k=0; k<FRAMESAMPLES/2; k++) {
@ -103,12 +104,14 @@ void WebRtcIsacfix_Time2SpecC(int16_t *inre1Q9,
tmp1iQ14 = WebRtcIsacfix_kSinTab2[k];
v1Q16 = WEBRTC_SPL_MUL_16_32_RSFT14(tmp1rQ14, xrQ16) - WEBRTC_SPL_MUL_16_32_RSFT14(tmp1iQ14, xiQ16);
v2Q16 = WEBRTC_SPL_MUL_16_32_RSFT14(tmp1iQ14, xrQ16) + WEBRTC_SPL_MUL_16_32_RSFT14(tmp1rQ14, xiQ16);
outreQ7[k] = (int16_t) WEBRTC_SPL_RSHIFT_W32(v1Q16, 9);
outimQ7[k] = (int16_t) WEBRTC_SPL_RSHIFT_W32(v2Q16, 9);
outreQ7[k] = (int16_t)(v1Q16 >> 9);
outimQ7[k] = (int16_t)(v2Q16 >> 9);
v1Q16 = -WEBRTC_SPL_MUL_16_32_RSFT14(tmp1iQ14, yrQ16) - WEBRTC_SPL_MUL_16_32_RSFT14(tmp1rQ14, yiQ16);
v2Q16 = -WEBRTC_SPL_MUL_16_32_RSFT14(tmp1rQ14, yrQ16) + WEBRTC_SPL_MUL_16_32_RSFT14(tmp1iQ14, yiQ16);
outreQ7[FRAMESAMPLES/2 - 1 - k] = (int16_t)WEBRTC_SPL_RSHIFT_W32(v1Q16, 9); //CalcLrIntQ(v1Q16, 9);
outimQ7[FRAMESAMPLES/2 - 1 - k] = (int16_t)WEBRTC_SPL_RSHIFT_W32(v2Q16, 9); //CalcLrIntQ(v2Q16, 9);
// CalcLrIntQ(v1Q16, 9);
outreQ7[FRAMESAMPLES / 2 - 1 - k] = (int16_t)(v1Q16 >> 9);
// CalcLrIntQ(v2Q16, 9);
outimQ7[FRAMESAMPLES / 2 - 1 - k] = (int16_t)(v2Q16 >> 9);
}
}
@ -166,8 +169,8 @@ void WebRtcIsacfix_Spec2TimeC(int16_t *inreQ7, int16_t *inimQ7, int32_t *outre1Q
} else {
int32_t round = WEBRTC_SPL_LSHIFT_W32((int32_t)1, -sh-1);
for (k=0; k<240; k++) {
inreQ7[k] = (int16_t) WEBRTC_SPL_RSHIFT_W32(outre1Q16[k]+round, -sh); //Q(16+sh)
inimQ7[k] = (int16_t) WEBRTC_SPL_RSHIFT_W32(outre2Q16[k]+round, -sh); //Q(16+sh)
inreQ7[k] = (int16_t)((outre1Q16[k] + round) >> -sh); // Q(16+sh)
inimQ7[k] = (int16_t)((outre2Q16[k] + round) >> -sh); // Q(16+sh)
}
}
@ -176,8 +179,8 @@ void WebRtcIsacfix_Spec2TimeC(int16_t *inreQ7, int16_t *inimQ7, int32_t *outre1Q
//"Fastest" vectors
if (sh>=0) {
for (k=0; k<240; k++) {
outre1Q16[k] = WEBRTC_SPL_RSHIFT_W32((int32_t)inreQ7[k], sh); //Q(16+sh) -> Q16
outre2Q16[k] = WEBRTC_SPL_RSHIFT_W32((int32_t)inimQ7[k], sh); //Q(16+sh) -> Q16
outre1Q16[k] = inreQ7[k] >> sh; // Q(16+sh) -> Q16
outre2Q16[k] = inimQ7[k] >> sh; // Q(16+sh) -> Q16
}
} else {
for (k=0; k<240; k++) {