From d4e75016a3836c3aab992afff6bfd8d5e3862aac Mon Sep 17 00:00:00 2001 From: Bjorn Volcker Date: Thu, 2 Apr 2015 06:59:38 +0200 Subject: [PATCH] Refactor audio_coding/codecs/isac/fix: Removed usage of trivial macro WEBRTC_SPL_LSHIFT_W32() The macro is defined as #define WEBRTC_SPL_LSHIFT_W32(a, b) ((a) << (b)) hence trivial. The macro name may in fact mislead the user to assume a cast/truncation to int32_t is done. - Removing usage of it. - Some style changes. BUG=3348, 3353 TESTED=locally on linux and trybots R=kwiberg@webrtc.org Review URL: https://webrtc-codereview.appspot.com/46749005 Cr-Commit-Position: refs/heads/master@{#8918} --- .../isac/fix/source/arith_routines_hist.c | 17 ++++--- .../isac/fix/source/arith_routines_logist.c | 9 ++-- .../isac/fix/source/bandwidth_estimator.c | 27 ++++++----- .../codecs/isac/fix/source/decode.c | 2 +- .../codecs/isac/fix/source/decode_plc.c | 7 +-- .../codecs/isac/fix/source/entropy_coding.c | 46 ++++++++++--------- .../codecs/isac/fix/source/filterbanks.c | 4 +- .../codecs/isac/fix/source/filters.c | 9 ++-- .../codecs/isac/fix/source/lattice.c | 12 ++--- .../isac/fix/source/lpc_masking_model.c | 37 +++++++-------- .../codecs/isac/fix/source/pitch_estimator.c | 22 ++++----- .../isac/fix/source/pitch_estimator_c.c | 4 +- .../isac/fix/source/pitch_estimator_mips.c | 3 +- .../codecs/isac/fix/source/pitch_filter.c | 11 ++--- .../codecs/isac/fix/source/transform.c | 28 +++++------ 15 files changed, 109 insertions(+), 129 deletions(-) diff --git a/webrtc/modules/audio_coding/codecs/isac/fix/source/arith_routines_hist.c b/webrtc/modules/audio_coding/codecs/isac/fix/source/arith_routines_hist.c index 83f36feff8..ae4f3d230e 100644 --- a/webrtc/modules/audio_coding/codecs/isac/fix/source/arith_routines_hist.c +++ b/webrtc/modules/audio_coding/codecs/isac/fix/source/arith_routines_hist.c @@ -101,7 +101,7 @@ int WebRtcIsacfix_EncHistMulti(Bitstr_enc *streamData, * W_upper < 2^24 */ while ( !(W_upper & 0xFF000000) ) { - W_upper = WEBRTC_SPL_LSHIFT_W32(W_upper, 8); + W_upper <<= 8; if (streamData->full == 0) { *streamPtr++ += (uint16_t)(streamData->streamval >> 24); streamData->full = 1; @@ -113,7 +113,7 @@ int WebRtcIsacfix_EncHistMulti(Bitstr_enc *streamData, if( streamPtr > maxStreamPtr ) { return -ISAC_DISALLOWED_BITSTREAM_LENGTH; } - streamData->streamval = WEBRTC_SPL_LSHIFT_W32(streamData->streamval, 8); + streamData->streamval <<= 8; } } @@ -174,7 +174,7 @@ int16_t WebRtcIsacfix_DecHistBisectMulti(int16_t *data, if (streamData->stream_index == 0) { /* read first word from bytestream */ - streamval = WEBRTC_SPL_LSHIFT_W32((uint32_t)*streamPtr++, 16); + streamval = (uint32_t)*streamPtr++ << 16; streamval |= *streamPtr++; } else { streamval = streamData->streamval; @@ -230,14 +230,13 @@ int16_t WebRtcIsacfix_DecHistBisectMulti(int16_t *data, { /* read next byte from stream */ if (streamData->full == 0) { - streamval = WEBRTC_SPL_LSHIFT_W32(streamval, 8) | - (*streamPtr++ & 0x00FF); + streamval = (streamval << 8) | (*streamPtr++ & 0x00FF); streamData->full = 1; } else { streamval = (streamval << 8) | (*streamPtr >> 8); streamData->full = 0; } - W_upper = WEBRTC_SPL_LSHIFT_W32(W_upper, 8); + W_upper <<= 8; } @@ -379,13 +378,13 @@ int16_t WebRtcIsacfix_DecHistOneStepMulti(int16_t *data, { /* read next byte from stream */ if (streamData->full == 0) { - streamval = WEBRTC_SPL_LSHIFT_W32(streamval, 8) | (*streamPtr++ & 0x00FF); + streamval = (streamval << 8) | (*streamPtr++ & 0x00FF); streamData->full = 1; } else { - streamval = WEBRTC_SPL_LSHIFT_W32(streamval, 8) | (*streamPtr >> 8); + streamval = (streamval << 8) | (*streamPtr >> 8); streamData->full = 0; } - W_upper = WEBRTC_SPL_LSHIFT_W32(W_upper, 8); + W_upper <<= 8; } } diff --git a/webrtc/modules/audio_coding/codecs/isac/fix/source/arith_routines_logist.c b/webrtc/modules/audio_coding/codecs/isac/fix/source/arith_routines_logist.c index 5c7df47821..23048a5c38 100644 --- a/webrtc/modules/audio_coding/codecs/isac/fix/source/arith_routines_logist.c +++ b/webrtc/modules/audio_coding/codecs/isac/fix/source/arith_routines_logist.c @@ -377,18 +377,17 @@ int16_t WebRtcIsacfix_DecLogisticMulti2(int16_t *dataQ7, if (streamPtr < streamData->stream + streamData->stream_size) { /* read next byte from stream */ if (streamData->full == 0) { - streamVal = WEBRTC_SPL_LSHIFT_W32(streamVal, 8) | (*streamPtr++ & 0x00FF); + streamVal = (streamVal << 8) | (*streamPtr++ & 0x00FF); streamData->full = 1; } else { - streamVal = WEBRTC_SPL_LSHIFT_W32(streamVal, 8) | - ((*streamPtr) >> 8); + streamVal = (streamVal << 8) | (*streamPtr >> 8); streamData->full = 0; } } else { /* Intending to read outside the stream. This can happen for the last * two or three bytes. It is how the algorithm is implemented. Do * not read from the bit stream and insert zeros instead. */ - streamVal = WEBRTC_SPL_LSHIFT_W32(streamVal, 8); + streamVal <<= 8; if (streamData->full == 0) { offset++; // We would have incremented the pointer in this case. streamData->full = 1; @@ -396,7 +395,7 @@ int16_t WebRtcIsacfix_DecLogisticMulti2(int16_t *dataQ7, streamData->full = 0; } } - W_upper = WEBRTC_SPL_LSHIFT_W32(W_upper, 8); + W_upper <<= 8; } } envCount++; diff --git a/webrtc/modules/audio_coding/codecs/isac/fix/source/bandwidth_estimator.c b/webrtc/modules/audio_coding/codecs/isac/fix/source/bandwidth_estimator.c index 72e6d6c2c9..67b18331b3 100644 --- a/webrtc/modules/audio_coding/codecs/isac/fix/source/bandwidth_estimator.c +++ b/webrtc/modules/audio_coding/codecs/isac/fix/source/bandwidth_estimator.c @@ -259,7 +259,7 @@ int32_t WebRtcIsacfix_UpdateUplinkBwImpl(BwEstimatorstr *bweStr, /* Check send time difference between this packet and previous received */ sendTimeDiff = sendTime - bweStr->prevSendTime; - if (sendTimeDiff <= WEBRTC_SPL_LSHIFT_W32(frameSizeSampl, 1)) { + if (sendTimeDiff <= frameSizeSampl * 2) { /* Only update if 3 seconds has past since last update */ if ((arrivalTime - bweStr->lastUpdate) > FS3) { @@ -324,8 +324,7 @@ int32_t WebRtcIsacfix_UpdateUplinkBwImpl(BwEstimatorstr *bweStr, if (!(bweStr->highSpeedSend && bweStr->highSpeedRec)) { if (arrTimeDiff > frameSizeSampl) { if (sendTimeDiff > 0) { - lateDiff = arrTimeDiff - sendTimeDiff - - WEBRTC_SPL_LSHIFT_W32(frameSizeSampl, 1); + lateDiff = arrTimeDiff - sendTimeDiff - frameSizeSampl * 2; } else { lateDiff = arrTimeDiff - frameSizeSampl; } @@ -433,11 +432,11 @@ int32_t WebRtcIsacfix_UpdateUplinkBwImpl(BwEstimatorstr *bweStr, /* difference between projected and actual arrival time differences */ /* Q9 (only shift arrTimeDiff by 5 to simulate divide by 16 (need to revisit if change sampling rate) DH */ - if (WEBRTC_SPL_LSHIFT_W32(arrTimeDiff, 6) > (int32_t)arrTimeProj) { - arrTimeNoise = WEBRTC_SPL_LSHIFT_W32(arrTimeDiff, 6) - arrTimeProj; + if ((arrTimeDiff << 6) > (int32_t)arrTimeProj) { + arrTimeNoise = (arrTimeDiff << 6) - arrTimeProj; sign = 1; } else { - arrTimeNoise = arrTimeProj - WEBRTC_SPL_LSHIFT_W32(arrTimeDiff, 6); + arrTimeNoise = arrTimeProj - (arrTimeDiff << 6); sign = -1; } @@ -446,8 +445,8 @@ int32_t WebRtcIsacfix_UpdateUplinkBwImpl(BwEstimatorstr *bweStr, /* long term averaged absolute jitter, Q15 */ weight >>= 3; - bweStr->recJitter = WEBRTC_SPL_MUL(weight, WEBRTC_SPL_LSHIFT_W32(arrTimeNoiseAbs, 5)) - + WEBRTC_SPL_MUL(1024 - weight, bweStr->recJitter); + bweStr->recJitter = weight * (arrTimeNoiseAbs << 5) + + (1024 - weight) * bweStr->recJitter; /* remove the fractional portion */ bweStr->recJitter >>= 10; @@ -459,13 +458,13 @@ int32_t WebRtcIsacfix_UpdateUplinkBwImpl(BwEstimatorstr *bweStr, /* short term averaged absolute jitter */ /* Calculation in Q13 products in Q23 */ - bweStr->recJitterShortTermAbs = WEBRTC_SPL_MUL(51, WEBRTC_SPL_LSHIFT_W32(arrTimeNoiseAbs, 3)) + + bweStr->recJitterShortTermAbs = 51 * (arrTimeNoiseAbs << 3) + WEBRTC_SPL_MUL(973, bweStr->recJitterShortTermAbs); bweStr->recJitterShortTermAbs >>= 10; /* short term averaged jitter */ /* Calculation in Q13 products in Q23 */ - bweStr->recJitterShortTerm = WEBRTC_SPL_MUL(205, WEBRTC_SPL_LSHIFT_W32(arrTimeNoise, 3)) * sign + + bweStr->recJitterShortTerm = 205 * (arrTimeNoise << 3) * sign + WEBRTC_SPL_MUL(3891, bweStr->recJitterShortTerm); if (bweStr->recJitterShortTerm < 0) { @@ -557,7 +556,7 @@ int16_t WebRtcIsacfix_UpdateUplinkBwRec(BwEstimatorstr *bweStr, /* compute the jitter estimate as decoded on the other side in Q9 */ /* 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)); + 51 * (MAX_ISAC_MD << 9); bweStr->sendMaxDelayAvg >>= 9; } else { @@ -565,7 +564,7 @@ int16_t WebRtcIsacfix_UpdateUplinkBwRec(BwEstimatorstr *bweStr, /* compute the jitter estimate as decoded on the other side in Q9 */ /* 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)); + 51 * (MIN_ISAC_MD << 9); bweStr->sendMaxDelayAvg >>= 9; } @@ -648,7 +647,7 @@ uint16_t WebRtcIsacfix_GetDownlinkBwIndexImpl(BwEstimatorstr *bweStr) tempTermX = WEBRTC_SPL_UMUL(461, bweStr->recBwAvgQ) - tempTerm1; /* rate in Q16 */ - tempTermY = WEBRTC_SPL_LSHIFT_W32((int32_t)rate, 16); + tempTermY = rate << 16; /* 0.1 * kQRateTable[rateInd] = KQRate01[rateInd] */ tempTerm1 = tempTermX + KQRate01[rateInd] - tempTermY; @@ -690,7 +689,7 @@ uint16_t WebRtcIsacfix_GetDownlinkBwIndexImpl(BwEstimatorstr *bweStr) tempMax = 652800; /* MAX_ISAC_MD * 0.1 in Q18 */ tempMin = 130560; /* MIN_ISAC_MD * 0.1 in Q18 */ tempTermX = WEBRTC_SPL_MUL((int32_t)bweStr->recMaxDelayAvgQ, (int32_t)461); - tempTermY = WEBRTC_SPL_LSHIFT_W32((int32_t)maxDelay, 18); + tempTermY = maxDelay << 18; tempTerm1 = tempTermX + tempMax - tempTermY; tempTerm2 = tempTermY - tempTermX - tempMin; diff --git a/webrtc/modules/audio_coding/codecs/isac/fix/source/decode.c b/webrtc/modules/audio_coding/codecs/isac/fix/source/decode.c index fd1e292e1b..714a897cdb 100644 --- a/webrtc/modules/audio_coding/codecs/isac/fix/source/decode.c +++ b/webrtc/modules/audio_coding/codecs/isac/fix/source/decode.c @@ -191,7 +191,7 @@ int16_t WebRtcIsacfix_DecodeImpl(int16_t *signal_out16, /* --- Store Highpass Residual --- */ for (k = 0; k < FRAMESAMPLES/2; k++) - Vector_Word32_1[k] = WEBRTC_SPL_LSHIFT_W32(Vector_Word32_2[k], 9); // Q16 -> Q25 + Vector_Word32_1[k] = Vector_Word32_2[k] << 9; // Q16 -> Q25 for( k = 0; k < PITCH_MAX_LAG + 10; k++ ) (ISACdec_obj->plcstr_obj).prevHP[k] = Vector_Word32_1[FRAMESAMPLES/2 - (PITCH_MAX_LAG + 10) + k]; diff --git a/webrtc/modules/audio_coding/codecs/isac/fix/source/decode_plc.c b/webrtc/modules/audio_coding/codecs/isac/fix/source/decode_plc.c index fa11ad4ff8..4243ea3874 100644 --- a/webrtc/modules/audio_coding/codecs/isac/fix/source/decode_plc.c +++ b/webrtc/modules/audio_coding/codecs/isac/fix/source/decode_plc.c @@ -46,9 +46,7 @@ static int16_t plc_filterma_Fast( { int i, j; int32_t o; - int32_t lim; - - lim = WEBRTC_SPL_LSHIFT_W32( (int32_t)1, 15 + rshift )-1; + int32_t lim = (1 << (15 + rshift)) - 1; for (i = 0; i < len; i++) { @@ -517,8 +515,7 @@ int16_t WebRtcIsacfix_DecodePlcImpl(int16_t *signal_out16, (int16_t) (7) ); for( i = 0; i < FRAMESAMPLES_HALF; i++ ) - Vector_Word32_2[i] = WEBRTC_SPL_LSHIFT_W32( - (int32_t)Vector_Word16_Extended_2[i], rshift ); + Vector_Word32_2[i] = Vector_Word16_Extended_2[i] << rshift; Vector_Word16_1 = Vector_Word16_Extended_1; } diff --git a/webrtc/modules/audio_coding/codecs/isac/fix/source/entropy_coding.c b/webrtc/modules/audio_coding/codecs/isac/fix/source/entropy_coding.c index 3d347f8699..c150e60692 100644 --- a/webrtc/modules/audio_coding/codecs/isac/fix/source/entropy_coding.c +++ b/webrtc/modules/audio_coding/codecs/isac/fix/source/entropy_coding.c @@ -108,8 +108,8 @@ static int16_t CalcLogN(int32_t arg) { int16_t zeros, log2, frac, logN; zeros=WebRtcSpl_NormU32(arg); - frac=(int16_t)WEBRTC_SPL_RSHIFT_U32(WEBRTC_SPL_LSHIFT_W32(arg, zeros)&0x7FFFFFFF, 23); - log2=(int16_t)(WEBRTC_SPL_LSHIFT_W32(31-zeros, 8)+frac); // log2(x) in Q8 + frac = (int16_t)((uint32_t)((arg << zeros) & 0x7FFFFFFF) >> 23); + log2 = (int16_t)(((31 - zeros) << 8) + frac); // log2(x) in Q8 logN=(int16_t)WEBRTC_SPL_MUL_16_16_RSFT(log2,22713,15); //Q8*Q15 log(2) = 0.693147 = 22713 in Q15 logN=logN+11; //Scalar compensation which minimizes the (log(x)-logN(x))^2 error over all x. @@ -138,10 +138,10 @@ static int32_t CalcExpN(int16_t x) { ax=(int16_t)WEBRTC_SPL_MUL_16_16_RSFT(x, 23637, 14); //Q8 axINT = ax >> 8; //Q0 axFRAC = ax&0x00FF; - exp16 = WEBRTC_SPL_LSHIFT_W32(1, axINT); //Q0 + exp16 = 1 << axINT; // Q0 axFRAC = axFRAC+256; //Q8 exp = exp16 * axFRAC; // Q0*Q8 = Q8 - exp = WEBRTC_SPL_LSHIFT_W32(exp, 9); //Q17 + exp <<= 9; // Q17 } else { // ax=(int16_t)WEBRTC_SPL_MUL_16_16_RSFT(x, 23637+700, 14); //Q8 ax=(int16_t)WEBRTC_SPL_MUL_16_16_RSFT(x, 23637, 14); //Q8 @@ -228,7 +228,7 @@ static void CalcInvArSpec(const int16_t *ARCoefQ12, sum >>= 15; CorrQ11[k] = (sum * tmpGain + round) >> shftVal; } - sum = WEBRTC_SPL_LSHIFT_W32(CorrQ11[0], 7); + sum = CorrQ11[0] << 7; for (n = 0; n < FRAMESAMPLES/8; n++) CurveQ16[n] = sum; @@ -258,8 +258,9 @@ static void CalcInvArSpec(const int16_t *ARCoefQ12, } for (k=0; k>= 15; CorrQ11[k] = (sum * tmpGain + round) >> shftVal; } - sum = WEBRTC_SPL_LSHIFT_W32(CorrQ11[0], 7); + sum = CorrQ11[0] << 7; for (n = 0; n < FRAMESAMPLES/8; n++) summQ16[n] = sum; @@ -330,14 +331,14 @@ static void CalcRootInvArSpec(const int16_t *ARCoefQ12, diffQ16[n] += (CS_ptrQ9[n] * (CorrQ11[k + 1] >> shftVal) + 2) >> 2; } - in_sqrt = summQ16[0] + WEBRTC_SPL_LSHIFT_W32(diffQ16[0], shftVal); + in_sqrt = summQ16[0] + (diffQ16[0] << shftVal); /* convert to magnitude spectrum, by doing square-roots (modified from SPLIB) */ res = 1 << (WebRtcSpl_GetSizeInBits(in_sqrt) >> 1); for (k = 0; k < FRAMESAMPLES/8; k++) { - in_sqrt = summQ16[k] + WEBRTC_SPL_LSHIFT_W32(diffQ16[k], shftVal); + in_sqrt = summQ16[k] + (diffQ16[k] << shftVal); i = 10; /* make in_sqrt positive to prohibit sqrt of negative values */ @@ -355,7 +356,8 @@ static void CalcRootInvArSpec(const int16_t *ARCoefQ12, } for (k = FRAMESAMPLES/8; k < FRAMESAMPLES/4; k++) { - in_sqrt = summQ16[FRAMESAMPLES/4-1 - k] - WEBRTC_SPL_LSHIFT_W32(diffQ16[FRAMESAMPLES/4-1 - k], shftVal); + in_sqrt = summQ16[FRAMESAMPLES / 4 - 1 - k] - + (diffQ16[FRAMESAMPLES / 4 - 1 - k] << shftVal); i = 10; /* make in_sqrt positive to prohibit sqrt of negative values */ @@ -493,8 +495,8 @@ int16_t WebRtcIsacfix_DecodeSpec(Bitstr_dec *streamdata, { for (k = 0; k < FRAMESAMPLES; k += 4) { - 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)); + gainQ10 = WebRtcSpl_DivW32W16ResW16(30 << 10, + (int16_t)((uint32_t)(invARSpec2_Q16[k >> 2] + 2195456) >> 16)); *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); @@ -505,8 +507,8 @@ int16_t WebRtcIsacfix_DecodeSpec(Bitstr_dec *streamdata, { for (k = 0; k < FRAMESAMPLES; k += 4) { - 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)); + gainQ10 = WebRtcSpl_DivW32W16ResW16(36 << 10, + (int16_t)((uint32_t)(invARSpec2_Q16[k >> 2] + 2654208) >> 16)); *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); @@ -575,7 +577,7 @@ int WebRtcIsacfix_EncodeSpec(const int16_t *fr, if (lft_shft > 0) { for (k=0; k> -lft_shft; @@ -607,7 +609,7 @@ int WebRtcIsacfix_EncodeSpec(const int16_t *fr, if (lft_shft > 0) nrg >>= lft_shft; else - nrg = WEBRTC_SPL_LSHIFT_W32(nrg, -lft_shft); + nrg <<= -lft_shft; if(nrg>131072) gain2_Q10 = WebRtcSpl_DivResultInQ31(FRAMESAMPLES >> 2, nrg); /* also shifts 31 bits to the left! */ @@ -1041,7 +1043,8 @@ int WebRtcIsacfix_DecodeLpcCoef(Bitstr_dec *streamdata, /* hi band LAR coeffs */ for (n=0; n>16)<<3 = Q17, with 1/0.45 = 2.222222222222 ~= 18204 in Q13 + // ((Q13*Q17)>>16)<<3 = Q17, with 1/0.45 = 2.222222222222 ~= 18204 in Q13 + tmp32 = WEBRTC_SPL_MUL_16_32_RSFT16(18204, tmpcoeffs_sQ17[poss]) << 3; tmp32 = tmp32 + WebRtcIsacfix_kMeansShapeQ17[model][poss]; // Q17+Q17 = Q17 LPCCoefQ17[pos] = tmp32; } @@ -1269,7 +1272,8 @@ static int EstCodeLpcCoef(int32_t *LPCCoefQ17, /* hi band LAR coeffs */ for (n=0; n>16)<<3 = Q17, with 1/0.45 = 2.222222222222 ~= 18204 in Q13 + // ((Q13*Q17)>>16)<<3 = Q17, with 1/0.45 = 2.222222222222 ~= 18204 in Q13 + tmp32 = WEBRTC_SPL_MUL_16_32_RSFT16(18204, tmpcoeffs_sQ17[poss]) << 3; tmp32 = tmp32 + WebRtcIsacfix_kMeansShapeQ17[0][poss]; // Q17+Q17 = Q17 LPCCoefQ17[pos] = tmp32; } @@ -1294,14 +1298,14 @@ static int EstCodeLpcCoef(int32_t *LPCCoefQ17, tmpcoeffs_gQ17[offsg]) << 1); sumQQ += (WEBRTC_SPL_MUL_16_32_RSFT16(WebRtcIsacfix_kT1GainQ15[0][1], tmpcoeffs_gQ17[offsg + 1]) << 1); - tmpcoeffs2_gQ21[posg] = WEBRTC_SPL_LSHIFT_W32(sumQQ, 4); + tmpcoeffs2_gQ21[posg] = sumQQ << 4; posg++; sumQQ = (WEBRTC_SPL_MUL_16_32_RSFT16(WebRtcIsacfix_kT1GainQ15[0][2], tmpcoeffs_gQ17[offsg]) << 1); sumQQ += (WEBRTC_SPL_MUL_16_32_RSFT16(WebRtcIsacfix_kT1GainQ15[0][3], tmpcoeffs_gQ17[offsg + 1]) << 1); - tmpcoeffs2_gQ21[posg] = WEBRTC_SPL_LSHIFT_W32(sumQQ, 4); + tmpcoeffs2_gQ21[posg] = sumQQ << 4; posg++; offsg += 2; } diff --git a/webrtc/modules/audio_coding/codecs/isac/fix/source/filterbanks.c b/webrtc/modules/audio_coding/codecs/isac/fix/source/filterbanks.c index 68d51b9fae..b5d91d4219 100644 --- a/webrtc/modules/audio_coding/codecs/isac/fix/source/filterbanks.c +++ b/webrtc/modules/audio_coding/codecs/isac/fix/source/filterbanks.c @@ -144,11 +144,11 @@ void WebRtcIsacfix_HighpassFilterFixDec32C(int16_t *io, 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. + c = (in << 2) - a2 - b2; // In Q2. c = (int32_t)WEBRTC_SPL_SAT(536870911, c, -536870912); state1 = state0; - state0 = WEBRTC_SPL_LSHIFT_W32(c, 2); // Write state as Q4 + state0 = c << 2; // Write state as Q4 } state[0] = state0; state[1] = state1; diff --git a/webrtc/modules/audio_coding/codecs/isac/fix/source/filters.c b/webrtc/modules/audio_coding/codecs/isac/fix/source/filters.c index aa91792379..21e49830a1 100644 --- a/webrtc/modules/audio_coding/codecs/isac/fix/source/filters.c +++ b/webrtc/modules/audio_coding/codecs/isac/fix/source/filters.c @@ -74,13 +74,12 @@ static void AllpassFilterForDec32(int16_t *InOut16, //Q0 for (j=0; j Q16 + a <<= 1; // Q15 -> Q16 b = WebRtcSpl_AddSatW32(a, FilterState[j]); //Q16+Q16=Q16 // |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 + // FilterState[j]: Q15<<1 + Q0<<16 = Q16 + Q16 = Q16 + FilterState[j] = WebRtcSpl_AddSatW32(a << 1, (uint32_t)InOut16[n] << 16); InOut16[n] = (int16_t)(b >> 16); // Save as Q0. } } @@ -101,7 +100,7 @@ void WebRtcIsacfix_DecimateAllpass32(const int16_t *in, memcpy(data_vec + 1, in, sizeof(int16_t) * (N - 1)); data_vec[0] = (int16_t)(state_in[2 * ALLPASSSECTIONS] >> 16); // z^-1 state. - state_in[2 * ALLPASSSECTIONS] = WEBRTC_SPL_LSHIFT_W32((uint32_t)in[N-1],16); + state_in[2 * ALLPASSSECTIONS] = (uint32_t)in[N - 1] << 16; diff --git a/webrtc/modules/audio_coding/codecs/isac/fix/source/lattice.c b/webrtc/modules/audio_coding/codecs/isac/fix/source/lattice.c index 6f9eec7735..cfd9a9eb73 100644 --- a/webrtc/modules/audio_coding/codecs/isac/fix/source/lattice.c +++ b/webrtc/modules/audio_coding/codecs/isac/fix/source/lattice.c @@ -129,7 +129,7 @@ void WebRtcIsacfix_NormLatticeFilterMa(int16_t orderCoef, /* compute the gain */ gain32 = gain_lo_hiQ17[temp3]; gain_sh = WebRtcSpl_NormW32(gain32); - gain32 = WEBRTC_SPL_LSHIFT_W32(gain32, gain_sh); //Q(17+gain_sh) + gain32 <<= gain_sh; // Q(17+gain_sh) for (k=0;k> 16); - t16b = (int16_t) (tmp32-WEBRTC_SPL_LSHIFT_W32(((int32_t)t16a), 16)); + t16b = (int16_t)(tmp32 - (t16a << 16)); if (t16b<0) t16a++; tmp32 = LATTICE_MUL_32_32_RSFT16(t16a, t16b, tmp32b); fQtmp = tmp32; // Q15 @@ -256,7 +256,7 @@ void WebRtcIsacfix_NormLatticeFilterAr(int16_t orderCoef, saturation. Therefore, it should be safe to use Q27 instead of Q17. */ - tmp32 = WEBRTC_SPL_LSHIFT_W32(gain_lo_hiQ17[temp3], 10); // Q27 + tmp32 = gain_lo_hiQ17[temp3] << 10; // Q27 for (k=0;k>15 = Q27 @@ -272,7 +272,7 @@ void WebRtcIsacfix_NormLatticeFilterAr(int16_t orderCoef, for (i=0;iQ26 + tmp32 = lat_inQ25[i + temp1] << 1; // Q25->Q26 tmp32 = WEBRTC_SPL_MUL_16_32_RSFT16(inv_gain16, tmp32); //lat_in[]*inv_gain in (Q(18-sh)*Q26)>>16 = Q(28-sh) tmp32 = WEBRTC_SPL_SHIFT_W32(tmp32, -(28-sh)); // lat_in[]*inv_gain in Q0 diff --git a/webrtc/modules/audio_coding/codecs/isac/fix/source/lpc_masking_model.c b/webrtc/modules/audio_coding/codecs/isac/fix/source/lpc_masking_model.c index d3cc9fa09e..5ae951a9e3 100644 --- a/webrtc/modules/audio_coding/codecs/isac/fix/source/lpc_masking_model.c +++ b/webrtc/modules/audio_coding/codecs/isac/fix/source/lpc_masking_model.c @@ -43,8 +43,7 @@ void WebRtcSpl_AToK_JSK( 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) - - WEBRTC_SPL_LSHIFT_W32(k16[m] * a16[m - k + 1], 1); + tmp32b = (a16[k] << 16) - ((k16[m] * a16[m - k + 1]) << 1); tmp32[k] = WebRtcSpl_DivW32W16(tmp32b, tmp_inv_denum16); //Q27/Q15 = Q12 } @@ -54,7 +53,7 @@ void WebRtcSpl_AToK_JSK( } tmp32[m] = WEBRTC_SPL_SAT(4092, tmp32[m], -4092); - k16[m-1] = (int16_t) WEBRTC_SPL_LSHIFT_W32(tmp32[m], 3); //Q12<<3 => Q15 + k16[m - 1] = (int16_t)(tmp32[m] << 3); // Q12<<3 => Q15 } return; @@ -89,7 +88,7 @@ int16_t WebRtcSpl_LevinsonW32_JSK( norm = WebRtcSpl_NormW32(R[0]); for (i=order;i>=0;i--) { - temp1W32 = WEBRTC_SPL_LSHIFT_W32(R[i], norm); + temp1W32 = R[i] << norm; /* Put R in hi and low format */ R_hi[i] = (int16_t)(temp1W32 >> 16); R_low[i] = (int16_t)((temp1W32 - ((int32_t)R_hi[i] << 16)) >> 1); @@ -97,8 +96,7 @@ int16_t WebRtcSpl_LevinsonW32_JSK( /* K = A[1] = -R[1] / R[0] */ - temp2W32 = WEBRTC_SPL_LSHIFT_W32((int32_t)R_hi[1],16) + - WEBRTC_SPL_LSHIFT_W32((int32_t)R_low[1],1); /* R[1] in Q31 */ + temp2W32 = (R_hi[1] << 16) + (R_low[1] << 1); /* R[1] in Q31 */ temp3W32 = WEBRTC_SPL_ABS_W32(temp2W32); /* abs R[1] */ temp1W32 = WebRtcSpl_DivW32HiLow(temp3W32, R_hi[0], R_low[0]); /* abs(R[1])/R[0] in Q31 */ /* Put back the sign on R[1] */ @@ -137,7 +135,7 @@ int16_t WebRtcSpl_LevinsonW32_JSK( /* Normalize Alpha and put it in hi and low format */ Alpha_exp = WebRtcSpl_NormW32(temp1W32); - temp1W32 = WEBRTC_SPL_LSHIFT_W32(temp1W32, Alpha_exp); + temp1W32 <<= Alpha_exp; Alpha_hi = (int16_t)(temp1W32 >> 16); Alpha_low = (int16_t)((temp1W32 - ((int32_t)Alpha_hi<< 16)) >> 1); @@ -164,9 +162,8 @@ int16_t WebRtcSpl_LevinsonW32_JSK( ((R_low[j] * A_hi[i - j]) >> 15)) << 1); } - temp1W32 = WEBRTC_SPL_LSHIFT_W32(temp1W32, 4); - temp1W32 += (WEBRTC_SPL_LSHIFT_W32((int32_t)R_hi[i], 16) + - WEBRTC_SPL_LSHIFT_W32((int32_t)R_low[i], 1)); + temp1W32 <<= 4; + temp1W32 += (R_hi[i] << 16) + (R_low[i] << 1); /* K = -temp1W32 / Alpha */ temp2W32 = WEBRTC_SPL_ABS_W32(temp1W32); /* abs(temp1W32) */ @@ -180,7 +177,7 @@ int16_t WebRtcSpl_LevinsonW32_JSK( /* Use the Alpha shifts from earlier to denormalize */ norm = WebRtcSpl_NormW32(temp3W32); if ((Alpha_exp <= norm)||(temp3W32==0)) { - temp3W32 = WEBRTC_SPL_LSHIFT_W32(temp3W32, Alpha_exp); + temp3W32 <<= Alpha_exp; } else { if (temp3W32 > 0) { @@ -214,8 +211,7 @@ int16_t WebRtcSpl_LevinsonW32_JSK( for(j=1; j> 15) + ((K_low * A_hi[i - j]) >> 15)) << 1; // temp1W32 += K*A[i-j] in Q27. @@ -249,7 +245,7 @@ int16_t WebRtcSpl_LevinsonW32_JSK( /* Normalize Alpha and store it on hi and low format */ norm = WebRtcSpl_NormW32(temp1W32); - temp1W32 = WEBRTC_SPL_LSHIFT_W32(temp1W32, norm); + temp1W32 <<= norm; Alpha_hi = (int16_t)(temp1W32 >> 16); Alpha_low = (int16_t)((temp1W32 - ((int32_t)Alpha_hi << 16)) >> 1); @@ -275,8 +271,7 @@ int16_t WebRtcSpl_LevinsonW32_JSK( for(i=1; i<=order; i++) { /* temp1W32 in Q27 */ - temp1W32 = WEBRTC_SPL_LSHIFT_W32((int32_t)A_hi[i], 16) + - WEBRTC_SPL_LSHIFT_W32((int32_t)A_low[i], 1); + temp1W32 = (A_hi[i] << 16) + (A_low[i] << 1); /* Round and store upper word */ A[i] = (int16_t)((temp1W32 + 32768) >> 16); } @@ -650,7 +645,7 @@ void WebRtcIsacfix_GetLpcCoef(int16_t *inLoQ0, sh_lo = WebRtcSpl_NormW32(corrloQQ[0]); QdomLO += sh_lo; for (ii=0; ii> 23); /* log2(magn(i)) */ - lg2= (WEBRTC_SPL_LSHIFT_W32((31-zeros), 8)+frac); - return lg2; - + return ((31 - zeros) << 8) + frac; } static __inline int16_t Exp2Q10(int16_t x) { // Both in and out in Q10 @@ -182,7 +180,7 @@ void WebRtcIsacfix_InitialPitch(const int16_t *in, /* Q0 */ int32_t lagsQ8[4]; old_lagQ = State->PFstr_wght.oldlagQ7; // Q7 - old_lagQ8= WEBRTC_SPL_LSHIFT_W32((int32_t)old_lagQ,1); //Q8 + old_lagQ8 = old_lagQ << 1; // Q8 oldgQ12= State->PFstr_wght.oldgainQ12; @@ -302,7 +300,7 @@ void WebRtcIsacfix_InitialPitch(const int16_t *in, /* Q0 */ lag32 = peakiq[best4q[k]]; fxq = &cv1q[peakiq[best4q[k]]-1]; xq[0]= lag32; - xq[0] = WEBRTC_SPL_LSHIFT_W32(xq[0], 8); + xq[0] <<= 8; Intrp1DQ8(xq, fxq, yq, fyq); tmp32a= WebRtcIsacfix_Log2Q8((uint32_t) *yq) - 2048; // offset 8*2^8 @@ -316,8 +314,7 @@ void WebRtcIsacfix_InitialPitch(const int16_t *in, /* Q0 */ best_lag1q = *yq; } } - tmp32a = best_lag1q - OFFSET_Q8; - tmp32b = WEBRTC_SPL_LSHIFT_W32(tmp32a, 1); + tmp32b = (best_lag1q - OFFSET_Q8) * 2; lagsQ8[0] = tmp32b + PITCH_MIN_LAG_Q8; lagsQ8[1] = lagsQ8[0]; } else { @@ -331,8 +328,8 @@ void WebRtcIsacfix_InitialPitch(const int16_t *in, /* Q0 */ for (k = 1; k <= PITCH_LAG_SPAN2; k++) { - tmp32a = WEBRTC_SPL_LSHIFT_W32(k, 7); // 0.5*k Q8 - tmp32b = (int32_t) (WEBRTC_SPL_LSHIFT_W32(tmp32a, 1)) - ratq; // Q8 + tmp32a = k << 7; // 0.5*k Q8 + tmp32b = tmp32a * 2 - ratq; // Q8 tmp32c = WEBRTC_SPL_MUL_16_16_RSFT((int16_t) tmp32b, (int16_t) tmp32b, 8); // Q8 tmp32b = tmp32c + (ratq >> 1); @@ -377,7 +374,7 @@ void WebRtcIsacfix_InitialPitch(const int16_t *in, /* Q0 */ fxq = &cv2q[peakiq[best4q[k]]-1]; xq[0]= lag32; - xq[0] = WEBRTC_SPL_LSHIFT_W32(xq[0], 8); + xq[0] <<= 8; Intrp1DQ8(xq, fxq, yq, fyq); /* Bias towards short lags */ @@ -392,8 +389,7 @@ void WebRtcIsacfix_InitialPitch(const int16_t *in, /* Q0 */ } } - tmp32a = best_lag2q - OFFSET_Q8; - tmp32b = WEBRTC_SPL_LSHIFT_W32(tmp32a, 1); + tmp32b = (best_lag2q - OFFSET_Q8) * 2; lagsQ8[2] = tmp32b + PITCH_MIN_LAG_Q8; lagsQ8[3] = lagsQ8[2]; } else { diff --git a/webrtc/modules/audio_coding/codecs/isac/fix/source/pitch_estimator_c.c b/webrtc/modules/audio_coding/codecs/isac/fix/source/pitch_estimator_c.c index b3f9f2f418..7ba7b69daa 100644 --- a/webrtc/modules/audio_coding/codecs/isac/fix/source/pitch_estimator_c.c +++ b/webrtc/modules/audio_coding/codecs/isac/fix/source/pitch_estimator_c.c @@ -22,12 +22,10 @@ extern int32_t WebRtcIsacfix_Log2Q8(uint32_t x); void WebRtcIsacfix_PCorr2Q32(const int16_t* in, int32_t* logcorQ8) { int16_t scaling,n,k; int32_t ysum32,csum32, lys, lcs; - int32_t oneQ8; + const int32_t oneQ8 = 1 << 8; // 1.00 in Q8 const int16_t* x; const int16_t* inptr; - oneQ8 = WEBRTC_SPL_LSHIFT_W32((int32_t)1, 8); // 1.00 in Q8 - x = in + PITCH_MAX_LAG / 2 + 2; scaling = WebRtcSpl_GetScalingSquare((int16_t*)in, PITCH_CORR_LEN2, diff --git a/webrtc/modules/audio_coding/codecs/isac/fix/source/pitch_estimator_mips.c b/webrtc/modules/audio_coding/codecs/isac/fix/source/pitch_estimator_mips.c index 2ce48887f1..f5e7e7fb9d 100644 --- a/webrtc/modules/audio_coding/codecs/isac/fix/source/pitch_estimator_mips.c +++ b/webrtc/modules/audio_coding/codecs/isac/fix/source/pitch_estimator_mips.c @@ -17,11 +17,10 @@ extern int32_t WebRtcIsacfix_Log2Q8(uint32_t x); void WebRtcIsacfix_PCorr2Q32(const int16_t* in, int32_t* logcorQ8) { int16_t scaling,n,k; int32_t ysum32,csum32, lys, lcs; - int32_t oneQ8; + const int32_t oneQ8 = 1 << 8; // 1.00 in Q8 const int16_t* x; const int16_t* inptr; - oneQ8 = WEBRTC_SPL_LSHIFT_W32((int32_t)1, 8); // 1.00 in Q8 x = in + PITCH_MAX_LAG / 2 + 2; scaling = WebRtcSpl_GetScalingSquare((int16_t*)in, PITCH_CORR_LEN2, diff --git a/webrtc/modules/audio_coding/codecs/isac/fix/source/pitch_filter.c b/webrtc/modules/audio_coding/codecs/isac/fix/source/pitch_filter.c index 472b54d332..06471beb33 100644 --- a/webrtc/modules/audio_coding/codecs/isac/fix/source/pitch_filter.c +++ b/webrtc/modules/audio_coding/codecs/isac/fix/source/pitch_filter.c @@ -49,13 +49,9 @@ void WebRtcIsacfix_PitchFilterCore(int loopNumber, static __inline int32_t CalcLrIntQ(int32_t fixVal, int16_t qDomain) { - int32_t intgr; - int32_t roundVal; + int32_t roundVal = 1 << (qDomain - 1); - roundVal = WEBRTC_SPL_LSHIFT_W32((int32_t)1, qDomain - 1); - intgr = (fixVal + roundVal) >> qDomain; - - return intgr; + return (fixVal + roundVal) >> qDomain; } void WebRtcIsacfix_PitchFilter(int16_t* indatQQ, // Q10 if type is 1 or 4, @@ -130,8 +126,7 @@ void WebRtcIsacfix_PitchFilter(int16_t* indatQQ, // Q10 if type is 1 or 4, curGainQ12 += gaindeltaQ12; curLagQ7 += lagdeltaQ7; indW32 = CalcLrIntQ(curLagQ7, 7); - tmpW32 = WEBRTC_SPL_LSHIFT_W32(indW32, 7); - tmpW32 -= curLagQ7; + tmpW32 = (indW32 << 7) - curLagQ7; frcQQ = (tmpW32 >> 4) + 4; if (frcQQ == PITCH_FRACS) { diff --git a/webrtc/modules/audio_coding/codecs/isac/fix/source/transform.c b/webrtc/modules/audio_coding/codecs/isac/fix/source/transform.c index e675e15f78..621f921013 100644 --- a/webrtc/modules/audio_coding/codecs/isac/fix/source/transform.c +++ b/webrtc/modules/audio_coding/codecs/isac/fix/source/transform.c @@ -66,11 +66,11 @@ void WebRtcIsacfix_Time2SpecC(int16_t *inre1Q9, //"Fastest" vectors if (sh>=0) { for (k=0; k> -sh); // Q(16+sh) inre2Q9[k] = (int16_t)((tmpimQ16[k] + round) >> -sh); // Q(16+sh) @@ -88,8 +88,8 @@ void WebRtcIsacfix_Time2SpecC(int16_t *inre1Q9, } } else { for (k=0; k Q16 - tmpimQ16[k] = WEBRTC_SPL_LSHIFT_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 } } @@ -132,10 +132,10 @@ void WebRtcIsacfix_Spec2TimeC(int16_t *inreQ7, int16_t *inimQ7, int32_t *outre1Q tmp1rQ14 = -WebRtcIsacfix_kSinTab2[FRAMESAMPLES/4 - 1 - k]; tmp1iQ14 = WebRtcIsacfix_kSinTab2[k]; - tmpInRe = WEBRTC_SPL_LSHIFT_W32((int32_t) inreQ7[k], 9); // Q7 -> Q16 - tmpInIm = WEBRTC_SPL_LSHIFT_W32((int32_t) inimQ7[k], 9); // Q7 -> Q16 - tmpInRe2 = WEBRTC_SPL_LSHIFT_W32((int32_t) inreQ7[FRAMESAMPLES/2 - 1 - k], 9); // Q7 -> Q16 - tmpInIm2 = WEBRTC_SPL_LSHIFT_W32((int32_t) inimQ7[FRAMESAMPLES/2 - 1 - k], 9); // Q7 -> Q16 + tmpInRe = inreQ7[k] << 9; // Q7 -> Q16 + tmpInIm = inimQ7[k] << 9; // Q7 -> Q16 + tmpInRe2 = inreQ7[FRAMESAMPLES / 2 - 1 - k] << 9; // Q7 -> Q16 + tmpInIm2 = inimQ7[FRAMESAMPLES / 2 - 1 - k] << 9; // Q7 -> Q16 xrQ16 = WEBRTC_SPL_MUL_16_32_RSFT14(tmp1rQ14, tmpInRe) + WEBRTC_SPL_MUL_16_32_RSFT14(tmp1iQ14, tmpInIm); xiQ16 = WEBRTC_SPL_MUL_16_32_RSFT14(tmp1rQ14, tmpInIm) - WEBRTC_SPL_MUL_16_32_RSFT14(tmp1iQ14, tmpInRe); @@ -163,11 +163,11 @@ void WebRtcIsacfix_Spec2TimeC(int16_t *inreQ7, int16_t *inimQ7, int32_t *outre1Q //"Fastest" vectors if (sh>=0) { for (k=0; k<240; k++) { - inreQ7[k] = (int16_t) WEBRTC_SPL_LSHIFT_W32(outre1Q16[k], sh); //Q(16+sh) - inimQ7[k] = (int16_t) WEBRTC_SPL_LSHIFT_W32(outre2Q16[k], sh); //Q(16+sh) + inreQ7[k] = (int16_t)(outre1Q16[k] << sh); // Q(16+sh) + inimQ7[k] = (int16_t)(outre2Q16[k] << sh); // Q(16+sh) } } else { - int32_t round = WEBRTC_SPL_LSHIFT_W32((int32_t)1, -sh-1); + int32_t round = 1 << (-sh - 1); for (k=0; k<240; k++) { inreQ7[k] = (int16_t)((outre1Q16[k] + round) >> -sh); // Q(16+sh) inimQ7[k] = (int16_t)((outre2Q16[k] + round) >> -sh); // Q(16+sh) @@ -184,8 +184,8 @@ void WebRtcIsacfix_Spec2TimeC(int16_t *inreQ7, int16_t *inimQ7, int32_t *outre1Q } } else { for (k=0; k<240; k++) { - outre1Q16[k] = WEBRTC_SPL_LSHIFT_W32((int32_t)inreQ7[k], -sh); //Q(16+sh) -> Q16 - outre2Q16[k] = WEBRTC_SPL_LSHIFT_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 } }