Moved all SILK source code to the silk/ directory
[opus.git] / silk / SKP_Silk_resampler_private.h
1 /***********************************************************************\r
2 Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
3 Redistribution and use in source and binary forms, with or without \r
4 modification, (subject to the limitations in the disclaimer below) \r
5 are permitted provided that the following conditions are met:\r
6 - Redistributions of source code must retain the above copyright notice,\r
7 this list of conditions and the following disclaimer.\r
8 - Redistributions in binary form must reproduce the above copyright \r
9 notice, this list of conditions and the following disclaimer in the \r
10 documentation and/or other materials provided with the distribution.\r
11 - Neither the name of Skype Limited, nor the names of specific \r
12 contributors, may be used to endorse or promote products derived from \r
13 this software without specific prior written permission.\r
14 NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED \r
15 BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND \r
16 CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,\r
17 BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND \r
18 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE \r
19 COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, \r
20 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\r
21 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF \r
22 USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON \r
23 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
24 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE \r
25 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
26 ***********************************************************************/\r
27 \r
28 /*                                                                                                                                              *\r
29  * File Name:   SKP_Silk_resampler_structs.h                                                    *\r
30  *                                                                                                                                              *\r
31  * Description: Structs for IIR/FIR resamplers                                                  *\r
32  *                                                                      *\r
33  * Copyright 2010 (c), Skype Limited                                    *\r
34  * All rights reserved.                                                                                                 *\r
35  *                                                                                                                                              *\r
36  *                                                                      */\r
37 \r
38 #ifndef SKP_Silk_RESAMPLER_H\r
39 #define SKP_Silk_RESAMPLER_H\r
40 \r
41 #ifdef __cplusplus\r
42 extern "C" {\r
43 #endif\r
44 \r
45 #include "SKP_Silk_SigProc_FIX.h"\r
46 #include "SKP_Silk_resampler_structs.h"\r
47 #include "SKP_Silk_resampler_rom.h"\r
48 \r
49 /* Number of input samples to process in the inner loop */\r
50 #define RESAMPLER_MAX_BATCH_SIZE_IN             480\r
51 \r
52 /* Description: Hybrid IIR/FIR polyphase implementation of resampling   */\r
53 void SKP_Silk_resampler_private_IIR_FIR(\r
54         void                            *SS,                /* I/O: Resampler state                                             */\r
55         SKP_int16                                               out[],              /* O:       Output signal                                                   */\r
56         const SKP_int16                                 in[],               /* I:       Input signal                                                    */\r
57         SKP_int32                                           inLen                   /* I:       Number of input samples                                 */\r
58 );\r
59 \r
60 /* Description: Hybrid IIR/FIR polyphase implementation of resampling   */\r
61 void SKP_Silk_resampler_private_down_FIR(\r
62         void                            *SS,                /* I/O: Resampler state                                             */\r
63         SKP_int16                                               out[],              /* O:       Output signal                                                   */\r
64         const SKP_int16                                 in[],               /* I:       Input signal                                                    */\r
65         SKP_int32                                           inLen                   /* I:       Number of input samples                                 */\r
66 );\r
67 \r
68 /* Copy */\r
69 void SKP_Silk_resampler_private_copy(\r
70         void                            *SS,                /* I/O: Resampler state (unused)                            */\r
71         SKP_int16                                               out[],              /* O:       Output signal                                                   */\r
72         const SKP_int16                                 in[],               /* I:       Input signal                                                    */\r
73         SKP_int32                                           inLen                   /* I:       Number of input samples                                 */\r
74 );\r
75 \r
76 /* Upsample by a factor 2, high quality */\r
77 void SKP_Silk_resampler_private_up2_HQ_wrapper(\r
78         void                            *SS,                /* I/O: Resampler state (unused)                            */\r
79     SKP_int16                       *out,           /* O:   Output signal [ 2 * len ]               */\r
80     const SKP_int16                 *in,            /* I:   Input signal [ len ]                    */\r
81     SKP_int32                       len             /* I:   Number of input samples                 */\r
82 );\r
83 \r
84 /* Upsample by a factor 2, high quality */\r
85 void SKP_Silk_resampler_private_up2_HQ(\r
86         SKP_int32                           *S,                     /* I/O: Resampler state [ 6 ]                                       */\r
87     SKP_int16                       *out,           /* O:   Output signal [ 2 * len ]               */\r
88     const SKP_int16                 *in,            /* I:   Input signal [ len ]                    */\r
89     SKP_int32                       len             /* I:   Number of input samples                 */\r
90 );\r
91 \r
92 /* Upsample 4x, low quality */\r
93 void SKP_Silk_resampler_private_up4(\r
94     SKP_int32                       *S,             /* I/O: State vector [ 2 ]                      */\r
95     SKP_int16                       *out,           /* O:   Output signal [ 4 * len ]               */\r
96     const SKP_int16                 *in,            /* I:   Input signal [ len ]                    */\r
97     SKP_int32                       len             /* I:   Number of input samples                 */\r
98 );\r
99 \r
100 /* Downsample 4x, low quality */\r
101 void SKP_Silk_resampler_private_down4(\r
102     SKP_int32                       *S,             /* I/O: State vector [ 2 ]                      */\r
103     SKP_int16                       *out,           /* O:   Output signal [ floor(len/2) ]          */\r
104     const SKP_int16                 *in,            /* I:   Input signal [ len ]                    */\r
105     SKP_int32                       inLen           /* I:   Number of input samples                 */\r
106 );\r
107 \r
108 /* Second order AR filter */\r
109 void SKP_Silk_resampler_private_AR2(\r
110         SKP_int32                                           S[],                    /* I/O: State vector [ 2 ]                              */\r
111         SKP_int32                                           out_Q8[],           /* O:   Output signal                                       */\r
112         const SKP_int16                             in[],                       /* I:   Input signal                                        */\r
113         const SKP_int16                             A_Q14[],            /* I:   AR coefficients, Q14                    */\r
114         SKP_int32                                       len                             /* I:   Signal length                                           */\r
115 );\r
116 \r
117 /* Fourth order ARMA filter */\r
118 void SKP_Silk_resampler_private_ARMA4(\r
119         SKP_int32                                           S[],                    /* I/O: State vector [ 4 ]                              */\r
120         SKP_int16                                           out[],                  /* O:       Output signal                                       */\r
121         const SKP_int16                             in[],                       /* I:   Input signal                                        */\r
122         const SKP_int16                             Coef[],                 /* I:       ARMA coefficients [ 7 ]                 */\r
123         SKP_int32                                       len                             /* I:   Signal length                                           */\r
124 );\r
125 \r
126 \r
127 #ifdef __cplusplus\r
128 }\r
129 #endif\r
130 #endif // SKP_Silk_RESAMPLER_H\r
131 \r