common_audio: Removes macro WEBRTC_SPL_SHIFT_W16
We should avoid macros in general (see style guide). This shift macro is not a severe one, since there is a check for negativity. BUG=3348,3353 TESTED=trybots and manually R=kwiberg@webrtc.org Review URL: https://webrtc-codereview.appspot.com/15799004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@6591 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
38214d53db
commit
c0ba4392f1
@ -111,8 +111,6 @@
|
||||
|
||||
// Shifting with negative numbers allowed
|
||||
// Positive means left shift
|
||||
#define WEBRTC_SPL_SHIFT_W16(x, c) \
|
||||
(((c) >= 0) ? ((x) << (c)) : ((x) >> (-(c))))
|
||||
#define WEBRTC_SPL_SHIFT_W32(x, c) \
|
||||
(((c) >= 0) ? ((x) << (c)) : ((x) >> (-(c))))
|
||||
|
||||
|
@ -79,7 +79,6 @@ TEST_F(SplTest, MacroTest) {
|
||||
// Shifting with negative numbers allowed
|
||||
int shift_amount = 1; // Workaround compiler warning using variable here.
|
||||
// Positive means left shift
|
||||
EXPECT_EQ(32766, WEBRTC_SPL_SHIFT_W16(a, shift_amount));
|
||||
EXPECT_EQ(32766, WEBRTC_SPL_SHIFT_W32(a, shift_amount));
|
||||
|
||||
// Shifting with negative numbers not allowed
|
||||
|
@ -328,7 +328,7 @@ int WebRtcAecm_ProcessBlock(AecmCore_t * aecm,
|
||||
int16_t zeros32, zeros16;
|
||||
int16_t zerosDBufNoisy, zerosDBufClean, zerosXBuf;
|
||||
int far_q;
|
||||
int16_t resolutionDiff, qDomainDiff;
|
||||
int16_t resolutionDiff, qDomainDiff, dfa_clean_q_domain_diff;
|
||||
|
||||
const int kMinPrefBand = 4;
|
||||
const int kMaxPrefBand = 24;
|
||||
@ -499,29 +499,28 @@ int WebRtcAecm_ProcessBlock(AecmCore_t * aecm,
|
||||
}
|
||||
|
||||
zeros16 = WebRtcSpl_NormW16(aecm->nearFilt[i]);
|
||||
if ((zeros16 < (aecm->dfaCleanQDomain - aecm->dfaCleanQDomainOld))
|
||||
& (aecm->nearFilt[i]))
|
||||
{
|
||||
tmp16no1 = WEBRTC_SPL_SHIFT_W16(aecm->nearFilt[i], zeros16);
|
||||
qDomainDiff = zeros16 - aecm->dfaCleanQDomain + aecm->dfaCleanQDomainOld;
|
||||
} else
|
||||
{
|
||||
tmp16no1 = WEBRTC_SPL_SHIFT_W16(aecm->nearFilt[i],
|
||||
aecm->dfaCleanQDomain -
|
||||
aecm->dfaCleanQDomainOld);
|
||||
assert(zeros16 >= 0); // |zeros16| is a norm, hence non-negative.
|
||||
dfa_clean_q_domain_diff = aecm->dfaCleanQDomain - aecm->dfaCleanQDomainOld;
|
||||
if (zeros16 < dfa_clean_q_domain_diff && aecm->nearFilt[i]) {
|
||||
tmp16no1 = aecm->nearFilt[i] << zeros16;
|
||||
qDomainDiff = zeros16 - dfa_clean_q_domain_diff;
|
||||
tmp16no2 = ptrDfaClean[i] >> -qDomainDiff;
|
||||
} else {
|
||||
tmp16no1 = dfa_clean_q_domain_diff < 0
|
||||
? aecm->nearFilt[i] >> -dfa_clean_q_domain_diff
|
||||
: aecm->nearFilt[i] << dfa_clean_q_domain_diff;
|
||||
qDomainDiff = 0;
|
||||
tmp16no2 = ptrDfaClean[i];
|
||||
}
|
||||
tmp16no2 = WEBRTC_SPL_SHIFT_W16(ptrDfaClean[i], qDomainDiff);
|
||||
tmp32no1 = (int32_t)(tmp16no2 - tmp16no1);
|
||||
tmp16no2 = (int16_t)WEBRTC_SPL_RSHIFT_W32(tmp32no1, 4);
|
||||
tmp16no2 += tmp16no1;
|
||||
zeros16 = WebRtcSpl_NormW16(tmp16no2);
|
||||
if ((tmp16no2) & (-qDomainDiff > zeros16))
|
||||
{
|
||||
if ((tmp16no2) & (-qDomainDiff > zeros16)) {
|
||||
aecm->nearFilt[i] = WEBRTC_SPL_WORD16_MAX;
|
||||
} else
|
||||
{
|
||||
aecm->nearFilt[i] = WEBRTC_SPL_SHIFT_W16(tmp16no2, -qDomainDiff);
|
||||
} else {
|
||||
aecm->nearFilt[i] = qDomainDiff < 0 ? tmp16no2 << -qDomainDiff
|
||||
: tmp16no2 >> qDomainDiff;
|
||||
}
|
||||
|
||||
// Wiener filter coefficients, resulting hnl in Q14
|
||||
|
@ -836,7 +836,7 @@ int WebRtcAecm_ProcessBlock(AecmCore_t* aecm,
|
||||
int16_t zeros32, zeros16;
|
||||
int16_t zerosDBufNoisy, zerosDBufClean, zerosXBuf;
|
||||
int far_q;
|
||||
int16_t resolutionDiff, qDomainDiff;
|
||||
int16_t resolutionDiff, qDomainDiff, dfa_clean_q_domain_diff;
|
||||
|
||||
const int kMinPrefBand = 4;
|
||||
const int kMaxPrefBand = 24;
|
||||
@ -1002,15 +1002,16 @@ int WebRtcAecm_ProcessBlock(AecmCore_t* aecm,
|
||||
}
|
||||
|
||||
zeros16 = WebRtcSpl_NormW16(aecm->nearFilt[i]);
|
||||
if ((zeros16 < (aecm->dfaCleanQDomain - aecm->dfaCleanQDomainOld))
|
||||
& (aecm->nearFilt[i])) {
|
||||
tmp16no1 = WEBRTC_SPL_SHIFT_W16(aecm->nearFilt[i], zeros16);
|
||||
qDomainDiff = zeros16 - aecm->dfaCleanQDomain + aecm->dfaCleanQDomainOld;
|
||||
tmp16no2 = WEBRTC_SPL_SHIFT_W16(ptrDfaClean[i], qDomainDiff);
|
||||
assert(zeros16 >= 0); // |zeros16| is a norm, hence non-negative.
|
||||
dfa_clean_q_domain_diff = aecm->dfaCleanQDomain - aecm->dfaCleanQDomainOld;
|
||||
if (zeros16 < dfa_clean_q_domain_diff && aecm->nearFilt[i]) {
|
||||
tmp16no1 = aecm->nearFilt[i] << zeros16;
|
||||
qDomainDiff = zeros16 - dfa_clean_q_domain_diff;
|
||||
tmp16no2 = ptrDfaClean[i] >> -qDomainDiff;
|
||||
} else {
|
||||
tmp16no1 = WEBRTC_SPL_SHIFT_W16(aecm->nearFilt[i],
|
||||
aecm->dfaCleanQDomain
|
||||
- aecm->dfaCleanQDomainOld);
|
||||
tmp16no1 = dfa_clean_q_domain_diff < 0
|
||||
? aecm->nearFilt[i] >> -dfa_clean_q_domain_diff
|
||||
: aecm->nearFilt[i] << dfa_clean_q_domain_diff;
|
||||
qDomainDiff = 0;
|
||||
tmp16no2 = ptrDfaClean[i];
|
||||
}
|
||||
@ -1022,7 +1023,8 @@ int WebRtcAecm_ProcessBlock(AecmCore_t* aecm,
|
||||
if ((tmp16no2) & (-qDomainDiff > zeros16)) {
|
||||
aecm->nearFilt[i] = WEBRTC_SPL_WORD16_MAX;
|
||||
} else {
|
||||
aecm->nearFilt[i] = WEBRTC_SPL_SHIFT_W16(tmp16no2, -qDomainDiff);
|
||||
aecm->nearFilt[i] = qDomainDiff < 0 ? tmp16no2 << -qDomainDiff
|
||||
: tmp16no2 >> qDomainDiff;
|
||||
}
|
||||
|
||||
// Wiener filter coefficients, resulting hnl in Q14
|
||||
|
Loading…
x
Reference in New Issue
Block a user