Update SILK code using the CELT range coder
[opus.git] / src_SigProc_FLP / SKP_Silk_allpass_int_FLP.c
similarity index 55%
rename from src/SKP_Silk_resample_3_2.c
rename to src_SigProc_FLP/SKP_Silk_allpass_int_FLP.c
index 53fe509..210780b 100644 (file)
@@ -26,48 +26,43 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ***********************************************************************/\r
 \r
 /*                                                                      *\r
- * File Name:   SKP_Silk_resample_3_2.c                               *\r
+ * SKP_Silk_allpass_int.c                                             *\r
  *                                                                      *\r
- * Resamples by a factor 3/2                                            *\r
+ * First-order allpass filter with                                      *                                                                     *\r
+ * transfer function:                                                   *\r
  *                                                                      *\r
- * Copyright 2008 (c), Skype Limited                                    *\r
- * All rights reserved.                                                 *\r
+ *         A + Z^(-1)                                                   *\r
+ * H(z) = ------------                                                  *\r
+ *        1 + A*Z^(-1)                                                  *\r
  *                                                                      *\r
- * Date: 081113                                                         *\r
+ * Implemented using minimum multiplier filter design.                  *\r
+ *                                                                      *\r
+ * Reference: http://www.univ.trieste.it/~ramponi/teaching/             *\r
+ * DSP/materiale/Ch6(2).pdf                                             *\r
+ *                                                                      *\r
+ * Copyright 2007 (c), Skype Limited                                    *\r
+ * Date: 070525                                                         *\r
  *                                                                      */\r
+#include "SKP_Silk_SigProc_FLP.h"\r
 \r
-#include "SKP_Silk_SigProc_FIX.h"\r
-\r
-#define IN_SUBFR_LEN_RESAMPLE_3_2       80\r
-\r
-/* Resamples by a factor 3/2 */\r
-void SKP_Silk_resample_3_2(\r
-    SKP_int16           *out,       /*   O: Fs_high signal  [inLen*3/2]             */\r
-    SKP_int32           *S,         /* I/O: State vector    [7+4]                   */\r
-    const SKP_int16     *in,        /* I:   Fs_low signal   [inLen]                 */\r
-    SKP_int             inLen       /* I:   Input length, must be a multiple of 2   */\r
+/* first-order allpass filter */\r
+void SKP_Silk_allpass_int_FLP(\r
+    const SKP_float     *in,        /* I:   input signal [len]          */\r
+    SKP_float           *S,         /* I/O: state [1]                   */\r
+    SKP_float           A,          /* I:   coefficient (0 <= A < 1)    */\r
+    SKP_float           *out,       /* O:   output signal [len]         */\r
+    const SKP_int32     len         /* I:   number of samples           */\r
 )\r
 {\r
-    SKP_int     LSubFrameIn, LSubFrameOut;\r
-    SKP_int16   outH[      3 * IN_SUBFR_LEN_RESAMPLE_3_2 ];\r
-    SKP_int32   scratch[ ( 9 * IN_SUBFR_LEN_RESAMPLE_3_2 ) / 2 ];\r
-\r
-    /* Check that input is multiple of 2 */\r
-    SKP_assert( inLen % 2 == 0 );\r
-\r
-    while( inLen > 0 ) {\r
-        LSubFrameIn  = SKP_min_int( IN_SUBFR_LEN_RESAMPLE_3_2, inLen );\r
-        LSubFrameOut = SKP_SMULWB( 98304, LSubFrameIn );\r
-\r
-        /* Upsample by a factor 3 */\r
-        SKP_Silk_resample_3_1( outH, &S[ 0 ], in, LSubFrameIn );\r
-        \r
-        /* Downsample by a factor 2 */\r
-        /* Scratch size needs to be: 3 * LSubFrameOut * sizeof( SKP_int32 ) */\r
-        SKP_Silk_resample_1_2_coarse( outH, &S[ 7 ], out, scratch, LSubFrameOut );\r
+    SKP_float Y2, X2, S0;\r
+    SKP_int32 k;\r
 \r
-        in    += LSubFrameIn;\r
-        out   += LSubFrameOut;\r
-        inLen -= LSubFrameIn;\r
+    S0 = S[ 0 ];\r
+    for ( k = len-1; k >= 0; k-- ) {\r
+        Y2        = *in - S0;\r
+        X2        = Y2 * A;\r
+        (*out++)  = S0 + X2;\r
+        S0        = (*in++) + X2;\r
     }\r
+    S[ 0 ] = S0;\r
 }\r