Fixing silk fixed point
[opus.git] / silk / 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 #ifndef SILK_RESAMPLER_H\r
29 #define SILK_RESAMPLER_H\r
30 \r
31 #ifdef __cplusplus\r
32 extern "C" {\r
33 #endif\r
34 \r
35 #include "silk_SigProc_FIX.h"\r
36 #include "silk_resampler_structs.h"\r
37 #include "silk_resampler_rom.h"\r
38 \r
39 /* Number of input samples to process in the inner loop */\r
40 #define RESAMPLER_MAX_BATCH_SIZE_IN             480\r
41 \r
42 /* Description: Hybrid IIR/FIR polyphase implementation of resampling   */\r
43 void silk_resampler_private_IIR_FIR(\r
44         void                            *SS,                /* I/O: Resampler state                                             */\r
45         SKP_int16                                               out[],              /* O:       Output signal                                                   */\r
46         const SKP_int16                                 in[],               /* I:       Input signal                                                    */\r
47         SKP_int32                                           inLen                   /* I:       Number of input samples                                 */\r
48 );\r
49 \r
50 /* Description: Hybrid IIR/FIR polyphase implementation of resampling   */\r
51 void silk_resampler_private_down_FIR(\r
52         void                            *SS,                /* I/O: Resampler state                                             */\r
53         SKP_int16                                               out[],              /* O:       Output signal                                                   */\r
54         const SKP_int16                                 in[],               /* I:       Input signal                                                    */\r
55         SKP_int32                                           inLen                   /* I:       Number of input samples                                 */\r
56 );\r
57 \r
58 /* Copy */\r
59 void silk_resampler_private_copy(\r
60         void                            *SS,                /* I/O: Resampler state (unused)                            */\r
61         SKP_int16                                               out[],              /* O:       Output signal                                                   */\r
62         const SKP_int16                                 in[],               /* I:       Input signal                                                    */\r
63         SKP_int32                                           inLen                   /* I:       Number of input samples                                 */\r
64 );\r
65 \r
66 /* Upsample by a factor 2, high quality */\r
67 void silk_resampler_private_up2_HQ_wrapper(\r
68         void                            *SS,                /* I/O: Resampler state (unused)                            */\r
69     SKP_int16                       *out,           /* O:   Output signal [ 2 * len ]               */\r
70     const SKP_int16                 *in,            /* I:   Input signal [ len ]                    */\r
71     SKP_int32                       len             /* I:   Number of input samples                 */\r
72 );\r
73 \r
74 /* Upsample by a factor 2, high quality */\r
75 void silk_resampler_private_up2_HQ(\r
76         SKP_int32                           *S,                     /* I/O: Resampler state [ 6 ]                                       */\r
77     SKP_int16                       *out,           /* O:   Output signal [ 2 * len ]               */\r
78     const SKP_int16                 *in,            /* I:   Input signal [ len ]                    */\r
79     SKP_int32                       len             /* I:   Number of input samples                 */\r
80 );\r
81 \r
82 /* Upsample 4x, low quality */\r
83 void silk_resampler_private_up4(\r
84     SKP_int32                       *S,             /* I/O: State vector [ 2 ]                      */\r
85     SKP_int16                       *out,           /* O:   Output signal [ 4 * len ]               */\r
86     const SKP_int16                 *in,            /* I:   Input signal [ len ]                    */\r
87     SKP_int32                       len             /* I:   Number of input samples                 */\r
88 );\r
89 \r
90 /* Downsample 4x, low quality */\r
91 void silk_resampler_private_down4(\r
92     SKP_int32                       *S,             /* I/O: State vector [ 2 ]                      */\r
93     SKP_int16                       *out,           /* O:   Output signal [ floor(len/2) ]          */\r
94     const SKP_int16                 *in,            /* I:   Input signal [ len ]                    */\r
95     SKP_int32                       inLen           /* I:   Number of input samples                 */\r
96 );\r
97 \r
98 /* Second order AR filter */\r
99 void silk_resampler_private_AR2(\r
100         SKP_int32                                           S[],                    /* I/O: State vector [ 2 ]                              */\r
101         SKP_int32                                           out_Q8[],           /* O:   Output signal                                       */\r
102         const SKP_int16                             in[],                       /* I:   Input signal                                        */\r
103         const SKP_int16                             A_Q14[],            /* I:   AR coefficients, Q14                    */\r
104         SKP_int32                                       len                             /* I:   Signal length                                           */\r
105 );\r
106 \r
107 /* Fourth order ARMA filter */\r
108 void silk_resampler_private_ARMA4(\r
109         SKP_int32                                           S[],                    /* I/O: State vector [ 4 ]                              */\r
110         SKP_int16                                           out[],                  /* O:       Output signal                                       */\r
111         const SKP_int16                             in[],                       /* I:   Input signal                                        */\r
112         const SKP_int16                             Coef[],                 /* I:       ARMA coefficients [ 7 ]                 */\r
113         SKP_int32                                       len                             /* I:   Signal length                                           */\r
114 );\r
115 \r
116 \r
117 #ifdef __cplusplus\r
118 }\r
119 #endif\r
120 #endif // SILK_RESAMPLER_H\r
121 \r