Update SILK code using the CELT range coder
[opus.git] / test / signalCompare.c
index 0444584..f6025d9 100644 (file)
@@ -30,7 +30,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */\r
 \r
 #ifdef _WIN32\r
-#define _CRT_SECURE_NO_DEPRECATE       1\r
+#define _CRT_SECURE_NO_DEPRECATE    1\r
 #endif\r
 \r
 #include <stdio.h>\r
@@ -40,12 +40,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 \r
 #include "SKP_Silk_SigProc_FIX.h"\r
 \r
-#define FRAME_LENGTH_MS                        10\r
-#define WIN_LENGTH_MS                  20\r
-#define BW_EXPANSION                   0.7f\r
+#define FRAME_LENGTH_MS         10\r
+#define WIN_LENGTH_MS           20\r
+#define BW_EXPANSION            0.7f\r
 \r
-#define MAX_FS_KHZ                             24\r
-#define LPC_ORDER                              10\r
+#define MAX_FS_KHZ              24\r
+#define LPC_ORDER               10\r
 \r
 #ifdef  __cplusplus\r
 extern "C"\r
@@ -53,30 +53,30 @@ extern "C"
 #endif\r
 /* Internally used functions */\r
 void Autocorrelation( \r
-       SKP_float *results,                                     /* o    result (length correlationCount)                        */\r
-       const SKP_float *inputData,                     /* i    input data to correlate                                         */\r
-       SKP_int inputDataSize,                          /* i    length of input                                                         */\r
-       SKP_int correlationCount                        /* i    number of correlation taps to compute           */\r
+    SKP_float *results,                 /* o    result (length correlationCount)            */\r
+    const SKP_float *inputData,         /* i    input data to correlate                     */\r
+    SKP_int inputDataSize,              /* i    length of input                             */\r
+    SKP_int correlationCount            /* i    number of correlation taps to compute       */\r
 );\r
 \r
 /* inner product of two SKP_float arrays, with result as double */\r
 double Inner_product( \r
-       const SKP_float         *data1, \r
-       const SKP_float         *data2, \r
-       SKP_int                         dataSize\r
+    const SKP_float     *data1, \r
+    const SKP_float     *data2, \r
+    SKP_int             dataSize\r
 );\r
 /* Solve the normal equations using the Levinson-Durbin recursion */\r
-SKP_float Levinsondurbin(                              /* O    prediction error energy                                         */\r
-       SKP_float               A[],                            /* O    prediction coefficients [order]                         */\r
-       const SKP_float corr[],                         /* I    input auto-correlations [order + 1]                     */\r
-       const SKP_int   order                           /* I    prediction order                                                        */\r
+SKP_float Levinsondurbin(               /* O    prediction error energy                     */\r
+    SKP_float       A[],                /* O    prediction coefficients [order]             */\r
+    const SKP_float corr[],             /* I    input auto-correlations [order + 1]         */\r
+    const SKP_int   order               /* I    prediction order                            */\r
 );\r
 \r
 /* Chirp (bw expand) LP AR filter */\r
 void Bwexpander( \r
-       SKP_float *ar,                                          /* io   AR filter to be expanded (without leading 1)   */\r
-       const SKP_int d,                                        /* i    length of ar                                                                    */\r
-       const SKP_float chirp                           /* i    chirp factor (typically in range (0..1) )               */\r
+    SKP_float *ar,                      /* io   AR filter to be expanded (without leading 1)    */\r
+    const SKP_int d,                    /* i    length of ar                                    */\r
+    const SKP_float chirp               /* i    chirp factor (typically in range (0..1) )       */\r
 );\r
 \r
 #ifdef  __cplusplus\r
@@ -84,283 +84,290 @@ void Bwexpander(
 #endif\r
 \r
 static void print_usage(char* argv[]) {\r
-       printf("\nusage: %s ref.pcm test.pcm [settings]\n", argv[ 0 ]);\r
-       printf("\nref.pcm       : Reference file");\r
-       printf("\ntest.pcm      : File to be tested, should be of same length as ref.pcm");\r
-       printf("\n   settings:");\r
-       printf("\n-diff         : Only determine bit-exactness");\r
-       printf("\n-fs <kHz>     : Sampling rate in kHz, max: %d; default: 24", MAX_FS_KHZ);\r
-       printf("\n");\r
+    printf("\nusage: %s ref.pcm test.pcm [settings]\n", argv[ 0 ]);\r
+    printf("\nref.pcm       : Reference file");\r
+    printf("\ntest.pcm      : File to be tested, should be of same length as ref.pcm");\r
+    printf("\n   settings:");\r
+    printf("\n-diff         : Only determine bit-exactness");\r
+    printf("\n-fs <Hz>      : Sampling rate in Hz, max: %d; default: 24000", MAX_FS_KHZ * 1000 );\r
+    printf("\n");\r
 }\r
 \r
+#ifdef SKP_MACRO_COUNT\r
+    varDefine /* Define and reset global counters */\r
+#endif\r
+\r
 int main(int argc, char* argv[])\r
 {\r
-       SKP_int   args, n, i, counterRef, counterTest;\r
-       char      testInFileName[150], refInFileName[150];\r
-       FILE      *refInFile, *testInFile;\r
-       SKP_int   nFrames = 0, isUnequal = 0;\r
-       SKP_int   diff = 0, Fs_kHz = 24;                /* defaults */\r
-       SKP_float c, refWhtnd, testWhtnd, refNrg, diffNrg;\r
-       double    SNR = 0.0;\r
-       SKP_int16 refIn[WIN_LENGTH_MS * MAX_FS_KHZ], testIn[WIN_LENGTH_MS * MAX_FS_KHZ];\r
-       SKP_float refWin[WIN_LENGTH_MS * MAX_FS_KHZ], testWin[WIN_LENGTH_MS * MAX_FS_KHZ];\r
-       SKP_float autoCorr[LPC_ORDER + 1], LPC_Coef[LPC_ORDER];\r
-\r
-       if (argc < 3) {\r
-               print_usage(argv);\r
-               exit(0);\r
-       } \r
-\r
-       /* get arguments */\r
-       args = 1;\r
-       strcpy(refInFileName, argv[args]);\r
-       args++;\r
-       strcpy(testInFileName, argv[args]);\r
-       args++;\r
-       while(args < argc ) {\r
-               if (SKP_STR_CASEINSENSITIVE_COMPARE(argv[args], "-diff") == 0) {\r
-                       diff = 1;\r
-                       args++;\r
-               }else if (SKP_STR_CASEINSENSITIVE_COMPARE(argv[args], "-fs") == 0) {\r
-                       sscanf(argv[args+1], "%d", &Fs_kHz);\r
-                       args += 2;\r
-               } else {\r
-                       printf("Error: unrecognized setting: %s\n\n", argv[args]);\r
-                       print_usage(argv);\r
-                       exit(0);\r
-               }\r
-       }\r
-\r
-       if( Fs_kHz > MAX_FS_KHZ ) {\r
-               printf("Error: sampling rate too high: %d\n\n", Fs_kHz);\r
-               print_usage(argv);\r
-               exit(0);\r
-       }\r
-\r
-       printf("Reference:  %s\n", refInFileName);\r
-       //printf("Test:       %s\n", testInFileName);\r
-\r
-       /* open files */\r
-       refInFile = fopen(refInFileName, "rb");\r
-       if (refInFile==NULL) {\r
-               printf("Error: could not open input file %s\n", refInFileName);\r
-               exit(0);\r
-       } \r
-       testInFile = fopen(testInFileName, "rb");\r
-       if (testInFile==NULL) {\r
-               printf("Error: could not open input file %s\n", testInFileName);\r
-               exit(0);\r
-       }\r
-\r
-       SKP_memset( refIn,  0, sizeof(refIn) );\r
-       SKP_memset( testIn, 0, sizeof(testIn) );\r
-\r
-       while(1) {\r
-               /* Read inputs */\r
-               counterRef  = (SKP_int)fread(&refIn[(WIN_LENGTH_MS - FRAME_LENGTH_MS) * Fs_kHz], \r
-                       sizeof(SKP_int16), FRAME_LENGTH_MS * Fs_kHz, refInFile);\r
-               counterTest = (SKP_int)fread(&testIn[(WIN_LENGTH_MS - FRAME_LENGTH_MS) * Fs_kHz], \r
-                       sizeof(SKP_int16), FRAME_LENGTH_MS * Fs_kHz, testInFile);\r
-               if(counterRef != FRAME_LENGTH_MS * Fs_kHz || counterTest != FRAME_LENGTH_MS * Fs_kHz){\r
-                       break;\r
-               }\r
-\r
-               /* test for bit-exactness */\r
-               for( n = 0; n < FRAME_LENGTH_MS * Fs_kHz; n++ ) {\r
-                       if( refIn[(WIN_LENGTH_MS - FRAME_LENGTH_MS) * Fs_kHz + n] != \r
-                               testIn[(WIN_LENGTH_MS - FRAME_LENGTH_MS) * Fs_kHz + n] ) {\r
-                                       isUnequal = 1;\r
-                                       break;\r
-                       }\r
-               }\r
-\r
-               /* apply sine window */\r
-               for( n = 0; n < WIN_LENGTH_MS * Fs_kHz; n++ ) {\r
-                       c = (SKP_float)sin( 3.14159265 * (n + 1) / (WIN_LENGTH_MS * Fs_kHz + 1) );\r
-                       refWin[n]  = refIn[n]  * c;\r
-                       testWin[n] = testIn[n] * c;\r
-               }\r
-\r
-               /* LPC analysis on reference signal */\r
-\r
-               /* Calculate auto correlation */\r
-               Autocorrelation(autoCorr, refWin, WIN_LENGTH_MS * Fs_kHz, LPC_ORDER + 1);\r
-\r
-               /* Add white noise */\r
-               autoCorr[ 0 ] += autoCorr[ 0 ] * 1e-6f + 1.0f; \r
-\r
-               /* Convert correlations to prediction coefficients */\r
-               Levinsondurbin(LPC_Coef, autoCorr, LPC_ORDER);\r
-\r
-               /* Bandwdith expansion */\r
-               Bwexpander(LPC_Coef, LPC_ORDER, BW_EXPANSION);\r
-\r
-               /* Filter both signals */\r
-               refNrg = 1.0f;\r
-               diffNrg = 1e-10f;\r
-               for( n = (WIN_LENGTH_MS - FRAME_LENGTH_MS) / 2 * Fs_kHz; \r
-                        n < (WIN_LENGTH_MS + FRAME_LENGTH_MS) / 2 * Fs_kHz; n++ ) {\r
-                               refWhtnd = refIn[n];\r
-                               testWhtnd = testIn[n];\r
-                               for( i = 0; i < LPC_ORDER; i++ ) {\r
-                                       refWhtnd  -= LPC_Coef[ i ] * refIn[n - i - 1];\r
-                                       testWhtnd -= LPC_Coef[ i ] * testIn[n - i - 1];\r
-                               }\r
-                               refNrg += refWhtnd * refWhtnd;\r
-                               diffNrg += (refWhtnd - testWhtnd) * (refWhtnd - testWhtnd);\r
-               }\r
-\r
-               /* weighted SNR */\r
-               if( refNrg > FRAME_LENGTH_MS * Fs_kHz ) {\r
-                       SNR += 10.0 * log10( refNrg / diffNrg );\r
-                       nFrames++;\r
-               }\r
-\r
-               /* Update Buffer */\r
-               SKP_memmove( refIn,  &refIn[FRAME_LENGTH_MS * Fs_kHz],  (WIN_LENGTH_MS - FRAME_LENGTH_MS) * Fs_kHz * sizeof(SKP_int16));\r
-               SKP_memmove( testIn, &testIn[FRAME_LENGTH_MS * Fs_kHz], (WIN_LENGTH_MS - FRAME_LENGTH_MS) * Fs_kHz * sizeof(SKP_int16));\r
-       }\r
-\r
-       if( diff ) {\r
-               if( isUnequal ) {\r
-                       printf("Signals     DIFFER\n");\r
-               } else {\r
-                       if(counterRef != counterTest){\r
-                               printf("Warning: signals differ in length\n");\r
-                       }\r
-                       printf("Signals     BIT-EXACT\n");\r
-               }\r
-       } else {\r
-               if( nFrames == 0 ) {\r
-                       printf("At least one signal too short or not loud enough\n");\r
-                       exit(0);\r
-               }\r
-               if(counterRef != counterTest){\r
-                       printf("Warning: signals differ in length\n");\r
-               }\r
-               if( isUnequal == 0 ) {\r
-                       printf("Signals     BIT-EXACT\n");\r
-               } else {\r
-                       printf("AVERAGE WEIGHTED SNR: %4.1f dB\n", SNR / nFrames);\r
-               }\r
-       }\r
-       printf("\n");\r
-\r
-       /* Close Files */\r
-       fclose(refInFile);\r
-       fclose(testInFile);\r
-\r
-       return 0;\r
+    SKP_int   args, n, i, counterRef, counterTest;\r
+    char      testInFileName[150], refInFileName[150];\r
+    FILE      *refInFile, *testInFile;\r
+    SKP_int   nFrames = 0, isUnequal = 0;\r
+    SKP_int   diff = 0, Fs_kHz;\r
+    SKP_int32 Fs_Hz = 24000;\r
+    SKP_float c, refWhtnd, testWhtnd, refNrg, diffNrg;\r
+    double    SNR = 0.0;\r
+    SKP_int16 refIn[WIN_LENGTH_MS * MAX_FS_KHZ], testIn[WIN_LENGTH_MS * MAX_FS_KHZ];\r
+    SKP_float refWin[WIN_LENGTH_MS * MAX_FS_KHZ], testWin[WIN_LENGTH_MS * MAX_FS_KHZ];\r
+    SKP_float autoCorr[LPC_ORDER + 1], LPC_Coef[LPC_ORDER];\r
+\r
+    if (argc < 3) {\r
+        print_usage(argv);\r
+        exit(0);\r
+    } \r
+\r
+    /* get arguments */\r
+    args = 1;\r
+    strcpy(refInFileName, argv[args]);\r
+    args++;\r
+    strcpy(testInFileName, argv[args]);\r
+    args++;\r
+    while(args < argc ) {\r
+        if (SKP_STR_CASEINSENSITIVE_COMPARE(argv[args], "-diff") == 0) {\r
+            diff = 1;\r
+            args++;\r
+        }else if (SKP_STR_CASEINSENSITIVE_COMPARE(argv[args], "-fs") == 0) {\r
+            sscanf(argv[args+1], "%d", &Fs_Hz);\r
+            args += 2;\r
+        } else {\r
+            printf("Error: unrecognized setting: %s\n\n", argv[args]);\r
+            print_usage(argv);\r
+            exit(0);\r
+        }\r
+    }\r
+\r
+    Fs_kHz = SKP_DIV32_16( Fs_Hz, 1000 );\r
+\r
+    if( Fs_kHz > MAX_FS_KHZ ) {\r
+        printf("Error: sampling rate too high: %d\n\n", Fs_kHz);\r
+        print_usage(argv);\r
+        exit(0);\r
+    }\r
+\r
+    printf("Reference:  %s\n", refInFileName);\r
+    //printf("Test:       %s\n", testInFileName);\r
+\r
+    /* open files */\r
+    refInFile = fopen(refInFileName, "rb");\r
+    if (refInFile==NULL) {\r
+        printf("Error: could not open input file %s\n", refInFileName);\r
+        exit(0);\r
+    } \r
+    testInFile = fopen(testInFileName, "rb");\r
+    if (testInFile==NULL) {\r
+        printf("Error: could not open input file %s\n", testInFileName);\r
+        exit(0);\r
+    }\r
+\r
+    SKP_memset( refIn,  0, sizeof(refIn) );\r
+    SKP_memset( testIn, 0, sizeof(testIn) );\r
+\r
+    while(1) {\r
+        /* Read inputs */\r
+        counterRef  = (SKP_int)fread(&refIn[(WIN_LENGTH_MS - FRAME_LENGTH_MS) * Fs_kHz], \r
+            sizeof(SKP_int16), FRAME_LENGTH_MS * Fs_kHz, refInFile);\r
+        counterTest = (SKP_int)fread(&testIn[(WIN_LENGTH_MS - FRAME_LENGTH_MS) * Fs_kHz], \r
+            sizeof(SKP_int16), FRAME_LENGTH_MS * Fs_kHz, testInFile);\r
+        if(counterRef != FRAME_LENGTH_MS * Fs_kHz || counterTest != FRAME_LENGTH_MS * Fs_kHz){\r
+            break;\r
+        }\r
+\r
+        /* test for bit-exactness */\r
+        for( n = 0; n < FRAME_LENGTH_MS * Fs_kHz; n++ ) {\r
+            if( refIn[(WIN_LENGTH_MS - FRAME_LENGTH_MS) * Fs_kHz + n] != \r
+                testIn[(WIN_LENGTH_MS - FRAME_LENGTH_MS) * Fs_kHz + n] ) {\r
+                    isUnequal = 1;\r
+                    break;\r
+            }\r
+        }\r
+\r
+        /* apply sine window */\r
+        for( n = 0; n < WIN_LENGTH_MS * Fs_kHz; n++ ) {\r
+            c = (SKP_float)sin( 3.14159265 * (n + 1) / (WIN_LENGTH_MS * Fs_kHz + 1) );\r
+            refWin[n]  = refIn[n]  * c;\r
+            testWin[n] = testIn[n] * c;\r
+        }\r
+\r
+        /* LPC analysis on reference signal */\r
+\r
+        /* Calculate auto correlation */\r
+        Autocorrelation(autoCorr, refWin, WIN_LENGTH_MS * Fs_kHz, LPC_ORDER + 1);\r
+\r
+        /* Add white noise */\r
+        autoCorr[ 0 ] += autoCorr[ 0 ] * 1e-6f + 1.0f; \r
+\r
+        /* Convert correlations to prediction coefficients */\r
+        Levinsondurbin(LPC_Coef, autoCorr, LPC_ORDER);\r
+\r
+        /* Bandwdith expansion */\r
+        Bwexpander(LPC_Coef, LPC_ORDER, BW_EXPANSION);\r
+\r
+        /* Filter both signals */\r
+        refNrg = 1.0f;\r
+        diffNrg = 1e-10f;\r
+        for( n = (WIN_LENGTH_MS - FRAME_LENGTH_MS) / 2 * Fs_kHz; \r
+             n < (WIN_LENGTH_MS + FRAME_LENGTH_MS) / 2 * Fs_kHz; n++ ) {\r
+                refWhtnd = refIn[n];\r
+                testWhtnd = testIn[n];\r
+                for( i = 0; i < LPC_ORDER; i++ ) {\r
+                    refWhtnd  -= LPC_Coef[ i ] * refIn[n - i - 1];\r
+                    testWhtnd -= LPC_Coef[ i ] * testIn[n - i - 1];\r
+                }\r
+                refNrg += refWhtnd * refWhtnd;\r
+                diffNrg += (refWhtnd - testWhtnd) * (refWhtnd - testWhtnd);\r
+        }\r
+\r
+        /* weighted SNR */\r
+        if( refNrg > FRAME_LENGTH_MS * Fs_kHz ) {\r
+            SNR += 10.0 * log10( refNrg / diffNrg );\r
+            nFrames++;\r
+        }\r
+\r
+        /* Update Buffer */\r
+        SKP_memmove( refIn,  &refIn[FRAME_LENGTH_MS * Fs_kHz],  (WIN_LENGTH_MS - FRAME_LENGTH_MS) * Fs_kHz * sizeof(SKP_int16));\r
+        SKP_memmove( testIn, &testIn[FRAME_LENGTH_MS * Fs_kHz], (WIN_LENGTH_MS - FRAME_LENGTH_MS) * Fs_kHz * sizeof(SKP_int16));\r
+    }\r
+\r
+    if( diff ) {\r
+        if( isUnequal ) {\r
+            printf("Signals     DIFFER\n");\r
+        } else {\r
+            if(counterRef != counterTest){\r
+                printf("Warning: signals differ in length\n");\r
+            }\r
+            printf("Signals     BIT-EXACT\n");\r
+        }\r
+    } else {\r
+        if( nFrames == 0 ) {\r
+            printf("At least one signal too short or not loud enough\n");\r
+            exit(0);\r
+        }\r
+        if(counterRef != counterTest){\r
+            printf("Warning: signals differ in length\n");\r
+        }\r
+        if( isUnequal == 0 ) {\r
+            printf("Signals     BIT-EXACT\n");\r
+        } else {\r
+            printf("AVERAGE WEIGHTED SNR: %4.1f dB\n", SNR / nFrames);\r
+        }\r
+    }\r
+    printf("\n");\r
+\r
+    /* Close Files */\r
+    fclose(refInFile);\r
+    fclose(testInFile);\r
+\r
+    return 0;\r
 }\r
 \r
 /* compute autocorrelation */\r
 void Autocorrelation( \r
-       SKP_float *results,                                     /* o    result (length correlationCount)                        */\r
-       const SKP_float *inputData,                     /* i    input data to correlate                                         */\r
-       SKP_int inputDataSize,                          /* i    length of input                                                         */\r
-       SKP_int correlationCount                        /* i    number of correlation taps to compute           */\r
+    SKP_float *results,                 /* o    result (length correlationCount)            */\r
+    const SKP_float *inputData,         /* i    input data to correlate                     */\r
+    SKP_int inputDataSize,              /* i    length of input                             */\r
+    SKP_int correlationCount            /* i    number of correlation taps to compute       */\r
 )\r
 {\r
-       SKP_int i;\r
+    SKP_int i;\r
 \r
-       if (correlationCount > inputDataSize) {\r
-               correlationCount = inputDataSize;\r
-       }\r
+    if (correlationCount > inputDataSize) {\r
+        correlationCount = inputDataSize;\r
+    }\r
 \r
-       for( i = 0; i < correlationCount; i++ ) {\r
-               results[ i ] =  (SKP_float)Inner_product( inputData, inputData + i, inputDataSize - i );\r
-       }\r
+    for( i = 0; i < correlationCount; i++ ) {\r
+        results[ i ] =  (SKP_float)Inner_product( inputData, inputData + i, inputDataSize - i );\r
+    }\r
 }\r
 \r
 /* inner product of two SKP_float arrays, with result as double */\r
 double Inner_product( \r
-       const SKP_float         *data1, \r
-       const SKP_float         *data2, \r
-       SKP_int                         dataSize\r
+    const SKP_float     *data1, \r
+    const SKP_float     *data2, \r
+    SKP_int             dataSize\r
 )\r
 {\r
-       SKP_int  i, dataSize4;\r
-       double   result;\r
-\r
-       /* 4x unrolled loop */\r
-       result = 0.0f;\r
-       dataSize4 = dataSize & 0xFFFC;\r
-       for( i = 0; i < dataSize4; i += 4 ) {\r
-               result += data1[ i + 0 ] * data2[ i + 0 ] + \r
-                                 data1[ i + 1 ] * data2[ i + 1 ] +\r
-                                 data1[ i + 2 ] * data2[ i + 2 ] +\r
-                                 data1[ i + 3 ] * data2[ i + 3 ];\r
-       }\r
-\r
-       /* add any remaining products */\r
-       for( ; i < dataSize; i++ ) {\r
-               result += data1[ i ] * data2[ i ];\r
-       }\r
-\r
-       return result;\r
+    SKP_int  i, dataSize4;\r
+    double   result;\r
+\r
+    /* 4x unrolled loop */\r
+    result = 0.0f;\r
+    dataSize4 = dataSize & 0xFFFC;\r
+    for( i = 0; i < dataSize4; i += 4 ) {\r
+        result += data1[ i + 0 ] * data2[ i + 0 ] + \r
+                  data1[ i + 1 ] * data2[ i + 1 ] +\r
+                  data1[ i + 2 ] * data2[ i + 2 ] +\r
+                  data1[ i + 3 ] * data2[ i + 3 ];\r
+    }\r
+\r
+    /* add any remaining products */\r
+    for( ; i < dataSize; i++ ) {\r
+        result += data1[ i ] * data2[ i ];\r
+    }\r
+\r
+    return result;\r
 }\r
 \r
 /* Solve the normal equations using the Levinson-Durbin recursion */\r
-SKP_float Levinsondurbin(                              /* O    prediction error energy                                         */\r
-       SKP_float               A[],                            /* O    prediction coefficients [order]                         */\r
-       const SKP_float corr[],                         /* I    input auto-correlations [order + 1]                     */\r
-       const SKP_int   order                           /* I    prediction order                                                        */\r
+SKP_float Levinsondurbin(               /* O    prediction error energy                     */\r
+    SKP_float       A[],                /* O    prediction coefficients [order]             */\r
+    const SKP_float corr[],             /* I    input auto-correlations [order + 1]         */\r
+    const SKP_int   order               /* I    prediction order                            */\r
 )\r
 {\r
-       SKP_int   i, mHalf, m;\r
-       SKP_float min_nrg, nrg, t, km, Atmp1, Atmp2;\r
-       \r
-       min_nrg = 1e-12f * corr[ 0 ] + 1e-9f;\r
-       nrg = corr[ 0 ];\r
-       nrg = SKP_max(min_nrg, nrg);\r
-       A[ 0 ] = corr[ 1 ] / nrg;\r
-       nrg -= A[ 0 ] * corr[ 1 ];\r
-       nrg = SKP_max(min_nrg, nrg);\r
-\r
-       for( m = 1; m < order; m++ )\r
-       {\r
-               t = corr[ m + 1 ];\r
-               for( i = 0; i < m; i++ ) {\r
-                       t -= A[ i ] * corr[ m - i ];\r
-               }\r
-\r
-               /* reflection coefficient */\r
-               km = t / nrg;\r
-\r
-               /* residual energy */\r
-               nrg -= km * t;\r
-               nrg = SKP_max(min_nrg, nrg);\r
-\r
-               mHalf = m >> 1;\r
-               for( i = 0; i < mHalf; i++ ) {\r
-                       Atmp1 = A[ i ];\r
-                       Atmp2 = A[ m - i - 1 ];\r
-                       A[ m - i - 1 ] -= km * Atmp1;\r
-                       A[ i ]         -= km * Atmp2;\r
-               }\r
-               if( m & 1 ) {\r
-                       A[ mHalf ]     -= km * A[ mHalf ];\r
-               }\r
-               A[ m ] = km;\r
-       }\r
-\r
-       /* return the residual energy */\r
-       return nrg;\r
+    SKP_int   i, mHalf, m;\r
+    SKP_float min_nrg, nrg, t, km, Atmp1, Atmp2;\r
+    \r
+    min_nrg = 1e-12f * corr[ 0 ] + 1e-9f;\r
+    nrg = corr[ 0 ];\r
+    nrg = SKP_max( min_nrg, nrg );\r
+    A[ 0 ] = corr[ 1 ] / nrg;\r
+    nrg -= A[ 0 ] * corr[ 1 ];\r
+    nrg = SKP_max(min_nrg, nrg);\r
+\r
+    for( m = 1; m < order; m++ )\r
+    {\r
+        t = corr[ m + 1 ];\r
+        for( i = 0; i < m; i++ ) {\r
+            t -= A[ i ] * corr[ m - i ];\r
+        }\r
+\r
+        /* reflection coefficient */\r
+        km = t / nrg;\r
+\r
+        /* residual energy */\r
+        nrg -= km * t;\r
+        nrg = SKP_max(min_nrg, nrg);\r
+\r
+        mHalf = m >> 1;\r
+        for( i = 0; i < mHalf; i++ ) {\r
+            Atmp1 = A[ i ];\r
+            Atmp2 = A[ m - i - 1 ];\r
+            A[ m - i - 1 ] -= km * Atmp1;\r
+            A[ i ]         -= km * Atmp2;\r
+        }\r
+        if( m & 1 ) {\r
+            A[ mHalf ]     -= km * A[ mHalf ];\r
+        }\r
+        A[ m ] = km;\r
+    }\r
+\r
+    /* return the residual energy */\r
+    return nrg;\r
 }\r
 \r
 /* Chirp (bw expand) LP AR filter */\r
 void Bwexpander( \r
-       SKP_float *ar,                                          /* io   AR filter to be expanded (without leading 1)   */\r
-       const SKP_int d,                                        /* i    length of ar                                                                    */\r
-       const SKP_float chirp                           /* i    chirp factor (typically in range (0..1) )               */\r
+    SKP_float *ar,                      /* io   AR filter to be expanded (without leading 1)    */\r
+    const SKP_int d,                    /* i    length of ar                                    */\r
+    const SKP_float chirp               /* i    chirp factor (typically in range (0..1) )       */\r
 )\r
 {\r
-       SKP_int   i;\r
-       SKP_float cfac = chirp;\r
-\r
-       for( i = 0; i < d - 1; i++ ) {\r
-               ar[ i ] *=  cfac;\r
-               cfac    *=  chirp;\r
-       }\r
-       ar[ d - 1 ] *=  cfac;\r
+    SKP_int   i;\r
+    SKP_float cfac = chirp;\r
+\r
+    for( i = 0; i < d - 1; i++ ) {\r
+        ar[ i ] *=  cfac;\r
+        cfac    *=  chirp;\r
+    }\r
+    ar[ d - 1 ] *=  cfac;\r
 }\r