common_audio refactoring: Removed macro WEBRTC_SPL_LSHIFT_U32
The macro is a trivial shift operator including a cast before shift. There is no guard against negative shifts. Replaced with << at place and added casts when necessary. Affects both fixed and float point versions of iSAC BUG=3348,3353 TESTED=locally on linux and trybots R=kwiberg@webrtc.org, tina.legrand@webrtc.org Review URL: https://webrtc-codereview.appspot.com/27369004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7320 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
24f62e1a28
commit
7c15510f38
@ -95,7 +95,6 @@
|
||||
#define WEBRTC_SPL_LSHIFT_W32(x, c) ((x) << (c))
|
||||
|
||||
#define WEBRTC_SPL_RSHIFT_U32(x, c) ((uint32_t)(x) >> (c))
|
||||
#define WEBRTC_SPL_LSHIFT_U32(x, c) ((uint32_t)(x) << (c))
|
||||
|
||||
#define WEBRTC_SPL_RAND(a) \
|
||||
((int16_t)(WEBRTC_SPL_MUL_16_16_RSFT((a), 18816, 7) & 0x00007fff))
|
||||
|
@ -72,7 +72,6 @@ TEST_F(SplTest, MacroTest) {
|
||||
EXPECT_EQ(32766, WEBRTC_SPL_LSHIFT_W32(a, 1));
|
||||
|
||||
EXPECT_EQ(8191u, WEBRTC_SPL_RSHIFT_U32(a, 1));
|
||||
EXPECT_EQ(32766u, WEBRTC_SPL_LSHIFT_U32(a, 1));
|
||||
|
||||
EXPECT_EQ(1470, WEBRTC_SPL_RAND(A));
|
||||
|
||||
|
@ -310,7 +310,7 @@ int16_t WebRtcIsacfix_DecHistOneStepMulti(int16_t *data,
|
||||
if (streamData->stream_index == 0)
|
||||
{
|
||||
/* read first word from bytestream */
|
||||
streamval = WEBRTC_SPL_LSHIFT_U32(*streamPtr++, 16);
|
||||
streamval = (uint32_t)(*streamPtr++) << 16;
|
||||
streamval |= *streamPtr++;
|
||||
} else {
|
||||
streamval = streamData->streamval;
|
||||
|
@ -184,21 +184,20 @@ int WebRtcIsacfix_EncLogisticMulti2(Bitstr_enc *streamData,
|
||||
* W_upper < 2^24 */
|
||||
while ( !(W_upper & 0xFF000000) )
|
||||
{
|
||||
W_upper = WEBRTC_SPL_LSHIFT_U32(W_upper, 8);
|
||||
W_upper <<= 8;
|
||||
if (streamData->full == 0) {
|
||||
*streamPtr++ += (uint16_t) WEBRTC_SPL_RSHIFT_U32(
|
||||
streamData->streamval, 24);
|
||||
streamData->full = 1;
|
||||
} else {
|
||||
*streamPtr = (uint16_t) WEBRTC_SPL_LSHIFT_U32(
|
||||
WEBRTC_SPL_RSHIFT_U32(streamData->streamval, 24), 8);
|
||||
*streamPtr = (uint16_t)((streamData->streamval >> 24) << 8);
|
||||
streamData->full = 0;
|
||||
}
|
||||
|
||||
if( streamPtr > maxStreamPtr )
|
||||
return -ISAC_DISALLOWED_BITSTREAM_LENGTH;
|
||||
|
||||
streamData->streamval = WEBRTC_SPL_LSHIFT_U32(streamData->streamval, 8);
|
||||
streamData->streamval <<= 8;
|
||||
}
|
||||
}
|
||||
|
||||
@ -257,7 +256,7 @@ int16_t WebRtcIsacfix_DecLogisticMulti2(int16_t *dataQ7,
|
||||
if (streamData->stream_index == 0)
|
||||
{
|
||||
/* read first word from bytestream */
|
||||
streamVal = WEBRTC_SPL_LSHIFT_U32(*streamPtr++, 16);
|
||||
streamVal = (uint32_t)(*streamPtr++) << 16;
|
||||
streamVal |= *streamPtr++;
|
||||
|
||||
} else {
|
||||
|
@ -523,9 +523,9 @@ int32_t WebRtcIsacfix_UpdateUplinkBwImpl(BwEstimatorstr *bweStr,
|
||||
bweStr->recBw = (int32_t) MIN_ISAC_BW;
|
||||
}
|
||||
|
||||
bweStr->recBwAvg = WEBRTC_SPL_LSHIFT_U32(bweStr->recBw + bweStr->recHeaderRate, 5);
|
||||
bweStr->recBwAvg = (bweStr->recBw + bweStr->recHeaderRate) << 5;
|
||||
|
||||
bweStr->recBwAvgQ = WEBRTC_SPL_LSHIFT_U32(bweStr->recBw, 7);
|
||||
bweStr->recBwAvgQ = bweStr->recBw << 7;
|
||||
|
||||
bweStr->recJitterShortTerm = 0;
|
||||
|
||||
@ -573,8 +573,8 @@ int16_t WebRtcIsacfix_UpdateUplinkBwRec(BwEstimatorstr *bweStr,
|
||||
|
||||
/* compute the BN estimate as decoded on the other side */
|
||||
/* sendBwAvg = 0.9 * sendBwAvg + 0.1 * kQRateTable[RateInd]; */
|
||||
bweStr->sendBwAvg = WEBRTC_SPL_UMUL(461, bweStr->sendBwAvg) +
|
||||
WEBRTC_SPL_UMUL(51, WEBRTC_SPL_LSHIFT_U32(kQRateTable[RateInd], 7));
|
||||
bweStr->sendBwAvg = 461 * bweStr->sendBwAvg +
|
||||
51 * ((uint32_t)kQRateTable[RateInd] << 7);
|
||||
bweStr->sendBwAvg = WEBRTC_SPL_RSHIFT_U32(bweStr->sendBwAvg, 9);
|
||||
|
||||
|
||||
@ -625,8 +625,8 @@ uint16_t WebRtcIsacfix_GetDownlinkBwIndexImpl(BwEstimatorstr *bweStr)
|
||||
/* Compute the averaged BN estimate on this side */
|
||||
|
||||
/* recBwAvg = 0.9 * recBwAvg + 0.1 * (rate + bweStr->recHeaderRate), 0.9 and 0.1 in Q9 */
|
||||
bweStr->recBwAvg = WEBRTC_SPL_UMUL(922, bweStr->recBwAvg) +
|
||||
WEBRTC_SPL_UMUL(102, WEBRTC_SPL_LSHIFT_U32((uint32_t)rate + bweStr->recHeaderRate, 5));
|
||||
bweStr->recBwAvg = 922 * bweStr->recBwAvg +
|
||||
102 * (((uint32_t)rate + bweStr->recHeaderRate) << 5);
|
||||
bweStr->recBwAvg = WEBRTC_SPL_RSHIFT_U32(bweStr->recBwAvg, 10);
|
||||
|
||||
/* Find quantization index that gives the closest rate after averaging.
|
||||
|
@ -102,7 +102,7 @@ int16_t WebRtcIsac_GetCrc(const int16_t* bitstream,
|
||||
for (byte_cntr = 0; byte_cntr < len_bitstream_in_bytes; byte_cntr++) {
|
||||
crc_tbl_indx = (WEBRTC_SPL_RSHIFT_U32(crc_state, 24) ^
|
||||
bitstream_ptr_uw8[byte_cntr]) & 0xFF;
|
||||
crc_state = WEBRTC_SPL_LSHIFT_U32(crc_state, 8) ^ kCrcTable[crc_tbl_indx];
|
||||
crc_state = (crc_state << 8) ^ kCrcTable[crc_tbl_indx];
|
||||
}
|
||||
|
||||
*crc = ~crc_state;
|
||||
|
Loading…
x
Reference in New Issue
Block a user