blob: 5e6b04476aae74a7e1219d3b118a1e75834a7979 [file] [log] [blame]
Gregory Maxwellae231142011-07-30 08:18:48 -04001/***********************************************************************
2Copyright (c) 2006-2011, Skype Limited. All rights reserved.
3Redistribution and use in source and binary forms, with or without
Jean-Marc Valinae00e602012-04-20 16:31:04 -04004modification, are permitted provided that the following conditions
5are met:
Gregory Maxwellae231142011-07-30 08:18:48 -04006- Redistributions of source code must retain the above copyright notice,
7this list of conditions and the following disclaimer.
8- Redistributions in binary form must reproduce the above copyright
9notice, this list of conditions and the following disclaimer in the
10documentation and/or other materials provided with the distribution.
Ralph Gilesf2446c22013-09-16 14:40:04 -070011- Neither the name of Internet Society, IETF or IETF Trust, nor the
Jean-Marc Valinae00e602012-04-20 16:31:04 -040012names of specific contributors, may be used to endorse or promote
13products derived from this software without specific prior written
14permission.
Timothy B. Terriberry80ad3832013-05-19 18:00:39 -070015THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Jean-Marc Valinae00e602012-04-20 16:31:04 -040016AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25POSSIBILITY OF SUCH DAMAGE.
Gregory Maxwellae231142011-07-30 08:18:48 -040026***********************************************************************/
27
Jean-Marc Valin5a484122011-08-15 10:49:53 -040028#ifdef HAVE_CONFIG_H
29#include "config.h"
30#endif
31
Koen Vosacc7a6c2011-10-28 19:44:26 -040032/* Filter coefficients for IIR/FIR polyphase resampling *
Koen Vosbf75c8e2011-12-13 14:47:31 -050033 * Total size: 179 Words (358 Bytes) */
Gregory Maxwellae231142011-07-30 08:18:48 -040034
Jean-Marc Valin1c2f5632011-09-16 01:16:53 -070035#include "resampler_private.h"
Gregory Maxwellae231142011-07-30 08:18:48 -040036
Koen Vosbf75c8e2011-12-13 14:47:31 -050037/* Matlab code for the notch filter coefficients: */
38/* B = [1, 0.147, 1]; A = [1, 0.107, 0.89]; G = 0.93; freqz(G * B, A, 2^14, 16e3); axis([0, 8000, -10, 1]) */
39/* fprintf('\t%6d, %6d, %6d, %6d\n', round(B(2)*2^16), round(-A(2)*2^16), round((1-A(3))*2^16), round(G*2^15)) */
Diego Elio Pettenò3f2efcb2012-09-10 01:48:24 -070040/* const opus_int16 silk_resampler_up2_hq_notch[ 4 ] = { 9634, -7012, 7209, 30474 }; */
Koen Vosbf75c8e2011-12-13 14:47:31 -050041
42/* Tables with IIR and FIR coefficients for fractional downsamplers (123 Words) */
43silk_DWORD_ALIGN const opus_int16 silk_Resampler_3_4_COEFS[ 2 + 3 * RESAMPLER_DOWN_ORDER_FIR0 / 2 ] = {
Timothy B. Terriberry554b3492014-10-03 21:49:57 -070044 -20694, -13867,
45 -49, 64, 17, -157, 353, -496, 163, 11047, 22205,
46 -39, 6, 91, -170, 186, 23, -896, 6336, 19928,
47 -19, -36, 102, -89, -24, 328, -951, 2568, 15909,
Gregory Maxwellae231142011-07-30 08:18:48 -040048};
49
Koen Vosbf75c8e2011-12-13 14:47:31 -050050silk_DWORD_ALIGN const opus_int16 silk_Resampler_2_3_COEFS[ 2 + 2 * RESAMPLER_DOWN_ORDER_FIR0 / 2 ] = {
Timothy B. Terriberry554b3492014-10-03 21:49:57 -070051 -14457, -14019,
52 64, 128, -122, 36, 310, -768, 584, 9267, 17733,
53 12, 128, 18, -142, 288, -117, -865, 4123, 14459,
Gregory Maxwellae231142011-07-30 08:18:48 -040054};
55
Koen Vosbf75c8e2011-12-13 14:47:31 -050056silk_DWORD_ALIGN const opus_int16 silk_Resampler_1_2_COEFS[ 2 + RESAMPLER_DOWN_ORDER_FIR1 / 2 ] = {
Timothy B. Terriberry554b3492014-10-03 21:49:57 -070057 616, -14323,
58 -10, 39, 58, -46, -84, 120, 184, -315, -541, 1284, 5380, 9024,
Gregory Maxwellae231142011-07-30 08:18:48 -040059};
60
Koen Vosbf75c8e2011-12-13 14:47:31 -050061silk_DWORD_ALIGN const opus_int16 silk_Resampler_1_3_COEFS[ 2 + RESAMPLER_DOWN_ORDER_FIR2 / 2 ] = {
Timothy B. Terriberry554b3492014-10-03 21:49:57 -070062 16102, -15162,
63 -13, 0, 20, 26, 5, -31, -43, -4, 65, 90, 7, -157, -248, -44, 593, 1583, 2612, 3271,
Koen Vosbf75c8e2011-12-13 14:47:31 -050064};
65
66silk_DWORD_ALIGN const opus_int16 silk_Resampler_1_4_COEFS[ 2 + RESAMPLER_DOWN_ORDER_FIR2 / 2 ] = {
Timothy B. Terriberry554b3492014-10-03 21:49:57 -070067 22500, -15099,
68 3, -14, -20, -15, 2, 25, 37, 25, -16, -71, -107, -79, 50, 292, 623, 982, 1288, 1464,
Koen Vosbf75c8e2011-12-13 14:47:31 -050069};
70
71silk_DWORD_ALIGN const opus_int16 silk_Resampler_1_6_COEFS[ 2 + RESAMPLER_DOWN_ORDER_FIR2 / 2 ] = {
Timothy B. Terriberry554b3492014-10-03 21:49:57 -070072 27540, -15257,
73 17, 12, 8, 1, -10, -22, -30, -32, -22, 3, 44, 100, 168, 243, 317, 381, 429, 455,
Gregory Maxwellae231142011-07-30 08:18:48 -040074};
75
Jean-Marc Valinfb3a4372011-09-16 00:58:26 -070076silk_DWORD_ALIGN const opus_int16 silk_Resampler_2_3_COEFS_LQ[ 2 + 2 * 2 ] = {
Gregory Maxwellae231142011-07-30 08:18:48 -040077 -2797, -6507,
78 4697, 10739,
79 1567, 8276,
80};
81
Koen Vosbf75c8e2011-12-13 14:47:31 -050082/* Table with interplation fractions of 1/24, 3/24, 5/24, ... , 23/24 : 23/24 (46 Words) */
83silk_DWORD_ALIGN const opus_int16 silk_resampler_frac_FIR_12[ 12 ][ RESAMPLER_ORDER_FIR_12 / 2 ] = {
Timothy B. Terriberry554b3492014-10-03 21:49:57 -070084 { 189, -600, 617, 30567 },
85 { 117, -159, -1070, 29704 },
86 { 52, 221, -2392, 28276 },
87 { -4, 529, -3350, 26341 },
88 { -48, 758, -3956, 23973 },
89 { -80, 905, -4235, 21254 },
90 { -99, 972, -4222, 18278 },
91 { -107, 967, -3957, 15143 },
92 { -103, 896, -3487, 11950 },
93 { -91, 773, -2865, 8798 },
94 { -71, 611, -2143, 5784 },
95 { -46, 425, -1375, 2996 },
Gregory Maxwellae231142011-07-30 08:18:48 -040096};