common_audio: Made input vector const in WebRtcSpl_LevinsonDurbin()

In addition, expanded the unit test to verify both unstable and stable filters.

BUG=3353, 1132
TESTED=locally on Mac and trybots
R=kwiberg@webrtc.org

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

git-svn-id: http://webrtc.googlecode.com/svn/trunk@8038 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
bjornv@webrtc.org
2015-01-12 05:53:43 +00:00
parent c14e3572c6
commit 88a4298234
3 changed files with 19 additions and 19 deletions

View File

@ -456,17 +456,15 @@ int WebRtcSpl_AutoCorrelation(const int16_t* in_vector,
// does NOT use the 64 bit class // does NOT use the 64 bit class
// //
// Input: // Input:
// - auto_corr : Vector with autocorrelation values of length >= // - auto_corr : Vector with autocorrelation values of length >= |order|+1
// |use_order|+1 // - order : The LPC filter order (support up to order 20)
// - use_order : The LPC filter order (support up to order 20)
// //
// Output: // Output:
// - lpc_coef : lpc_coef[0..use_order] LPC coefficients in Q12 // - lpc_coef : lpc_coef[0..order] LPC coefficients in Q12
// - refl_coef : refl_coef[0...use_order-1]| Reflection coefficients in // - refl_coef : refl_coef[0...order-1]| Reflection coefficients in Q15
// Q15
// //
// Return value : 1 for stable 0 for unstable // Return value : 1 for stable 0 for unstable
int16_t WebRtcSpl_LevinsonDurbin(int32_t* auto_corr, int16_t WebRtcSpl_LevinsonDurbin(const int32_t* auto_corr,
int16_t* lpc_coef, int16_t* lpc_coef,
int16_t* refl_coef, int16_t* refl_coef,
int16_t order); int16_t order);

View File

@ -19,7 +19,7 @@
#define SPL_LEVINSON_MAXORDER 20 #define SPL_LEVINSON_MAXORDER 20
int16_t WebRtcSpl_LevinsonDurbin(int32_t *R, int16_t *A, int16_t *K, int16_t WebRtcSpl_LevinsonDurbin(const int32_t* R, int16_t* A, int16_t* K,
int16_t order) int16_t order)
{ {
int16_t i, j; int16_t i, j;

View File

@ -371,18 +371,20 @@ TEST_F(SplTest, VectorOperationsTest) {
} }
TEST_F(SplTest, EstimatorsTest) { TEST_F(SplTest, EstimatorsTest) {
const int kVectorSize = 4; const int16_t kOrder = 2;
int B[] = {4, 12, 133, 1100}; const int32_t unstable_filter[] = { 4, 12, 133, 1100 };
int16_t b16[kVectorSize]; const int32_t stable_filter[] = { 1100, 133, 12, 4 };
int32_t b32[kVectorSize]; int16_t lpc[kOrder + 2] = { 0 };
int16_t bTmp16[kVectorSize]; int16_t refl[kOrder + 2] = { 0 };
int16_t lpc_result[] = { 4096, -497, 15, 0 };
int16_t refl_result[] = { -3962, 123, 0, 0 };
for (int kk = 0; kk < kVectorSize; ++kk) { EXPECT_EQ(0, WebRtcSpl_LevinsonDurbin(unstable_filter, lpc, refl, kOrder));
b16[kk] = B[kk]; EXPECT_EQ(1, WebRtcSpl_LevinsonDurbin(stable_filter, lpc, refl, kOrder));
b32[kk] = B[kk]; for (int i = 0; i < kOrder + 2; ++i) {
EXPECT_EQ(lpc_result[i], lpc[i]);
EXPECT_EQ(refl_result[i], refl[i]);
} }
EXPECT_EQ(0, WebRtcSpl_LevinsonDurbin(b32, b16, bTmp16, 2));
} }
TEST_F(SplTest, FilterTest) { TEST_F(SplTest, FilterTest) {