annotate libfaad2/sbr_qmf.c @ 11448:a262f14a33af

fixes
author gabucino
date Wed, 12 Nov 2003 17:44:08 +0000
parents 3185f64f6350
children 4a370c80fe5c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1 /*
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
3 ** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
4 **
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
5 ** This program is free software; you can redistribute it and/or modify
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
6 ** it under the terms of the GNU General Public License as published by
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
7 ** the Free Software Foundation; either version 2 of the License, or
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
8 ** (at your option) any later version.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
9 **
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
10 ** This program is distributed in the hope that it will be useful,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
13 ** GNU General Public License for more details.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
14 **
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
15 ** You should have received a copy of the GNU General Public License
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
16 ** along with this program; if not, write to the Free Software
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
17 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
18 **
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
19 ** Any non-GPL usage of this software or parts of this software is strictly
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
20 ** forbidden.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
21 **
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
22 ** Commercial non-GPL licensing of this software is possible.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
23 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
24 **
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
25 ** $Id: sbr_qmf.c,v 1.13 2003/09/30 12:43:05 menno Exp $
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
26 **/
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
27
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
28 #include "common.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
29 #include "structs.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
30
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
31 #ifdef SBR_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
32
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
33
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
34 #include <stdlib.h>
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
35 #include <string.h>
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
36 #include "sbr_dct.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
37 #include "sbr_qmf.h"
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
38 #include "sbr_qmf_c.h"
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
39 #include "sbr_syntax.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
40
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
41
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
42 qmfa_info *qmfa_init(uint8_t channels)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
43 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
44 qmfa_info *qmfa = (qmfa_info*)malloc(sizeof(qmfa_info));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
45 qmfa->x = (real_t*)malloc(channels * 10 * sizeof(real_t));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
46 memset(qmfa->x, 0, channels * 10 * sizeof(real_t));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
47
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
48 qmfa->channels = channels;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
49
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
50 return qmfa;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
51 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
52
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
53 void qmfa_end(qmfa_info *qmfa)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
54 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
55 if (qmfa)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
56 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
57 if (qmfa->x) free(qmfa->x);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
58 free(qmfa);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
59 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
60 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
61
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
62 void sbr_qmf_analysis_32(sbr_info *sbr, qmfa_info *qmfa, const real_t *input,
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
63 qmf_t *X, uint8_t offset, uint8_t kx)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
64 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
65 uint8_t l;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
66 real_t u[64];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
67 #ifndef SBR_LOW_POWER
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
68 real_t x[64], y[64];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
69 #else
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
70 real_t y[32];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
71 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
72 const real_t *inptr = input;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
73
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
74 /* qmf subsample l */
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
75 for (l = 0; l < sbr->numTimeSlotsRate; l++)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
76 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
77 int16_t n;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
78
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
79 /* shift input buffer x */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
80 memmove(qmfa->x + 32, qmfa->x, (320-32)*sizeof(real_t));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
81
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
82 /* add new samples to input buffer x */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
83 for (n = 32 - 1; n >= 0; n--)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
84 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
85 #ifdef FIXED_POINT
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
86 qmfa->x[n] = (*inptr++) >> 5;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
87 #else
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
88 qmfa->x[n] = *inptr++;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
89 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
90 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
91
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
92 /* window and summation to create array u */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
93 for (n = 0; n < 64; n++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
94 {
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
95 u[n] = MUL_R_C(qmfa->x[n], qmf_c[2*n]) +
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
96 MUL_R_C(qmfa->x[n + 64], qmf_c[2*(n + 64)]) +
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
97 MUL_R_C(qmfa->x[n + 128], qmf_c[2*(n + 128)]) +
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
98 MUL_R_C(qmfa->x[n + 192], qmf_c[2*(n + 192)]) +
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
99 MUL_R_C(qmfa->x[n + 256], qmf_c[2*(n + 256)]);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
100 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
101
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
102 /* calculate 32 subband samples by introducing X */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
103 #ifdef SBR_LOW_POWER
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
104 y[0] = u[48];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
105 for (n = 1; n < 16; n++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
106 y[n] = u[n+48] + u[48-n];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
107 for (n = 16; n < 32; n++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
108 y[n] = -u[n-16] + u[48-n];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
109
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
110 DCT3_32_unscaled(u, y);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
111
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
112 for (n = 0; n < 32; n++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
113 {
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
114 if (n < kx)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
115 {
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
116 #ifdef FIXED_POINT
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
117 QMF_RE(X[((l + offset)<<5) + n]) = u[n] << 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
118 #else
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
119 QMF_RE(X[((l + offset)<<5) + n]) = 2. * u[n];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
120 #endif
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
121 } else {
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
122 QMF_RE(X[((l + offset)<<5) + n]) = 0;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
123 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
124 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
125 #else
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
126 x[0] = u[0];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
127 x[63] = u[32];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
128 for (n = 2; n < 64; n += 2)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
129 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
130 x[n-1] = u[(n>>1)];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
131 x[n] = -u[64-(n>>1)];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
132 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
133
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
134 DCT4_64(y, x);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
135
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
136 for (n = 0; n < 32; n++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
137 {
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
138 if (n < kx)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
139 {
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
140 #ifdef FIXED_POINT
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
141 QMF_RE(X[((l + offset)<<5) + n]) = y[n] << 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
142 QMF_IM(X[((l + offset)<<5) + n]) = -y[63-n] << 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
143 #else
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
144 QMF_RE(X[((l + offset)<<5) + n]) = 2. * y[n];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
145 QMF_IM(X[((l + offset)<<5) + n]) = -2. * y[63-n];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
146 #endif
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
147 } else {
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
148 QMF_RE(X[((l + offset)<<5) + n]) = 0;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
149 QMF_IM(X[((l + offset)<<5) + n]) = 0;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
150 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
151 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
152 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
153 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
154 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
155
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
156 qmfs_info *qmfs_init(uint8_t channels)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
157 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
158 int size = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
159 qmfs_info *qmfs = (qmfs_info*)malloc(sizeof(qmfs_info));
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
160
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
161 qmfs->v[0] = (real_t*)malloc(channels * 10 * sizeof(real_t));
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
162 memset(qmfs->v[0], 0, channels * 10 * sizeof(real_t));
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
163 qmfs->v[1] = (real_t*)malloc(channels * 10 * sizeof(real_t));
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
164 memset(qmfs->v[1], 0, channels * 10 * sizeof(real_t));
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
165
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
166 qmfs->v_index = 0;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
167
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
168 qmfs->channels = channels;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
169
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
170 return qmfs;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
171 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
172
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
173 void qmfs_end(qmfs_info *qmfs)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
174 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
175 if (qmfs)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
176 {
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
177 if (qmfs->v[0]) free(qmfs->v[0]);
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
178 if (qmfs->v[1]) free(qmfs->v[1]);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
179 free(qmfs);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
180 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
181 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
182
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
183 #ifdef SBR_LOW_POWER
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
184 void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, const qmf_t *X,
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
185 real_t *output)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
186 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
187 uint8_t l;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
188 int16_t n, k;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
189 real_t x[64];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
190 real_t *outptr = output;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
191
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
192
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
193 /* qmf subsample l */
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
194 for (l = 0; l < sbr->numTimeSlotsRate; l++)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
195 {
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
196 real_t *v0, *v1;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
197
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
198 /* shift buffers */
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
199 memmove(qmfs->v[0] + 64, qmfs->v[0], (640-64)*sizeof(real_t));
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
200 memmove(qmfs->v[1] + 64, qmfs->v[1], (640-64)*sizeof(real_t));
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
201
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
202 v0 = qmfs->v[qmfs->v_index];
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
203 v1 = qmfs->v[(qmfs->v_index + 1) & 0x1];
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
204 qmfs->v_index = (qmfs->v_index + 1) & 0x1;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
205
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
206 /* calculate 128 samples */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
207 for (k = 0; k < 64; k++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
208 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
209 #ifdef FIXED_POINT
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
210 x[k] = QMF_RE(X[(l<<6) + k]);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
211 #else
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
212 x[k] = QMF_RE(X[(l<<6) + k]) / 32.;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
213 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
214 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
215
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
216 DCT2_64_unscaled(x, x);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
217
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
218 for (n = 0; n < 32; n++)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
219 {
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
220 v0[n+32] = x[n];
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
221 v1[n] = x[n+32];
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
222 }
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
223 v0[0] = v1[0];
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
224 for (n = 1; n < 32; n++)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
225 {
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
226 v0[32 - n] = v0[n + 32];
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
227 v1[n + 32] = -v1[32 - n];
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
228 }
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
229 v1[32] = 0;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
230
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
231 /* calculate 64 output samples and window */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
232 for (k = 0; k < 64; k++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
233 {
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
234 *outptr++ = MUL_R_C(v0[k], qmf_c[k]) +
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
235 MUL_R_C(v0[64 + k], qmf_c[64 + k]) +
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
236 MUL_R_C(v0[128 + k], qmf_c[128 + k]) +
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
237 MUL_R_C(v0[192 + k], qmf_c[192 + k]) +
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
238 MUL_R_C(v0[256 + k], qmf_c[256 + k]) +
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
239 MUL_R_C(v0[320 + k], qmf_c[320 + k]) +
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
240 MUL_R_C(v0[384 + k], qmf_c[384 + k]) +
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
241 MUL_R_C(v0[448 + k], qmf_c[448 + k]) +
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
242 MUL_R_C(v0[512 + k], qmf_c[512 + k]) +
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
243 MUL_R_C(v0[576 + k], qmf_c[576 + k]);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
244 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
245 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
246 }
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
247 #else
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
248 void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, const qmf_t *X,
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
249 real_t *output)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
250 {
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
251 uint8_t l;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
252 int16_t n, k;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
253 real_t x1[64], x2[64];
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
254 real_t *outptr = output;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
255
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
256
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
257 /* qmf subsample l */
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
258 for (l = 0; l < sbr->numTimeSlotsRate; l++)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
259 {
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
260 real_t *v0, *v1;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
261
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
262 /* shift buffers */
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
263 memmove(qmfs->v[0] + 64, qmfs->v[0], (640-64)*sizeof(real_t));
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
264 memmove(qmfs->v[1] + 64, qmfs->v[1], (640-64)*sizeof(real_t));
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
265
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
266 v0 = qmfs->v[qmfs->v_index];
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
267 v1 = qmfs->v[(qmfs->v_index + 1) & 0x1];
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
268 qmfs->v_index = (qmfs->v_index + 1) & 0x1;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
269
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
270 /* calculate 128 samples */
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
271 for (k = 0; k < 64; k++)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
272 {
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
273 x1[k] = QMF_RE(X[(l<<6) + k])/64.;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
274 x2[63 - k] = QMF_IM(X[(l<<6) + k])/64.;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
275 }
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
276
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
277 DCT4_64(x1, x1);
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
278 DCT4_64(x2, x2);
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
279
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
280 for (n = 0; n < 64; n+=2)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
281 {
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
282 v0[n] = x2[n] - x1[n];
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
283 v0[n+1] = -x2[n+1] - x1[n+1];
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
284 v1[63-n] = x2[n] + x1[n];
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
285 v1[63-n-1] = -x2[n+1] + x1[n+1];
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
286 }
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
287
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
288 /* calculate 64 output samples and window */
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
289 for (k = 0; k < 64; k++)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
290 {
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
291 *outptr++ = MUL_R_C(v0[k], qmf_c[k]) +
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
292 MUL_R_C(v0[64 + k], qmf_c[64 + k]) +
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
293 MUL_R_C(v0[128 + k], qmf_c[128 + k]) +
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
294 MUL_R_C(v0[192 + k], qmf_c[192 + k]) +
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
295 MUL_R_C(v0[256 + k], qmf_c[256 + k]) +
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
296 MUL_R_C(v0[320 + k], qmf_c[320 + k]) +
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
297 MUL_R_C(v0[384 + k], qmf_c[384 + k]) +
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
298 MUL_R_C(v0[448 + k], qmf_c[448 + k]) +
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
299 MUL_R_C(v0[512 + k], qmf_c[512 + k]) +
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
300 MUL_R_C(v0[576 + k], qmf_c[576 + k]);
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
301 }
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
302 }
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
303 }
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
304 #endif
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
305
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
306 #endif