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/webrtc@8038 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/common_audio/signal_processing/include/signal_processing_library.h b/common_audio/signal_processing/include/signal_processing_library.h
index ff17009..d987e9a 100644
--- a/common_audio/signal_processing/include/signal_processing_library.h
+++ b/common_audio/signal_processing/include/signal_processing_library.h
@@ -456,17 +456,15 @@
// does NOT use the 64 bit class
//
// Input:
-// - auto_corr : Vector with autocorrelation values of length >=
-// |use_order|+1
-// - use_order : The LPC filter order (support up to order 20)
+// - auto_corr : Vector with autocorrelation values of length >= |order|+1
+// - order : The LPC filter order (support up to order 20)
//
// Output:
-// - lpc_coef : lpc_coef[0..use_order] LPC coefficients in Q12
-// - refl_coef : refl_coef[0...use_order-1]| Reflection coefficients in
-// Q15
+// - lpc_coef : lpc_coef[0..order] LPC coefficients in Q12
+// - refl_coef : refl_coef[0...order-1]| Reflection coefficients in Q15
//
// 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* refl_coef,
int16_t order);
diff --git a/common_audio/signal_processing/levinson_durbin.c b/common_audio/signal_processing/levinson_durbin.c
index 29f2398..e07af5d 100644
--- a/common_audio/signal_processing/levinson_durbin.c
+++ b/common_audio/signal_processing/levinson_durbin.c
@@ -19,7 +19,7 @@
#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 i, j;
diff --git a/common_audio/signal_processing/signal_processing_unittest.cc b/common_audio/signal_processing/signal_processing_unittest.cc
index 611d2bf..305789e 100644
--- a/common_audio/signal_processing/signal_processing_unittest.cc
+++ b/common_audio/signal_processing/signal_processing_unittest.cc
@@ -371,18 +371,20 @@
}
TEST_F(SplTest, EstimatorsTest) {
- const int kVectorSize = 4;
- int B[] = {4, 12, 133, 1100};
- int16_t b16[kVectorSize];
- int32_t b32[kVectorSize];
- int16_t bTmp16[kVectorSize];
+ const int16_t kOrder = 2;
+ const int32_t unstable_filter[] = { 4, 12, 133, 1100 };
+ const int32_t stable_filter[] = { 1100, 133, 12, 4 };
+ int16_t lpc[kOrder + 2] = { 0 };
+ 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) {
- b16[kk] = B[kk];
- b32[kk] = B[kk];
- }
-
- EXPECT_EQ(0, WebRtcSpl_LevinsonDurbin(b32, b16, bTmp16, 2));
+ EXPECT_EQ(0, WebRtcSpl_LevinsonDurbin(unstable_filter, lpc, refl, kOrder));
+ EXPECT_EQ(1, WebRtcSpl_LevinsonDurbin(stable_filter, lpc, refl, kOrder));
+ for (int i = 0; i < kOrder + 2; ++i) {
+ EXPECT_EQ(lpc_result[i], lpc[i]);
+ EXPECT_EQ(refl_result[i], refl[i]);
+ }
}
TEST_F(SplTest, FilterTest) {