shithub: opus

Download patch

ref: e2a6aaa73158d4e9415a7e053f84f83314e2d9e3
parent: d5158a42d1010e3a2c4431dbada17314496b6ce3
author: Timothy B. Terriberry <[email protected]>
date: Wed Oct 12 10:24:19 EDT 2011

Improves accuracy of NLSF2A by reordering the polynomial roots

--- a/silk/NLSF2A.c
+++ b/silk/NLSF2A.c
@@ -69,6 +69,15 @@
     const opus_int    d                  /* I    filter order (should be even)                       */
 )
 {
+    /* This ordering was found to maximize quality. It improves numerical accuracy of
+       silk_NLSF2A_find_poly() compared to "standard" ordering. */
+    static const unsigned char ordering16[16] = {
+      0, 15, 8, 7, 4, 11, 12, 3, 2, 13, 10, 5, 6, 9, 14, 1
+    };
+    static const unsigned char ordering10[10] = {
+      0, 9, 6, 3, 4, 5, 8, 1, 2, 7
+    };
+    const unsigned char *ordering;
     opus_int   k, i, dd;
     opus_int32 cos_LSF_QA[ SILK_MAX_ORDER_LPC ];
     opus_int32 P[ SILK_MAX_ORDER_LPC / 2 + 1 ], Q[ SILK_MAX_ORDER_LPC / 2 + 1 ];
@@ -80,6 +89,7 @@
     silk_assert( d==10||d==16 );
 
     /* convert LSFs to 2*cos(LSF), using piecewise linear curve from table */
+    ordering = d == 16 ? ordering16 : ordering10;
     for( k = 0; k < d; k++ ) {
         silk_assert(NLSF[k] >= 0 );
         silk_assert(NLSF[k] <= 32767 );
@@ -98,7 +108,7 @@
         delta   = silk_LSFCosTab_FIX_Q12[ f_int + 1 ] - cos_val;  /* Q12, with a range of 0..200 */
 
         /* Linear interpolation */
-        cos_LSF_QA[k] = silk_RSHIFT_ROUND( silk_LSHIFT( cos_val, 8 ) + silk_MUL( delta, f_frac ), 20 - QA ); /* QA */
+        cos_LSF_QA[ordering[k]] = silk_RSHIFT_ROUND( silk_LSHIFT( cos_val, 8 ) + silk_MUL( delta, f_frac ), 20 - QA ); /* QA */
     }
 
     dd = silk_RSHIFT( d, 1 );