Fixed a bug in Coverity (fileInstanceId=1323160).
Review URL: https://webrtc-codereview.appspot.com/724007 git-svn-id: http://webrtc.googlecode.com/svn/trunk@2616 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
28655423fd
commit
620a2563d0
@ -519,9 +519,9 @@ int32_t WebRtcIsacfix_CalculateResidualEnergy(int lpc_order,
|
||||
shift_norm = 32 - WebRtcSpl_NormW32(word32_high);
|
||||
residual_energy = (int32_t)(sum64 >> shift_norm);
|
||||
} else {
|
||||
if((word32_low & 0x80000000) == 1) {
|
||||
if((word32_low & 0x80000000) != 0) {
|
||||
shift_norm = 1;
|
||||
residual_energy = word32_low >> 1;
|
||||
residual_energy = (uint32_t)word32_low >> 1;
|
||||
} else {
|
||||
shift_norm = WebRtcSpl_NormW32(word32_low);
|
||||
residual_energy = word32_low << shift_norm;
|
||||
|
@ -26,8 +26,29 @@ TEST_F(IsacUnitTest, CalculateResidualEnergyTest) {
|
||||
int q_shift_residual = 0;
|
||||
int32_t residual_energy = 0;
|
||||
|
||||
// Test the code path where (residual_energy >= 0x10000).
|
||||
residual_energy = WebRtcIsacfix_CalculateResidualEnergy(kIntOrder,
|
||||
kInt32QDomain, kIntShift, a, corr, &q_shift_residual);
|
||||
EXPECT_EQ(1789023310, residual_energy);
|
||||
EXPECT_EQ(2, q_shift_residual);
|
||||
|
||||
// Test the code path where (residual_energy < 0x10000)
|
||||
// and ((energy & 0x8000) != 0).
|
||||
for(int i = 0; i < kIntOrder + 1; i++) {
|
||||
a[i] = 24575 >> i;
|
||||
corr[i] = i;
|
||||
}
|
||||
residual_energy = WebRtcIsacfix_CalculateResidualEnergy(kIntOrder,
|
||||
kInt32QDomain, kIntShift, a, corr, &q_shift_residual);
|
||||
EXPECT_EQ(1595279092, residual_energy);
|
||||
EXPECT_EQ(26, q_shift_residual);
|
||||
|
||||
// Test the code path where (residual_energy <= 0x7fff).
|
||||
for(int i = 0; i < kIntOrder + 1; i++) {
|
||||
a[i] = 2457 >> i;
|
||||
}
|
||||
residual_energy = WebRtcIsacfix_CalculateResidualEnergy(kIntOrder,
|
||||
kInt32QDomain, kIntShift, a, corr, &q_shift_residual);
|
||||
EXPECT_EQ(2029266944, residual_energy);
|
||||
EXPECT_EQ(33, q_shift_residual);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user