common_audio: Removes macro WEBRTC_SPL_LSHIFT_U16

We should avoid macros in general (see style guide) and the shift ones are particular dangerous since they assume that the user apply a non-negative shift.

Related CL: https://webrtc-codereview.appspot.com/16669004

BUG=3348,3353
TESTED=trybots and manually on linux
R=turaj@webrtc.org

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

git-svn-id: http://webrtc.googlecode.com/svn/trunk@6444 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
bjornv@webrtc.org 2014-06-16 10:30:14 +00:00
parent eb16b811fb
commit 721f970cba
5 changed files with 20 additions and 16 deletions

View File

@ -123,7 +123,6 @@
#define WEBRTC_SPL_RSHIFT_W32(x, c) ((x) >> (c))
#define WEBRTC_SPL_LSHIFT_W32(x, c) ((x) << (c))
#define WEBRTC_SPL_LSHIFT_U16(x, c) ((uint16_t)(x) << (c))
#define WEBRTC_SPL_RSHIFT_U32(x, c) ((uint32_t)(x) >> (c))
#define WEBRTC_SPL_LSHIFT_U32(x, c) ((uint32_t)(x) << (c))

View File

@ -89,7 +89,6 @@ TEST_F(SplTest, MacroTest) {
EXPECT_EQ(8191, WEBRTC_SPL_RSHIFT_W32(a, 1));
EXPECT_EQ(32766, WEBRTC_SPL_LSHIFT_W32(a, 1));
EXPECT_EQ(32766, WEBRTC_SPL_LSHIFT_U16(a, 1));
EXPECT_EQ(8191u, WEBRTC_SPL_RSHIFT_U32(a, 1));
EXPECT_EQ(32766u, WEBRTC_SPL_LSHIFT_U32(a, 1));

View File

@ -15,18 +15,21 @@
*
*/
#include "arith_routins.h"
#include "bandwidth_estimator.h"
#include "codec.h"
#include "pitch_gain_tables.h"
#include "pitch_lag_tables.h"
#include "entropy_coding.h"
#include "lpc_tables.h"
#include "lpc_masking_model.h"
#include "pitch_estimator.h"
#include "structs.h"
#include "webrtc/modules/audio_coding/codecs/isac/fix/source/codec.h"
#include <assert.h>
#include <stdio.h>
#include "webrtc/modules/audio_coding/codecs/isac/fix/source/arith_routins.h"
#include "webrtc/modules/audio_coding/codecs/isac/fix/source/bandwidth_estimator.h"
#include "webrtc/modules/audio_coding/codecs/isac/fix/source/entropy_coding.h"
#include "webrtc/modules/audio_coding/codecs/isac/fix/source/lpc_masking_model.h"
#include "webrtc/modules/audio_coding/codecs/isac/fix/source/lpc_tables.h"
#include "webrtc/modules/audio_coding/codecs/isac/fix/source/pitch_estimator.h"
#include "webrtc/modules/audio_coding/codecs/isac/fix/source/pitch_gain_tables.h"
#include "webrtc/modules/audio_coding/codecs/isac/fix/source/pitch_lag_tables.h"
#include "webrtc/modules/audio_coding/codecs/isac/fix/source/structs.h"
int WebRtcIsacfix_EncodeImpl(int16_t *in,
ISACFIX_EncInst_t *ISACenc_obj,
@ -450,12 +453,14 @@ int WebRtcIsacfix_EncodeImpl(int16_t *in,
while (stream_length < MinBytes)
{
assert(stream_length >= 0);
if (stream_length & 0x0001){
ISACenc_obj->bitstr_seed = WEBRTC_SPL_RAND( ISACenc_obj->bitstr_seed );
ISACenc_obj->bitstr_obj.stream[ WEBRTC_SPL_RSHIFT_W16(stream_length, 1) ] |= (uint16_t)(ISACenc_obj->bitstr_seed & 0xFF);
} else {
ISACenc_obj->bitstr_seed = WEBRTC_SPL_RAND( ISACenc_obj->bitstr_seed );
ISACenc_obj->bitstr_obj.stream[ WEBRTC_SPL_RSHIFT_W16(stream_length, 1) ] = WEBRTC_SPL_LSHIFT_U16(ISACenc_obj->bitstr_seed, 8);
ISACenc_obj->bitstr_obj.stream[stream_length / 2] =
((uint16_t)ISACenc_obj->bitstr_seed << 8);
}
stream_length++;
}
@ -467,7 +472,8 @@ int WebRtcIsacfix_EncodeImpl(int16_t *in,
}
else {
ISACenc_obj->bitstr_obj.stream[usefulstr_len>>1] &= 0x00FF;
ISACenc_obj->bitstr_obj.stream[usefulstr_len>>1] += WEBRTC_SPL_LSHIFT_U16((MinBytes - usefulstr_len) & 0x00FF, 8);
ISACenc_obj->bitstr_obj.stream[usefulstr_len >> 1] +=
((uint16_t)((MinBytes - usefulstr_len) & 0x00FF) << 8);
}
}
else

View File

@ -773,7 +773,7 @@ int16_t WebRtcAgc_ProcessVad(AgcVad_t *state, // (i) VAD state
tmp16 = WEBRTC_SPL_LSHIFT_W16(3, 12);
tmp32 = WEBRTC_SPL_MUL_16_16(tmp16, (dB - state->meanLongTerm));
tmp32 = WebRtcSpl_DivW32W16(tmp32, state->stdLongTerm);
tmpU16 = WEBRTC_SPL_LSHIFT_U16((uint16_t)13, 12);
tmpU16 = (13 << 12);
tmp32b = WEBRTC_SPL_MUL_16_U16(state->logRatio, tmpU16);
tmp32 += WEBRTC_SPL_RSHIFT_W32(tmp32b, 10);

View File

@ -1407,7 +1407,7 @@ void WebRtcNsx_DataAnalysis(NsxInst_t* inst, short* speechFrame, uint16_t* magnU
tmpU32no1 = WEBRTC_SPL_RSHIFT_U32((uint32_t)sum_log_i_log_magn, 12); // Q5
// Shift the largest value of sum_log_i and tmp32no3 before multiplication
tmp_u16 = WEBRTC_SPL_LSHIFT_U16((uint16_t)sum_log_i, 1); // Q6
tmp_u16 = ((uint16_t)sum_log_i << 1); // Q6
if ((uint32_t)sum_log_i > tmpU32no1) {
tmp_u16 >>= zeros;
} else {