shithub: opus

Download patch

ref: 96739ad35e57706a69b9198b4862a5814f8e98bd
parent: 5d48dbd3117cda1413b9677f28bc32127b78c7f5
author: Gregory Maxwell <[email protected]>
date: Tue Sep 27 22:26:45 EDT 2011

Eliminate function pointers from the resampler.

--- a/silk/SigProc_FIX.h
+++ b/silk/SigProc_FIX.h
@@ -106,16 +106,6 @@
 );
 
 /*!
- * Downsample by a factor 3, low quality
-*/
-void silk_resampler_down3(
-    opus_int32                           *S,         /* I/O: State vector [ 8 ]                  */
-    opus_int16                           *out,       /* O:   Output signal [ floor(inLen/3) ]    */
-    const opus_int16                     *in,        /* I:   Input signal [ inLen ]              */
-    opus_int32                           inLen       /* I:   Number of input samples             */
-);
-
-/*!
  * second order ARMA filter;
  * slower than biquad() but uses more precise coefficients
  * can handle (slowly) varying coefficients
--- a/silk/resampler.c
+++ b/silk/resampler.c
@@ -72,6 +72,11 @@
     return a;
 }
 
+#define USE_silk_resampler_copy (0)
+#define USE_silk_resampler_private_up2_HQ_wrapper (1)
+#define USE_silk_resampler_private_IIR_FIR (2)
+#define USE_silk_resampler_private_down_FIR (3)
+
 /* Initialize/reset the resampler state for a given pair of input/output sampling rates */
 opus_int silk_resampler_init(
     silk_resampler_state_struct    *S,                    /* I/O: Resampler state             */
@@ -85,54 +90,11 @@
     silk_memset( S, 0, sizeof( silk_resampler_state_struct ) );
 
     /* Input checking */
-#if RESAMPLER_SUPPORT_ABOVE_48KHZ
-    if( Fs_Hz_in < 8000 || Fs_Hz_in > 192000 || Fs_Hz_out < 8000 || Fs_Hz_out > 192000 ) {
-#else
     if( Fs_Hz_in < 8000 || Fs_Hz_in >  48000 || Fs_Hz_out < 8000 || Fs_Hz_out >  48000 ) {
-#endif
         silk_assert( 0 );
         return -1;
     }
 
-#if RESAMPLER_SUPPORT_ABOVE_48KHZ
-    /* Determine pre downsampling and post upsampling */
-    if( Fs_Hz_in > 96000 ) {
-        S->nPreDownsamplers = 2;
-        S->down_pre_function = silk_resampler_private_down4;
-    } else if( Fs_Hz_in > 48000 ) {
-        S->nPreDownsamplers = 1;
-        S->down_pre_function = silk_resampler_down2;
-    } else {
-        S->nPreDownsamplers = 0;
-        S->down_pre_function = NULL;
-    }
-
-    if( Fs_Hz_out > 96000 ) {
-        S->nPostUpsamplers = 2;
-        S->up_post_function = silk_resampler_private_up4;
-    } else if( Fs_Hz_out > 48000 ) {
-        S->nPostUpsamplers = 1;
-        S->up_post_function = silk_resampler_up2;
-    } else {
-        S->nPostUpsamplers = 0;
-        S->up_post_function = NULL;
-    }
-
-    if( S->nPreDownsamplers + S->nPostUpsamplers > 0 ) {
-        /* Ratio of output/input samples */
-        S->ratio_Q16 = silk_LSHIFT32( silk_DIV32( silk_LSHIFT32( Fs_Hz_out, 13 ), Fs_Hz_in ), 3 );
-        /* Make sure the ratio is rounded up */
-        while( silk_SMULWW( S->ratio_Q16, Fs_Hz_in ) < Fs_Hz_out ) S->ratio_Q16++;
-
-        /* Batch size is 10 ms */
-        S->batchSizePrePost = silk_DIV32_16( Fs_Hz_in, 100 );
-
-        /* Convert sampling rate to those after pre-downsampling and before post-upsampling */
-        Fs_Hz_in  = silk_RSHIFT( Fs_Hz_in,  S->nPreDownsamplers  );
-        Fs_Hz_out = silk_RSHIFT( Fs_Hz_out, S->nPostUpsamplers  );
-    }
-#endif
-
     /* Number of samples processed per batch */
     /* First, try 10 ms frames */
     S->batchSize = silk_DIV32_16( Fs_Hz_in, 100 );
@@ -155,18 +117,12 @@
         /* Upsample */
         if( Fs_Hz_out == silk_MUL( Fs_Hz_in, 2 ) ) {                             /* Fs_out : Fs_in = 2 : 1 */
             /* Special case: directly use 2x upsampler */
-            S->resampler_function = silk_resampler_private_up2_HQ_wrapper;
+            S->resampler_function = USE_silk_resampler_private_up2_HQ_wrapper;
         } else {
             /* Default resampler */
-            S->resampler_function = silk_resampler_private_IIR_FIR;
+            S->resampler_function = USE_silk_resampler_private_IIR_FIR;
             up2 = 1;
-            if( Fs_Hz_in > 24000 ) {
-                /* Low-quality all-pass upsampler */
-                S->up2_function = silk_resampler_up2;
-            } else {
-                /* High-quality all-pass upsampler */
-                S->up2_function = silk_resampler_private_up2_HQ;
-            }
+            S->up2_hq = Fs_Hz_in <= 24000;
         }
     } else if ( Fs_Hz_out < Fs_Hz_in ) {
         /* Downsample */
@@ -173,63 +129,57 @@
         if( silk_MUL( Fs_Hz_out, 4 ) == silk_MUL( Fs_Hz_in, 3 ) ) {               /* Fs_out : Fs_in = 3 : 4 */
             S->FIR_Fracs = 3;
             S->Coefs = silk_Resampler_3_4_COEFS;
-            S->resampler_function = silk_resampler_private_down_FIR;
+            S->resampler_function = USE_silk_resampler_private_down_FIR;
         } else if( silk_MUL( Fs_Hz_out, 3 ) == silk_MUL( Fs_Hz_in, 2 ) ) {        /* Fs_out : Fs_in = 2 : 3 */
             S->FIR_Fracs = 2;
             S->Coefs = silk_Resampler_2_3_COEFS;
-            S->resampler_function = silk_resampler_private_down_FIR;
+            S->resampler_function = USE_silk_resampler_private_down_FIR;
         } else if( silk_MUL( Fs_Hz_out, 2 ) == Fs_Hz_in ) {                      /* Fs_out : Fs_in = 1 : 2 */
             S->FIR_Fracs = 1;
             S->Coefs = silk_Resampler_1_2_COEFS;
-            S->resampler_function = silk_resampler_private_down_FIR;
+            S->resampler_function = USE_silk_resampler_private_down_FIR;
         } else if( silk_MUL( Fs_Hz_out, 8 ) == silk_MUL( Fs_Hz_in, 3 ) ) {        /* Fs_out : Fs_in = 3 : 8 */
             S->FIR_Fracs = 3;
             S->Coefs = silk_Resampler_3_8_COEFS;
-            S->resampler_function = silk_resampler_private_down_FIR;
+            S->resampler_function = USE_silk_resampler_private_down_FIR;
         } else if( silk_MUL( Fs_Hz_out, 3 ) == Fs_Hz_in ) {                      /* Fs_out : Fs_in = 1 : 3 */
             S->FIR_Fracs = 1;
             S->Coefs = silk_Resampler_1_3_COEFS;
-            S->resampler_function = silk_resampler_private_down_FIR;
+            S->resampler_function = USE_silk_resampler_private_down_FIR;
         } else if( silk_MUL( Fs_Hz_out, 4 ) == Fs_Hz_in ) {                      /* Fs_out : Fs_in = 1 : 4 */
             S->FIR_Fracs = 1;
             down2 = 1;
             S->Coefs = silk_Resampler_1_2_COEFS;
-            S->resampler_function = silk_resampler_private_down_FIR;
+            S->resampler_function = USE_silk_resampler_private_down_FIR;
         } else if( silk_MUL( Fs_Hz_out, 6 ) == Fs_Hz_in ) {                      /* Fs_out : Fs_in = 1 : 6 */
             S->FIR_Fracs = 1;
             down2 = 1;
             S->Coefs = silk_Resampler_1_3_COEFS;
-            S->resampler_function = silk_resampler_private_down_FIR;
+            S->resampler_function = USE_silk_resampler_private_down_FIR;
         } else if( silk_MUL( Fs_Hz_out, 441 ) == silk_MUL( Fs_Hz_in, 80 ) ) {     /* Fs_out : Fs_in = 80 : 441 */
             S->Coefs = silk_Resampler_80_441_ARMA4_COEFS;
-            S->resampler_function = silk_resampler_private_IIR_FIR;
+            S->resampler_function = USE_silk_resampler_private_IIR_FIR;
         } else if( silk_MUL( Fs_Hz_out, 441 ) == silk_MUL( Fs_Hz_in, 120 ) ) {    /* Fs_out : Fs_in = 120 : 441 */
             S->Coefs = silk_Resampler_120_441_ARMA4_COEFS;
-            S->resampler_function = silk_resampler_private_IIR_FIR;
+            S->resampler_function = USE_silk_resampler_private_IIR_FIR;
         } else if( silk_MUL( Fs_Hz_out, 441 ) == silk_MUL( Fs_Hz_in, 160 ) ) {    /* Fs_out : Fs_in = 160 : 441 */
             S->Coefs = silk_Resampler_160_441_ARMA4_COEFS;
-            S->resampler_function = silk_resampler_private_IIR_FIR;
+            S->resampler_function = USE_silk_resampler_private_IIR_FIR;
         } else if( silk_MUL( Fs_Hz_out, 441 ) == silk_MUL( Fs_Hz_in, 240 ) ) {    /* Fs_out : Fs_in = 240 : 441 */
             S->Coefs = silk_Resampler_240_441_ARMA4_COEFS;
-            S->resampler_function = silk_resampler_private_IIR_FIR;
+            S->resampler_function = USE_silk_resampler_private_IIR_FIR;
         } else if( silk_MUL( Fs_Hz_out, 441 ) == silk_MUL( Fs_Hz_in, 320 ) ) {    /* Fs_out : Fs_in = 320 : 441 */
             S->Coefs = silk_Resampler_320_441_ARMA4_COEFS;
-            S->resampler_function = silk_resampler_private_IIR_FIR;
+            S->resampler_function = USE_silk_resampler_private_IIR_FIR;
         } else {
             /* Default resampler */
-            S->resampler_function = silk_resampler_private_IIR_FIR;
+            S->resampler_function = USE_silk_resampler_private_IIR_FIR;
             up2 = 1;
-            if( Fs_Hz_in > 24000 ) {
-                /* Low-quality all-pass upsampler */
-                S->up2_function = silk_resampler_up2;
-            } else {
-                /* High-quality all-pass upsampler */
-                S->up2_function = silk_resampler_private_up2_HQ;
-            }
+            S->up2_hq = Fs_Hz_in <= 24000;
         }
     } else {
         /* Input and output sampling rates are equal: copy */
-        S->resampler_function = silk_resampler_private_copy;
+        S->resampler_function = USE_silk_resampler_copy;
     }
 
     S->input2x = up2 | down2;
@@ -255,10 +205,6 @@
     silk_memset( S->sDown2, 0, sizeof( S->sDown2 ) );
     silk_memset( S->sIIR,   0, sizeof( S->sIIR ) );
     silk_memset( S->sFIR,   0, sizeof( S->sFIR ) );
-#if RESAMPLER_SUPPORT_ABOVE_48KHZ
-    silk_memset( S->sDownPre, 0, sizeof( S->sDownPre ) );
-    silk_memset( S->sUpPost,  0, sizeof( S->sUpPost ) );
-#endif
     return 0;
 }
 
@@ -276,42 +222,19 @@
         return -1;
     }
 
-#if RESAMPLER_SUPPORT_ABOVE_48KHZ
-    if( S->nPreDownsamplers + S->nPostUpsamplers > 0 ) {
-        /* The input and/or output sampling rate is above 48000 Hz */
-        opus_int32       nSamplesIn, nSamplesOut;
-        opus_int16        in_buf[ 480 ], out_buf[ 480 ];
-
-        while( inLen > 0 ) {
-            /* Number of input and output samples to process */
-            nSamplesIn = silk_min( inLen, S->batchSizePrePost );
-            nSamplesOut = silk_SMULWB( S->ratio_Q16, nSamplesIn );
-
-            silk_assert( silk_RSHIFT32( nSamplesIn,  S->nPreDownsamplers ) <= 480 );
-            silk_assert( silk_RSHIFT32( nSamplesOut, S->nPostUpsamplers  ) <= 480 );
-
-            if( S->nPreDownsamplers > 0 ) {
-                S->down_pre_function( S->sDownPre, in_buf, in, nSamplesIn );
-                if( S->nPostUpsamplers > 0 ) {
-                    S->resampler_function( S, out_buf, in_buf, silk_RSHIFT32( nSamplesIn, S->nPreDownsamplers ) );
-                    S->up_post_function( S->sUpPost, out, out_buf, silk_RSHIFT32( nSamplesOut, S->nPostUpsamplers ) );
-                } else {
-                    S->resampler_function( S, out, in_buf, silk_RSHIFT32( nSamplesIn, S->nPreDownsamplers ) );
-                }
-            } else {
-                S->resampler_function( S, out_buf, in, silk_RSHIFT32( nSamplesIn, S->nPreDownsamplers ) );
-                S->up_post_function( S->sUpPost, out, out_buf, silk_RSHIFT32( nSamplesOut, S->nPostUpsamplers ) );
-            }
-
-            in += nSamplesIn;
-            out += nSamplesOut;
-            inLen -= nSamplesIn;
-        }
-    } else
-#endif
-    {
-        /* Input and output sampling rate are at most 48000 Hz */
-        S->resampler_function( S, out, in, inLen );
+    /* Input and output sampling rate are at most 48000 Hz */
+    switch(S->resampler_function) {
+        case USE_silk_resampler_private_up2_HQ_wrapper:
+            silk_resampler_private_up2_HQ_wrapper( S, out, in, inLen );
+            break;
+        case USE_silk_resampler_private_IIR_FIR:
+            silk_resampler_private_IIR_FIR( S, out, in, inLen );
+            break;
+        case USE_silk_resampler_private_down_FIR:
+            silk_resampler_private_down_FIR( S, out, in, inLen );
+            break;
+        default:
+            silk_memcpy( out, in, inLen * sizeof( opus_int16 ) );
     }
 
     return 0;
--- a/silk/resampler_down3.c
+++ /dev/null
@@ -1,89 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-are permitted provided that the following conditions are met:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright
-notice, this list of conditions and the following disclaimer in the
-documentation and/or other materials provided with the distribution.
-- Neither the name of Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
-CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
-BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-***********************************************************************/
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "SigProc_FIX.h"
-#include "resampler_private.h"
-
-#define ORDER_FIR                   6
-
-/* Downsample by a factor 3, low quality */
-void silk_resampler_down3(
-    opus_int32                           *S,         /* I/O: State vector [ 8 ]                  */
-    opus_int16                           *out,       /* O:   Output signal [ floor(inLen/3) ]    */
-    const opus_int16                     *in,        /* I:   Input signal [ inLen ]              */
-    opus_int32                           inLen       /* I:   Number of input samples             */
-)
-{
-    opus_int32 nSamplesIn, counter, res_Q6;
-    opus_int32 buf[ RESAMPLER_MAX_BATCH_SIZE_IN + ORDER_FIR ];
-    opus_int32 *buf_ptr;
-
-    /* Copy buffered samples to start of buffer */
-    silk_memcpy( buf, S, ORDER_FIR * sizeof( opus_int32 ) );
-
-    /* Iterate over blocks of frameSizeIn input samples */
-    while( 1 ) {
-        nSamplesIn = silk_min( inLen, RESAMPLER_MAX_BATCH_SIZE_IN );
-
-        /* Second-order AR filter (output in Q8) */
-        silk_resampler_private_AR2( &S[ ORDER_FIR ], &buf[ ORDER_FIR ], in,
-            silk_Resampler_1_3_COEFS_LQ, nSamplesIn );
-
-        /* Interpolate filtered signal */
-        buf_ptr = buf;
-        counter = nSamplesIn;
-        while( counter > 2 ) {
-            /* Inner product */
-            res_Q6 = silk_SMULWB(         silk_ADD32( buf_ptr[ 0 ], buf_ptr[ 5 ] ), silk_Resampler_1_3_COEFS_LQ[ 2 ] );
-            res_Q6 = silk_SMLAWB( res_Q6, silk_ADD32( buf_ptr[ 1 ], buf_ptr[ 4 ] ), silk_Resampler_1_3_COEFS_LQ[ 3 ] );
-            res_Q6 = silk_SMLAWB( res_Q6, silk_ADD32( buf_ptr[ 2 ], buf_ptr[ 3 ] ), silk_Resampler_1_3_COEFS_LQ[ 4 ] );
-
-            /* Scale down, saturate and store in output array */
-            *out++ = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( res_Q6, 6 ) );
-
-            buf_ptr += 3;
-            counter -= 3;
-        }
-
-        in += nSamplesIn;
-        inLen -= nSamplesIn;
-
-        if( inLen > 0 ) {
-            /* More iterations to do; copy last part of filtered signal to beginning of buffer */
-            silk_memcpy( buf, &buf[ nSamplesIn ], ORDER_FIR * sizeof( opus_int32 ) );
-        } else {
-            break;
-        }
-    }
-
-    /* Copy last part of filtered signal to the state for the next call */
-    silk_memcpy( S, &buf[ nSamplesIn ], ORDER_FIR * sizeof( opus_int32 ) );
-}
--- a/silk/resampler_private.h
+++ b/silk/resampler_private.h
@@ -79,22 +79,6 @@
     opus_int32                       len             /* I:   Number of input samples                 */
 );
 
-/* Upsample 4x, low quality */
-void silk_resampler_private_up4(
-    opus_int32                       *S,             /* I/O: State vector [ 2 ]                      */
-    opus_int16                       *out,           /* O:   Output signal [ 4 * len ]               */
-    const opus_int16                 *in,            /* I:   Input signal [ len ]                    */
-    opus_int32                       len             /* I:   Number of input samples                 */
-);
-
-/* Downsample 4x, low quality */
-void silk_resampler_private_down4(
-    opus_int32                       *S,             /* I/O: State vector [ 2 ]                      */
-    opus_int16                       *out,           /* O:   Output signal [ floor(len/2) ]          */
-    const opus_int16                 *in,            /* I:   Input signal [ len ]                    */
-    opus_int32                       inLen           /* I:   Number of input samples                 */
-);
-
 /* Second order AR filter */
 void silk_resampler_private_AR2(
     opus_int32                        S[],            /* I/O: State vector [ 2 ]                        */
--- a/silk/resampler_private_IIR_FIR.c
+++ b/silk/resampler_private_IIR_FIR.c
@@ -76,7 +76,11 @@
 
         if( S->input2x == 1 ) {
             /* Upsample 2x */
-            S->up2_function( S->sIIR, &buf[ RESAMPLER_ORDER_FIR_144 ], in, nSamplesIn );
+            if (S->up2_hq) {
+                silk_resampler_private_up2_HQ( S->sIIR, &buf[ RESAMPLER_ORDER_FIR_144 ], in, nSamplesIn );
+            } else {
+                silk_resampler_up2( S->sIIR, &buf[ RESAMPLER_ORDER_FIR_144 ], in, nSamplesIn );
+            }
         } else {
             /* Fourth-order ARMA filter */
             silk_resampler_private_ARMA4( S->sIIR, &buf[ RESAMPLER_ORDER_FIR_144 ], in, S->Coefs, nSamplesIn );
--- a/silk/resampler_private_copy.c
+++ /dev/null
@@ -1,50 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-are permitted provided that the following conditions are met:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright
-notice, this list of conditions and the following disclaimer in the
-documentation and/or other materials provided with the distribution.
-- Neither the name of Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
-CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
-BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-***********************************************************************/
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "SigProc_FIX.h"
-#include "resampler_private.h"
-
-#ifdef __GNUC__
-#define OPUS_UNUSED_VAR __attribute__ ((unused))
-#else
-#define OPUS_UNUSED_VAR
-#endif
-
-/* Copy */
-void silk_resampler_private_copy(
-    void                 *SS OPUS_UNUSED_VAR,            /* I/O: Resampler state (unused)                */
-    opus_int16                         out[],            /* O:    Output signal                             */
-    const opus_int16                    in[],            /* I:    Input signal                            */
-    opus_int32                         inLen             /* I:    Number of input samples                    */
-)
-{
-    silk_memcpy( out, in, inLen * sizeof( opus_int16 ) );
-}
--- a/silk/resampler_private_down4.c
+++ /dev/null
@@ -1,73 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-are permitted provided that the following conditions are met:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright
-notice, this list of conditions and the following disclaimer in the
-documentation and/or other materials provided with the distribution.
-- Neither the name of Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
-CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
-BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-***********************************************************************/
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "SigProc_FIX.h"
-#include "resampler_private.h"
-
-/* Downsample by a factor 4. Note: very low quality, only use with input sampling rates above 96 kHz. */
-void silk_resampler_private_down4(
-    opus_int32                       *S,             /* I/O: State vector [ 2 ]                      */
-    opus_int16                       *out,           /* O:   Output signal [ floor(len/2) ]          */
-    const opus_int16                 *in,            /* I:   Input signal [ len ]                    */
-    opus_int32                       inLen           /* I:   Number of input samples                 */
-)
-{
-    opus_int32 k, len4 = silk_RSHIFT32( inLen, 2 );
-    opus_int32 in32, out32, Y, X;
-
-    silk_assert( silk_resampler_down2_0 > 0 );
-    silk_assert( silk_resampler_down2_1 < 0 );
-
-    /* Internal variables and state are in Q10 format */
-    for( k = 0; k < len4; k++ ) {
-        /* Add two input samples and convert to Q10 */
-        in32 = silk_LSHIFT( silk_ADD32( (opus_int32)in[ 4 * k ], (opus_int32)in[ 4 * k + 1 ] ), 9 );
-
-        /* All-pass section for even input sample */
-        Y      = silk_SUB32( in32, S[ 0 ] );
-        X      = silk_SMLAWB( Y, Y, silk_resampler_down2_1 );
-        out32  = silk_ADD32( S[ 0 ], X );
-        S[ 0 ] = silk_ADD32( in32, X );
-
-        /* Add two input samples and convert to Q10 */
-        in32 = silk_LSHIFT( silk_ADD32( (opus_int32)in[ 4 * k + 2 ], (opus_int32)in[ 4 * k + 3 ] ), 9 );
-
-        /* All-pass section for odd input sample */
-        Y      = silk_SUB32( in32, S[ 1 ] );
-        X      = silk_SMULWB( Y, silk_resampler_down2_0 );
-        out32  = silk_ADD32( out32, S[ 1 ] );
-        out32  = silk_ADD32( out32, X );
-        S[ 1 ] = silk_ADD32( in32, X );
-
-        /* Add, convert back to int16 and store to output */
-        out[ k ] = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( out32, 11 ) );
-    }
-}
--- a/silk/resampler_private_up4.c
+++ /dev/null
@@ -1,77 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved.
-Redistribution and use in source and binary forms, with or without
-modification, (subject to the limitations in the disclaimer below)
-are permitted provided that the following conditions are met:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright
-notice, this list of conditions and the following disclaimer in the
-documentation and/or other materials provided with the distribution.
-- Neither the name of Skype Limited, nor the names of specific
-contributors, may be used to endorse or promote products derived from
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
-BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
-CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
-BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-***********************************************************************/
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "SigProc_FIX.h"
-#include "resampler_private.h"
-
-/* Upsample by a factor 4, Note: low quality, only use with output sampling rates above 96 kHz. */
-void silk_resampler_private_up4(
-    opus_int32                       *S,             /* I/O: State vector [ 2 ]                      */
-    opus_int16                       *out,           /* O:   Output signal [ 4 * len ]               */
-    const opus_int16                 *in,            /* I:   Input signal [ len ]                    */
-    opus_int32                       len             /* I:   Number of INPUT samples                 */
-)
-{
-    opus_int32 k;
-    opus_int32 in32, out32, Y, X;
-    opus_int16 out16;
-
-    silk_assert( silk_resampler_up2_lq_0 > 0 );
-    silk_assert( silk_resampler_up2_lq_1 < 0 );
-
-    /* Internal variables and state are in Q10 format */
-    for( k = 0; k < len; k++ ) {
-        /* Convert to Q10 */
-        in32 = silk_LSHIFT( (opus_int32)in[ k ], 10 );
-
-        /* All-pass section for even output sample */
-        Y      = silk_SUB32( in32, S[ 0 ] );
-        X      = silk_SMULWB( Y, silk_resampler_up2_lq_0 );
-        out32  = silk_ADD32( S[ 0 ], X );
-        S[ 0 ] = silk_ADD32( in32, X );
-
-        /* Convert back to int16 and store to output */
-        out16 = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( out32, 10 ) );
-        out[ 4 * k ]     = out16;
-        out[ 4 * k + 1 ] = out16;
-
-        /* All-pass section for odd output sample */
-        Y      = silk_SUB32( in32, S[ 1 ] );
-        X      = silk_SMLAWB( Y, Y, silk_resampler_up2_lq_1 );
-        out32  = silk_ADD32( S[ 1 ], X );
-        S[ 1 ] = silk_ADD32( in32, X );
-
-        /* Convert back to int16 and store to output */
-        out16 = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( out32, 10 ) );
-        out[ 4 * k + 2 ] = out16;
-        out[ 4 * k + 3 ] = out16;
-    }
-}
--- a/silk/resampler_structs.h
+++ b/silk/resampler_structs.h
@@ -33,8 +33,6 @@
 #endif
 
 /* Flag to enable support for input/output sampling rates above 48 kHz. Turn off for embedded devices */
-#define RESAMPLER_SUPPORT_ABOVE_48KHZ                1
-
 #define SILK_RESAMPLER_MAX_FIR_ORDER                 16
 #define SILK_RESAMPLER_MAX_IIR_ORDER                 6
 
@@ -43,23 +41,13 @@
     opus_int32       sIIR[ SILK_RESAMPLER_MAX_IIR_ORDER ];        /* this must be the first element of this struct */
     opus_int32       sFIR[ SILK_RESAMPLER_MAX_FIR_ORDER ];
     opus_int32       sDown2[ 2 ];
-    void            (*resampler_function)( void *, opus_int16 *, const opus_int16 *, opus_int32 );
-    void            (*up2_function)(  opus_int32 *, opus_int16 *, const opus_int16 *, opus_int32 );
+    opus_int32       resampler_function;
+    opus_int32       up2_hq;
     opus_int32       batchSize;
     opus_int32       invRatio_Q16;
     opus_int32       FIR_Fracs;
     opus_int32       input2x;
     const opus_int16    *Coefs;
-#if RESAMPLER_SUPPORT_ABOVE_48KHZ
-    opus_int32       sDownPre[ 2 ];
-    opus_int32       sUpPost[ 2 ];
-    void            (*down_pre_function)( opus_int32 *, opus_int16 *, const opus_int16 *, opus_int32 );
-    void            (*up_post_function)(  opus_int32 *, opus_int16 *, const opus_int16 *, opus_int32 );
-    opus_int32       batchSizePrePost;
-    opus_int32       ratio_Q16;
-    opus_int32       nPreDownsamplers;
-    opus_int32       nPostUpsamplers;
-#endif
     opus_int32 magic_number;
 } silk_resampler_state_struct;
 
--- a/silk/silk_common.vcxproj
+++ b/silk/silk_common.vcxproj
@@ -145,15 +145,11 @@
     <ClCompile Include="resampler.c" />
     <ClCompile Include="resampler_down2.c" />
     <ClCompile Include="resampler_down2_3.c" />
-    <ClCompile Include="resampler_down3.c" />
     <ClCompile Include="resampler_private_AR2.c" />
     <ClCompile Include="resampler_private_ARMA4.c" />
-    <ClCompile Include="resampler_private_copy.c" />
-    <ClCompile Include="resampler_private_down4.c" />
     <ClCompile Include="resampler_private_down_FIR.c" />
     <ClCompile Include="resampler_private_IIR_FIR.c" />
     <ClCompile Include="resampler_private_up2_HQ.c" />
-    <ClCompile Include="resampler_private_up4.c" />
     <ClCompile Include="resampler_rom.c" />
     <ClCompile Include="resampler_up2.c" />
     <ClCompile Include="scale_copy_vector16.c" />
--- a/silk/silk_common.vcxproj.filters
+++ b/silk/silk_common.vcxproj.filters
@@ -195,9 +195,6 @@
     <ClCompile Include="resampler_down2_3.c">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="resampler_down3.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="resampler_private_AR2.c">
       <Filter>Source Files</Filter>
     </ClCompile>
@@ -204,12 +201,6 @@
     <ClCompile Include="resampler_private_ARMA4.c">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="resampler_private_copy.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="resampler_private_down4.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="resampler_private_down_FIR.c">
       <Filter>Source Files</Filter>
     </ClCompile>
@@ -217,9 +208,6 @@
       <Filter>Source Files</Filter>
     </ClCompile>
     <ClCompile Include="resampler_private_up2_HQ.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="resampler_private_up4.c">
       <Filter>Source Files</Filter>
     </ClCompile>
     <ClCompile Include="resampler_rom.c">
--- a/silk_sources.mk
+++ b/silk_sources.mk
@@ -70,15 +70,11 @@
 silk/resampler.c \
 silk/resampler_down2_3.c \
 silk/resampler_down2.c \
-silk/resampler_down3.c \
 silk/resampler_private_AR2.c \
 silk/resampler_private_ARMA4.c \
-silk/resampler_private_copy.c \
-silk/resampler_private_down4.c \
 silk/resampler_private_down_FIR.c \
 silk/resampler_private_IIR_FIR.c \
 silk/resampler_private_up2_HQ.c \
-silk/resampler_private_up4.c \
 silk/resampler_rom.c \
 silk/resampler_up2.c \
 silk/scale_copy_vector16.c \