shithub: opus

Download patch

ref: 53ea87fb96bc7eb550d1f60b3136e32857a4f9d9
parent: 3346d88390716296ad1c6995bc0b7f0c1060d744
author: Jean-Marc Valin <[email protected]>
date: Sun Oct 9 21:57:22 EDT 2011

Cheap early detection of unstable filters

We check the DC gain before doing the full RC calculations

--- a/silk/LPC_inv_pred_gain.c
+++ b/silk/LPC_inv_pred_gain.c
@@ -117,14 +117,19 @@
     opus_int   k;
     opus_int32 Atmp_QA[ 2 ][ SILK_MAX_ORDER_LPC ];
     opus_int32 *Anew_QA;
+    opus_int32 DC_resp=0;
 
     Anew_QA = Atmp_QA[ order & 1 ];
 
     /* Increase Q domain of the AR coefficients */
     for( k = 0; k < order; k++ ) {
+        DC_resp += (opus_int32)A_Q12[ k ];
         Anew_QA[ k ] = silk_LSHIFT( (opus_int32)A_Q12[ k ], QA - 12 );
     }
-
+    /* If the DC is unstable, we don't even need to do the full calculations */
+    if ( DC_resp >= 4096 ) {
+       return 1;
+    }
     return LPC_inverse_pred_gain_QA( invGain_Q30, Atmp_QA, order );
 }