Mercurial > mplayer.hg
annotate libfaad2/ssr_ipqf.c @ 13367:81ca72fd45f6
runtime aspect switching, patch by Aurelien Jacobs <aurel at gnuage . org>
author | diego |
---|---|
date | Fri, 17 Sep 2004 15:38:59 +0000 |
parents | d81145997036 |
children | 2ae5ab4331ca |
rev | line source |
---|---|
10725 | 1 /* |
2 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding | |
12527 | 3 ** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com |
10725 | 4 ** |
5 ** This program is free software; you can redistribute it and/or modify | |
6 ** it under the terms of the GNU General Public License as published by | |
7 ** the Free Software Foundation; either version 2 of the License, or | |
8 ** (at your option) any later version. | |
9 ** | |
10 ** This program is distributed in the hope that it will be useful, | |
11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 ** GNU General Public License for more details. | |
14 ** | |
15 ** You should have received a copy of the GNU General Public License | |
16 ** along with this program; if not, write to the Free Software | |
17 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
18 ** | |
19 ** Any non-GPL usage of this software or parts of this software is strictly | |
20 ** forbidden. | |
21 ** | |
22 ** Commercial non-GPL licensing of this software is possible. | |
23 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | |
24 ** | |
12625
d81145997036
More information about modifications to comply more closely with GPL 2a.
diego
parents:
12527
diff
changeset
|
25 ** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30 |
d81145997036
More information about modifications to comply more closely with GPL 2a.
diego
parents:
12527
diff
changeset
|
26 ** $Id: ssr_ipqf.c,v 1.3 2004/06/02 22:59:03 diego Exp $ |
d81145997036
More information about modifications to comply more closely with GPL 2a.
diego
parents:
12527
diff
changeset
|
27 ** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/ |
10725 | 28 **/ |
29 | |
30 #include "common.h" | |
31 #include "structs.h" | |
32 | |
33 #ifdef SSR_DEC | |
34 | |
35 #include "ssr.h" | |
36 #include "ssr_ipqf.h" | |
37 | |
38 static real_t **app_pqfbuf; | |
39 static real_t **pp_q0, **pp_t0, **pp_t1; | |
40 | |
41 void gc_set_protopqf(real_t *p_proto) | |
42 { | |
43 int j; | |
44 static real_t a_half[48] = | |
45 { | |
46 1.2206911375946939E-05, 1.7261986723798209E-05, 1.2300093657077942E-05, | |
47 -1.0833943097791965E-05, -5.7772498639901686E-05, -1.2764767618947719E-04, | |
48 -2.0965186675013334E-04, -2.8166673689263850E-04, -3.1234860429017460E-04, | |
49 -2.6738519958452353E-04, -1.1949424681824722E-04, 1.3965139412648678E-04, | |
50 4.8864136409185725E-04, 8.7044629275148344E-04, 1.1949430269934793E-03, | |
51 1.3519708175026700E-03, 1.2346314373964412E-03, 7.6953209114159191E-04, | |
52 -5.2242432579537141E-05, -1.1516092887213454E-03, -2.3538469841711277E-03, | |
53 -3.4033123072127277E-03, -4.0028551071986133E-03, -3.8745415659693259E-03, | |
54 -2.8321073426874310E-03, -8.5038892323704195E-04, 1.8856751185350931E-03, | |
55 4.9688741735340923E-03, 7.8056704536795926E-03, 9.7027909685901654E-03, | |
56 9.9960423120166159E-03, 8.2019366335594487E-03, 4.1642072876103365E-03, | |
57 -1.8364453822737758E-03, -9.0384863094167686E-03, -1.6241528177129844E-02, | |
58 -2.1939551286300665E-02, -2.4533179947088161E-02, -2.2591663337768787E-02, | |
59 -1.5122066420044672E-02, -1.7971713448186293E-03, 1.6903413428575379E-02, | |
60 3.9672315874127042E-02, 6.4487527248102796E-02, 8.8850025474701726E-02, | |
61 0.1101132906105560 , 0.1258540205143761 , 0.1342239368467012 | |
62 }; | |
63 | |
64 for (j = 0; j < 48; ++j) | |
65 { | |
66 p_proto[j] = p_proto[95-j] = a_half[j]; | |
67 } | |
68 } | |
69 | |
70 void gc_setcoef_eff_pqfsyn(int mm, | |
71 int kk, | |
72 real_t *p_proto, | |
73 real_t ***ppp_q0, | |
74 real_t ***ppp_t0, | |
75 real_t ***ppp_t1) | |
76 { | |
77 int i, k, n; | |
78 real_t w; | |
79 | |
80 /* Set 1st Mul&Acc Coef's */ | |
81 *ppp_q0 = (real_t **) calloc(mm, sizeof(real_t *)); | |
82 for (n = 0; n < mm; ++n) | |
83 { | |
84 (*ppp_q0)[n] = (real_t *) calloc(mm, sizeof(real_t)); | |
85 } | |
86 for (n = 0; n < mm/2; ++n) | |
87 { | |
88 for (i = 0; i < mm; ++i) | |
89 { | |
90 w = (2*i+1)*(2*n+1-mm)*M_PI/(4*mm); | |
91 (*ppp_q0)[n][i] = 2.0 * cos((real_t) w); | |
92 | |
93 w = (2*i+1)*(2*(mm+n)+1-mm)*M_PI/(4*mm); | |
94 (*ppp_q0)[n + mm/2][i] = 2.0 * cos((real_t) w); | |
95 } | |
96 } | |
97 | |
98 /* Set 2nd Mul&Acc Coef's */ | |
99 *ppp_t0 = (real_t **) calloc(mm, sizeof(real_t *)); | |
100 *ppp_t1 = (real_t **) calloc(mm, sizeof(real_t *)); | |
101 for (n = 0; n < mm; ++n) | |
102 { | |
103 (*ppp_t0)[n] = (real_t *) calloc(kk, sizeof(real_t)); | |
104 (*ppp_t1)[n] = (real_t *) calloc(kk, sizeof(real_t)); | |
105 } | |
106 for (n = 0; n < mm; ++n) | |
107 { | |
108 for (k = 0; k < kk; ++k) | |
109 { | |
110 (*ppp_t0)[n][k] = mm * p_proto[2*k *mm + n]; | |
111 (*ppp_t1)[n][k] = mm * p_proto[(2*k+1)*mm + n]; | |
112 | |
113 if (k%2 != 0) | |
114 { | |
115 (*ppp_t0)[n][k] = -(*ppp_t0)[n][k]; | |
116 (*ppp_t1)[n][k] = -(*ppp_t1)[n][k]; | |
117 } | |
118 } | |
119 } | |
120 } | |
121 | |
122 void ssr_ipqf(ssr_info *ssr, real_t *in_data, real_t *out_data, | |
123 real_t buffer[SSR_BANDS][96/4], | |
124 uint16_t frame_len, uint8_t bands) | |
125 { | |
126 static int initFlag = 0; | |
127 real_t a_pqfproto[PQFTAPS]; | |
128 | |
129 int i; | |
130 | |
131 if (initFlag == 0) | |
132 { | |
133 gc_set_protopqf(a_pqfproto); | |
134 gc_setcoef_eff_pqfsyn(SSR_BANDS, PQFTAPS/(2*SSR_BANDS), a_pqfproto, | |
135 &pp_q0, &pp_t0, &pp_t1); | |
136 initFlag = 1; | |
137 } | |
138 | |
139 for (i = 0; i < frame_len / SSR_BANDS; i++) | |
140 { | |
141 int l, n, k; | |
142 int mm = SSR_BANDS; | |
143 int kk = PQFTAPS/(2*SSR_BANDS); | |
144 | |
145 for (n = 0; n < mm; n++) | |
146 { | |
147 for (k = 0; k < 2*kk-1; k++) | |
148 { | |
149 buffer[n][k] = buffer[n][k+1]; | |
150 } | |
151 } | |
152 | |
153 for (n = 0; n < mm; n++) | |
154 { | |
155 real_t acc = 0.0; | |
156 for (l = 0; l < mm; l++) | |
157 { | |
158 acc += pp_q0[n][l] * in_data[l*frame_len/SSR_BANDS + i]; | |
159 } | |
160 buffer[n][2*kk-1] = acc; | |
161 } | |
162 | |
163 for (n = 0; n < mm/2; n++) | |
164 { | |
165 real_t acc = 0.0; | |
166 for (k = 0; k < kk; k++) | |
167 { | |
168 acc += pp_t0[n][k] * buffer[n][2*kk-1-2*k]; | |
169 } | |
170 for (k = 0; k < kk; ++k) | |
171 { | |
172 acc += pp_t1[n][k] * buffer[n + mm/2][2*kk-2-2*k]; | |
173 } | |
174 out_data[i*SSR_BANDS + n] = acc; | |
175 | |
176 acc = 0.0; | |
177 for (k = 0; k < kk; k++) | |
178 { | |
179 acc += pp_t0[mm-1-n][k] * buffer[n][2*kk-1-2*k]; | |
180 } | |
181 for (k = 0; k < kk; k++) | |
182 { | |
183 acc -= pp_t1[mm-1-n][k] * buffer[n + mm/2][2*kk-2-2*k]; | |
184 } | |
185 out_data[i*SSR_BANDS + mm-1-n] = acc; | |
186 } | |
187 } | |
188 } | |
189 | |
190 #endif |