annotate libfaad2/sbr_hfgen.c @ 14223:becddea18201

forgot to remove now useless extern monitor_aspect
author reimar
date Thu, 23 Dec 2004 12:49:31 +0000
parents 6d50ef45a058
children 2ae5ab4331ca
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
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
3 ** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com
10725
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 **
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
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
26 ** $Id: sbr_hfgen.c,v 1.4 2004/06/23 13:50:52 diego Exp $
12625
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
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
28 **/
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
29
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
30 /* High Frequency generation */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
31
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
32 #include "common.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
33 #include "structs.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
34
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
35 #ifdef SBR_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
36
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
37 #include "sbr_syntax.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
38 #include "sbr_hfgen.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
39 #include "sbr_fbt.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
40
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
41
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
42 /* static function declarations */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
43 #ifdef SBR_LOW_POWER
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
44 static void calc_prediction_coef_lp(sbr_info *sbr, qmf_t Xlow[MAX_NTSRHFG][64],
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
45 complex_t *alpha_0, complex_t *alpha_1, real_t *rxx);
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
46 static void calc_aliasing_degree(sbr_info *sbr, real_t *rxx, real_t *deg);
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
47 #else
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
48 static void calc_prediction_coef(sbr_info *sbr, qmf_t Xlow[MAX_NTSRHFG][64],
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
49 complex_t *alpha_0, complex_t *alpha_1, uint8_t k);
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
50 #endif
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
51 static void calc_chirp_factors(sbr_info *sbr, uint8_t ch);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
52 static void patch_construction(sbr_info *sbr);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
53
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
54
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
55 void hf_generation(sbr_info *sbr, qmf_t Xlow[MAX_NTSRHFG][64],
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
56 qmf_t Xhigh[MAX_NTSRHFG][64]
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
57 #ifdef SBR_LOW_POWER
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
58 ,real_t *deg
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
59 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
60 ,uint8_t ch)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
61 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
62 uint8_t l, i, x;
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
63 ALIGN complex_t alpha_0[64], alpha_1[64];
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
64 #ifdef SBR_LOW_POWER
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
65 ALIGN real_t rxx[64];
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
66 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
67
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
68 uint8_t offset = sbr->tHFAdj;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
69 uint8_t first = sbr->t_E[ch][0];
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
70 uint8_t last = sbr->t_E[ch][sbr->L_E[ch]];
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
71
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
72 calc_chirp_factors(sbr, ch);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
73
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
74 #ifdef SBR_LOW_POWER
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
75 memset(deg, 0, 64*sizeof(real_t));
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
76 #endif
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
77
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
78 if ((ch == 0) && (sbr->Reset))
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
79 patch_construction(sbr);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
80
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
81 /* calculate the prediction coefficients */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
82 #ifdef SBR_LOW_POWER
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
83 calc_prediction_coef_lp(sbr, Xlow, alpha_0, alpha_1, rxx);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
84 calc_aliasing_degree(sbr, rxx, deg);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
85 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
86
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
87 /* actual HF generation */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
88 for (i = 0; i < sbr->noPatches; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
89 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
90 for (x = 0; x < sbr->patchNoSubbands[i]; x++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
91 {
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
92 real_t a0_r, a0_i, a1_r, a1_i;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
93 real_t bw, bw2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
94 uint8_t q, p, k, g;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
95
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
96 /* find the low and high band for patching */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
97 k = sbr->kx + x;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
98 for (q = 0; q < i; q++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
99 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
100 k += sbr->patchNoSubbands[q];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
101 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
102 p = sbr->patchStartSubband[i] + x;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
103
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
104 #ifdef SBR_LOW_POWER
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
105 if (x != 0 /*x < sbr->patchNoSubbands[i]-1*/)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
106 deg[k] = deg[p];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
107 else
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
108 deg[k] = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
109 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
110
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
111 g = sbr->table_map_k_to_g[k];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
112
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
113 bw = sbr->bwArray[ch][g];
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
114 bw2 = MUL_C(bw, bw);
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
115
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
116 /* do the patching */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
117 /* with or without filtering */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
118 if (bw2 > 0)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
119 {
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
120 real_t temp1_r, temp2_r, temp3_r;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
121 #ifndef SBR_LOW_POWER
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
122 real_t temp1_i, temp2_i, temp3_i;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
123 calc_prediction_coef(sbr, Xlow, alpha_0, alpha_1, p);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
124 #endif
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
125
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
126 a0_r = MUL_C(RE(alpha_0[p]), bw);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
127 a1_r = MUL_C(RE(alpha_1[p]), bw2);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
128 #ifndef SBR_LOW_POWER
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
129 a0_i = MUL_C(IM(alpha_0[p]), bw);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
130 a1_i = MUL_C(IM(alpha_1[p]), bw2);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
131 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
132
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
133 temp2_r = QMF_RE(Xlow[first - 2 + offset][p]);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
134 temp3_r = QMF_RE(Xlow[first - 1 + offset][p]);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
135 #ifndef SBR_LOW_POWER
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
136 temp2_i = QMF_IM(Xlow[first - 2 + offset][p]);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
137 temp3_i = QMF_IM(Xlow[first - 1 + offset][p]);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
138 #endif
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
139 for (l = first; l < last; l++)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
140 {
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
141 temp1_r = temp2_r;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
142 temp2_r = temp3_r;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
143 temp3_r = QMF_RE(Xlow[l + offset][p]);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
144 #ifndef SBR_LOW_POWER
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
145 temp1_i = temp2_i;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
146 temp2_i = temp3_i;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
147 temp3_i = QMF_IM(Xlow[l + offset][p]);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
148 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
149
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
150 #ifdef SBR_LOW_POWER
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
151 QMF_RE(Xhigh[l + offset][k]) =
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
152 temp3_r
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
153 +(MUL_R(a0_r, temp2_r) +
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
154 MUL_R(a1_r, temp1_r));
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
155 #else
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
156 QMF_RE(Xhigh[l + offset][k]) =
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
157 temp3_r
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
158 +(MUL_R(a0_r, temp2_r) -
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
159 MUL_R(a0_i, temp2_i) +
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
160 MUL_R(a1_r, temp1_r) -
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
161 MUL_R(a1_i, temp1_i));
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
162 QMF_IM(Xhigh[l + offset][k]) =
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
163 temp3_i
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
164 +(MUL_R(a0_i, temp2_r) +
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
165 MUL_R(a0_r, temp2_i) +
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
166 MUL_R(a1_i, temp1_r) +
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
167 MUL_R(a1_r, temp1_i));
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
168 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
169 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
170 } else {
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
171 for (l = first; l < last; l++)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
172 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
173 QMF_RE(Xhigh[l + offset][k]) = QMF_RE(Xlow[l + offset][p]);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
174 #ifndef SBR_LOW_POWER
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
175 QMF_IM(Xhigh[l + offset][k]) = QMF_IM(Xlow[l + offset][p]);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
176 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
177 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
178 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
179 }
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 if (sbr->Reset)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
183 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
184 limiter_frequency_table(sbr);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
185 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
186 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
187
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
188 typedef struct
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
189 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
190 complex_t r01;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
191 complex_t r02;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
192 complex_t r11;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
193 complex_t r12;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
194 complex_t r22;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
195 real_t det;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
196 } acorr_coef;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
197
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
198 #ifdef SBR_LOW_POWER
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
199 static void auto_correlation(sbr_info *sbr, acorr_coef *ac,
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
200 qmf_t buffer[MAX_NTSRHFG][64],
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
201 uint8_t bd, uint8_t len)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
202 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
203 real_t r01 = 0, r02 = 0, r11 = 0;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
204 int8_t j;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
205 uint8_t offset = sbr->tHFAdj;
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
206 #ifdef FIXED_POINT
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
207 const real_t rel = FRAC_CONST(0.999999); // 1 / (1 + 1e-6f);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
208 uint32_t maxi = 0;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
209 uint32_t pow2, exp;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
210 #else
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
211 const real_t rel = 1 / (1 + 1e-6f);
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
212 #endif
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
213
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
214
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
215 #ifdef FIXED_POINT
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
216 mask = 0;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
217
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
218 for (j = (offset-2); j < (len + offset); j++)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
219 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
220 real_t x;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
221 x = QMF_RE(buffer[j][bd])>>REAL_BITS;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
222 mask |= x ^ (x >> 31);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
223 }
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
224
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
225 exp = wl_min_lzc(mask);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
226
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
227 /* improves accuracy */
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
228 if (exp > 0)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
229 exp -= 1;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
230
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
231 for (j = offset; j < len + offset; j++)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
232 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
233 real_t buf_j = ((QMF_RE(buffer[j][bd])+(1<<(exp-1)))>>exp);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
234 real_t buf_j_1 = ((QMF_RE(buffer[j-1][bd])+(1<<(exp-1)))>>exp);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
235 real_t buf_j_2 = ((QMF_RE(buffer[j-2][bd])+(1<<(exp-1)))>>exp);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
236
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
237 /* normalisation with rounding */
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
238 r01 += MUL_R(buf_j, buf_j_1);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
239 r02 += MUL_R(buf_j, buf_j_2);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
240 r11 += MUL_R(buf_j_1, buf_j_1);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
241 }
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
242 RE(ac->r12) = r01 -
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
243 MUL_R(((QMF_RE(buffer[len+offset-1][bd])+(1<<(exp-1)))>>exp), ((QMF_RE(buffer[len+offset-2][bd])+(1<<(exp-1)))>>exp)) +
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
244 MUL_R(((QMF_RE(buffer[offset-1][bd])+(1<<(exp-1)))>>exp), ((QMF_RE(buffer[offset-2][bd])+(1<<(exp-1)))>>exp));
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
245 RE(ac->r22) = r11 -
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
246 MUL_R(((QMF_RE(buffer[len+offset-2][bd])+(1<<(exp-1)))>>exp), ((QMF_RE(buffer[len+offset-2][bd])+(1<<(exp-1)))>>exp)) +
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
247 MUL_R(((QMF_RE(buffer[offset-2][bd])+(1<<(exp-1)))>>exp), ((QMF_RE(buffer[offset-2][bd])+(1<<(exp-1)))>>exp));
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
248 #else
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
249 for (j = offset; j < len + offset; j++)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
250 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
251 r01 += QMF_RE(buffer[j][bd]) * QMF_RE(buffer[j-1][bd]);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
252 r02 += QMF_RE(buffer[j][bd]) * QMF_RE(buffer[j-2][bd]);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
253 r11 += QMF_RE(buffer[j-1][bd]) * QMF_RE(buffer[j-1][bd]);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
254 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
255 RE(ac->r12) = r01 -
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
256 QMF_RE(buffer[len+offset-1][bd]) * QMF_RE(buffer[len+offset-2][bd]) +
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
257 QMF_RE(buffer[offset-1][bd]) * QMF_RE(buffer[offset-2][bd]);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
258 RE(ac->r22) = r11 -
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
259 QMF_RE(buffer[len+offset-2][bd]) * QMF_RE(buffer[len+offset-2][bd]) +
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
260 QMF_RE(buffer[offset-2][bd]) * QMF_RE(buffer[offset-2][bd]);
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
261 #endif
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
262 RE(ac->r01) = r01;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
263 RE(ac->r02) = r02;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
264 RE(ac->r11) = r11;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
265
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
266 ac->det = MUL_R(RE(ac->r11), RE(ac->r22)) - MUL_F(MUL_R(RE(ac->r12), RE(ac->r12)), rel);
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
267 }
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
268 #else
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
269 static void auto_correlation(sbr_info *sbr, acorr_coef *ac, qmf_t buffer[MAX_NTSRHFG][64],
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
270 uint8_t bd, uint8_t len)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
271 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
272 real_t r01r = 0, r01i = 0, r02r = 0, r02i = 0, r11r = 0;
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
273 real_t temp1_r, temp1_i, temp2_r, temp2_i, temp3_r, temp3_i, temp4_r, temp4_i, temp5_r, temp5_i;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
274 #ifdef FIXED_POINT
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
275 const real_t rel = FRAC_CONST(0.999999); // 1 / (1 + 1e-6f);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
276 uint32_t mask, exp;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
277 real_t pow2_to_exp;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
278 #else
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
279 const real_t rel = 1 / (1 + 1e-6f);
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
280 #endif
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
281 int8_t j;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
282 uint8_t offset = sbr->tHFAdj;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
283
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
284 #ifdef FIXED_POINT
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
285 mask = 0;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
286
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
287 for (j = (offset-2); j < (len + offset); j++)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
288 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
289 real_t x;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
290 x = QMF_RE(buffer[j][bd])>>REAL_BITS;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
291 mask |= x ^ (x >> 31);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
292 x = QMF_IM(buffer[j][bd])>>REAL_BITS;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
293 mask |= x ^ (x >> 31);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
294 }
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
295
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
296 exp = wl_min_lzc(mask);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
297
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
298 /* improves accuracy */
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
299 if (exp > 0)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
300 exp -= 1;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
301
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
302 pow2_to_exp = 1<<(exp-1);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
303
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
304 temp2_r = (QMF_RE(buffer[offset-2][bd]) + pow2_to_exp) >> exp;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
305 temp2_i = (QMF_IM(buffer[offset-2][bd]) + pow2_to_exp) >> exp;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
306 temp3_r = (QMF_RE(buffer[offset-1][bd]) + pow2_to_exp) >> exp;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
307 temp3_i = (QMF_IM(buffer[offset-1][bd]) + pow2_to_exp) >> exp;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
308 // Save these because they are needed after loop
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
309 temp4_r = temp2_r;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
310 temp4_i = temp2_i;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
311 temp5_r = temp3_r;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
312 temp5_i = temp3_i;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
313
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
314 for (j = offset; j < len + offset; j++)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
315 {
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
316 temp1_r = temp2_r; // temp1_r = (QMF_RE(buffer[offset-2][bd] + (1<<(exp-1))) >> exp;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
317 temp1_i = temp2_i; // temp1_i = (QMF_IM(buffer[offset-2][bd] + (1<<(exp-1))) >> exp;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
318 temp2_r = temp3_r; // temp2_r = (QMF_RE(buffer[offset-1][bd] + (1<<(exp-1))) >> exp;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
319 temp2_i = temp3_i; // temp2_i = (QMF_IM(buffer[offset-1][bd] + (1<<(exp-1))) >> exp;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
320 temp3_r = (QMF_RE(buffer[j][bd]) + pow2_to_exp) >> exp;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
321 temp3_i = (QMF_IM(buffer[j][bd]) + pow2_to_exp) >> exp;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
322 r01r += MUL_R(temp3_r, temp2_r) + MUL_R(temp3_i, temp2_i);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
323 r01i += MUL_R(temp3_i, temp2_r) - MUL_R(temp3_r, temp2_i);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
324 r02r += MUL_R(temp3_r, temp1_r) + MUL_R(temp3_i, temp1_i);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
325 r02i += MUL_R(temp3_i, temp1_r) - MUL_R(temp3_r, temp1_i);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
326 r11r += MUL_R(temp2_r, temp2_r) + MUL_R(temp2_i, temp2_i);
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
327 }
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
328
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
329 // These are actual values in temporary variable at this point
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
330 // temp1_r = (QMF_RE(buffer[len+offset-1-2][bd] + (1<<(exp-1))) >> exp;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
331 // temp1_i = (QMF_IM(buffer[len+offset-1-2][bd] + (1<<(exp-1))) >> exp;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
332 // temp2_r = (QMF_RE(buffer[len+offset-1-1][bd] + (1<<(exp-1))) >> exp;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
333 // temp2_i = (QMF_IM(buffer[len+offset-1-1][bd] + (1<<(exp-1))) >> exp;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
334 // temp3_r = (QMF_RE(buffer[len+offset-1][bd]) + (1<<(exp-1))) >> exp;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
335 // temp3_i = (QMF_IM(buffer[len+offset-1][bd]) + (1<<(exp-1))) >> exp;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
336 // temp4_r = (QMF_RE(buffer[offset-2][bd]) + (1<<(exp-1))) >> exp;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
337 // temp4_i = (QMF_IM(buffer[offset-2][bd]) + (1<<(exp-1))) >> exp;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
338 // temp5_r = (QMF_RE(buffer[offset-1][bd]) + (1<<(exp-1))) >> exp;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
339 // temp5_i = (QMF_IM(buffer[offset-1][bd]) + (1<<(exp-1))) >> exp;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
340
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
341 RE(ac->r12) = r01r -
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
342 (MUL_R(temp3_r, temp2_r) + MUL_R(temp3_i, temp2_i)) +
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
343 (MUL_R(temp5_r, temp4_r) + MUL_R(temp5_i, temp4_i));
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
344 IM(ac->r12) = r01i -
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
345 (MUL_R(temp3_i, temp2_r) - MUL_R(temp3_r, temp2_i)) +
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
346 (MUL_R(temp5_i, temp4_r) - MUL_R(temp5_r, temp4_i));
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
347 RE(ac->r22) = r11r -
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
348 (MUL_R(temp2_r, temp2_r) + MUL_R(temp2_i, temp2_i)) +
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
349 (MUL_R(temp4_r, temp4_r) + MUL_R(temp4_i, temp4_i));
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
350
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
351 #else
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
352
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
353 temp2_r = QMF_RE(buffer[offset-2][bd]);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
354 temp2_i = QMF_IM(buffer[offset-2][bd]);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
355 temp3_r = QMF_RE(buffer[offset-1][bd]);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
356 temp3_i = QMF_IM(buffer[offset-1][bd]);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
357 // Save these because they are needed after loop
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
358 temp4_r = temp2_r;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
359 temp4_i = temp2_i;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
360 temp5_r = temp3_r;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
361 temp5_i = temp3_i;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
362
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
363 for (j = offset; j < len + offset; j++)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
364 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
365 temp1_r = temp2_r; // temp1_r = QMF_RE(buffer[j-2][bd];
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
366 temp1_i = temp2_i; // temp1_i = QMF_IM(buffer[j-2][bd];
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
367 temp2_r = temp3_r; // temp2_r = QMF_RE(buffer[j-1][bd];
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
368 temp2_i = temp3_i; // temp2_i = QMF_IM(buffer[j-1][bd];
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
369 temp3_r = QMF_RE(buffer[j][bd]);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
370 temp3_i = QMF_IM(buffer[j][bd]);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
371 r01r += temp3_r * temp2_r + temp3_i * temp2_i;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
372 r01i += temp3_i * temp2_r - temp3_r * temp2_i;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
373 r02r += temp3_r * temp1_r + temp3_i * temp1_i;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
374 r02i += temp3_i * temp1_r - temp3_r * temp1_i;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
375 r11r += temp2_r * temp2_r + temp2_i * temp2_i;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
376 }
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
377
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
378 // These are actual values in temporary variable at this point
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
379 // temp1_r = QMF_RE(buffer[len+offset-1-2][bd];
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
380 // temp1_i = QMF_IM(buffer[len+offset-1-2][bd];
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
381 // temp2_r = QMF_RE(buffer[len+offset-1-1][bd];
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
382 // temp2_i = QMF_IM(buffer[len+offset-1-1][bd];
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
383 // temp3_r = QMF_RE(buffer[len+offset-1][bd]);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
384 // temp3_i = QMF_IM(buffer[len+offset-1][bd]);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
385 // temp4_r = QMF_RE(buffer[offset-2][bd]);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
386 // temp4_i = QMF_IM(buffer[offset-2][bd]);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
387 // temp5_r = QMF_RE(buffer[offset-1][bd]);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
388 // temp5_i = QMF_IM(buffer[offset-1][bd]);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
389
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
390 RE(ac->r12) = r01r -
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
391 (temp3_r * temp2_r + temp3_i * temp2_i) +
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
392 (temp5_r * temp4_r + temp5_i * temp4_i);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
393 IM(ac->r12) = r01i -
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
394 (temp3_i * temp2_r - temp3_r * temp2_i) +
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
395 (temp5_i * temp4_r - temp5_r * temp4_i);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
396 RE(ac->r22) = r11r -
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
397 (temp2_r * temp2_r + temp2_i * temp2_i) +
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
398 (temp4_r * temp4_r + temp4_i * temp4_i);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
399
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
400 #endif
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
401
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
402 RE(ac->r01) = r01r;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
403 IM(ac->r01) = r01i;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
404 RE(ac->r02) = r02r;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
405 IM(ac->r02) = r02i;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
406 RE(ac->r11) = r11r;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
407
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
408 ac->det = MUL_R(RE(ac->r11), RE(ac->r22)) - MUL_F(rel, (MUL_R(RE(ac->r12), RE(ac->r12)) + MUL_R(IM(ac->r12), IM(ac->r12))));
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
409 }
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
410 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
411
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
412 /* calculate linear prediction coefficients using the covariance method */
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
413 #ifndef SBR_LOW_POWER
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
414 static void calc_prediction_coef(sbr_info *sbr, qmf_t Xlow[MAX_NTSRHFG][64],
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
415 complex_t *alpha_0, complex_t *alpha_1, uint8_t k)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
416 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
417 real_t tmp;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
418 acorr_coef ac;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
419
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
420 auto_correlation(sbr, &ac, Xlow, k, sbr->numTimeSlotsRate + 6);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
421
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
422 if (ac.det == 0)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
423 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
424 RE(alpha_1[k]) = 0;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
425 IM(alpha_1[k]) = 0;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
426 } else {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
427 #ifdef FIXED_POINT
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
428 tmp = (MUL_R(RE(ac.r01), RE(ac.r12)) - MUL_R(IM(ac.r01), IM(ac.r12)) - MUL_R(RE(ac.r02), RE(ac.r11)));
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
429 RE(alpha_1[k]) = DIV_R(tmp, ac.det);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
430 tmp = (MUL_R(IM(ac.r01), RE(ac.r12)) + MUL_R(RE(ac.r01), IM(ac.r12)) - MUL_R(IM(ac.r02), RE(ac.r11)));
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
431 IM(alpha_1[k]) = DIV_R(tmp, ac.det);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
432 #else
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
433 tmp = REAL_CONST(1.0) / ac.det;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
434 RE(alpha_1[k]) = (MUL_R(RE(ac.r01), RE(ac.r12)) - MUL_R(IM(ac.r01), IM(ac.r12)) - MUL_R(RE(ac.r02), RE(ac.r11))) * tmp;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
435 IM(alpha_1[k]) = (MUL_R(IM(ac.r01), RE(ac.r12)) + MUL_R(RE(ac.r01), IM(ac.r12)) - MUL_R(IM(ac.r02), RE(ac.r11))) * tmp;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
436 #endif
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
437 }
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
438
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
439 if (RE(ac.r11) == 0)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
440 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
441 RE(alpha_0[k]) = 0;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
442 IM(alpha_0[k]) = 0;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
443 } else {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
444 #ifdef FIXED_POINT
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
445 tmp = -(RE(ac.r01) + MUL_R(RE(alpha_1[k]), RE(ac.r12)) + MUL_R(IM(alpha_1[k]), IM(ac.r12)));
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
446 RE(alpha_0[k]) = DIV_R(tmp, RE(ac.r11));
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
447 tmp = -(IM(ac.r01) + MUL_R(IM(alpha_1[k]), RE(ac.r12)) - MUL_R(RE(alpha_1[k]), IM(ac.r12)));
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
448 IM(alpha_0[k]) = DIV_R(tmp, RE(ac.r11));
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
449 #else
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
450 tmp = 1.0f / RE(ac.r11);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
451 RE(alpha_0[k]) = -(RE(ac.r01) + MUL_R(RE(alpha_1[k]), RE(ac.r12)) + MUL_R(IM(alpha_1[k]), IM(ac.r12))) * tmp;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
452 IM(alpha_0[k]) = -(IM(ac.r01) + MUL_R(IM(alpha_1[k]), RE(ac.r12)) - MUL_R(RE(alpha_1[k]), IM(ac.r12))) * tmp;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
453 #endif
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
454 }
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
455
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
456 if ((MUL_R(RE(alpha_0[k]),RE(alpha_0[k])) + MUL_R(IM(alpha_0[k]),IM(alpha_0[k])) >= REAL_CONST(16)) ||
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
457 (MUL_R(RE(alpha_1[k]),RE(alpha_1[k])) + MUL_R(IM(alpha_1[k]),IM(alpha_1[k])) >= REAL_CONST(16)))
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
458 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
459 RE(alpha_0[k]) = 0;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
460 IM(alpha_0[k]) = 0;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
461 RE(alpha_1[k]) = 0;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
462 IM(alpha_1[k]) = 0;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
463 }
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
464 }
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
465 #else
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
466 static void calc_prediction_coef_lp(sbr_info *sbr, qmf_t Xlow[MAX_NTSRHFG][64],
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
467 complex_t *alpha_0, complex_t *alpha_1, real_t *rxx)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
468 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
469 uint8_t k;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
470 real_t tmp;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
471 acorr_coef ac;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
472
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
473 for (k = 1; k < sbr->f_master[0]; k++)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
474 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
475 auto_correlation(sbr, &ac, Xlow, k, sbr->numTimeSlotsRate + 6);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
476
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
477 if (ac.det == 0)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
478 {
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
479 RE(alpha_0[k]) = 0;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
480 RE(alpha_1[k]) = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
481 } else {
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
482 tmp = MUL_R(RE(ac.r01), RE(ac.r22)) - MUL_R(RE(ac.r12), RE(ac.r02));
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
483 RE(alpha_0[k]) = DIV_R(tmp, (-ac.det));
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
484
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
485 tmp = MUL_R(RE(ac.r01), RE(ac.r12)) - MUL_R(RE(ac.r02), RE(ac.r11));
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
486 RE(alpha_1[k]) = DIV_R(tmp, ac.det);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
487 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
488
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
489 if ((RE(alpha_0[k]) >= REAL_CONST(4)) || (RE(alpha_1[k]) >= REAL_CONST(4)))
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
490 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
491 RE(alpha_0[k]) = REAL_CONST(0);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
492 RE(alpha_1[k]) = REAL_CONST(0);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
493 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
494
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
495 /* reflection coefficient */
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
496 if (RE(ac.r11) == 0)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
497 {
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
498 rxx[k] = COEF_CONST(0.0);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
499 } else {
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
500 rxx[k] = DIV_C(RE(ac.r01), RE(ac.r11));
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
501 rxx[k] = -rxx[k];
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
502 if (rxx[k] > COEF_CONST(1.0)) rxx[k] = COEF_CONST(1.0);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
503 if (rxx[k] < COEF_CONST(-1.0)) rxx[k] = COEF_CONST(-1.0);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
504 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
505 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
506 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
507
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
508 static void calc_aliasing_degree(sbr_info *sbr, real_t *rxx, real_t *deg)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
509 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
510 uint8_t k;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
511
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
512 rxx[0] = COEF_CONST(0.0);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
513 deg[1] = COEF_CONST(0.0);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
514
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
515 for (k = 2; k < sbr->k0; k++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
516 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
517 deg[k] = 0.0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
518
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
519 if ((k % 2 == 0) && (rxx[k] < COEF_CONST(0.0)))
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
520 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
521 if (rxx[k-1] < 0.0)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
522 {
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
523 deg[k] = COEF_CONST(1.0);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
524
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
525 if (rxx[k-2] > COEF_CONST(0.0))
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
526 {
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
527 deg[k-1] = COEF_CONST(1.0) - MUL_C(rxx[k-1], rxx[k-1]);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
528 }
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
529 } else if (rxx[k-2] > COEF_CONST(0.0)) {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
530 deg[k] = COEF_CONST(1.0) - MUL_C(rxx[k-1], rxx[k-1]);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
531 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
532 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
533
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
534 if ((k % 2 == 1) && (rxx[k] > COEF_CONST(0.0)))
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
535 {
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
536 if (rxx[k-1] > COEF_CONST(0.0))
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
537 {
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
538 deg[k] = COEF_CONST(1.0);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
539
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
540 if (rxx[k-2] < COEF_CONST(0.0))
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
541 {
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
542 deg[k-1] = COEF_CONST(1.0) - MUL_C(rxx[k-1], rxx[k-1]);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
543 }
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
544 } else if (rxx[k-2] < COEF_CONST(0.0)) {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
545 deg[k] = COEF_CONST(1.0) - MUL_C(rxx[k-1], rxx[k-1]);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
546 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
547 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
548 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
549 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
550 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
551
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
552 /* FIXED POINT: bwArray = COEF */
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
553 static real_t mapNewBw(uint8_t invf_mode, uint8_t invf_mode_prev)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
554 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
555 switch (invf_mode)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
556 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
557 case 1: /* LOW */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
558 if (invf_mode_prev == 0) /* NONE */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
559 return COEF_CONST(0.6);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
560 else
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
561 return COEF_CONST(0.75);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
562
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
563 case 2: /* MID */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
564 return COEF_CONST(0.9);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
565
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
566 case 3: /* HIGH */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
567 return COEF_CONST(0.98);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
568
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
569 default: /* NONE */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
570 if (invf_mode_prev == 1) /* LOW */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
571 return COEF_CONST(0.6);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
572 else
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
573 return COEF_CONST(0.0);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
574 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
575 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
576
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
577 /* FIXED POINT: bwArray = COEF */
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
578 static void calc_chirp_factors(sbr_info *sbr, uint8_t ch)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
579 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
580 uint8_t i;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
581
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
582 for (i = 0; i < sbr->N_Q; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
583 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
584 sbr->bwArray[ch][i] = mapNewBw(sbr->bs_invf_mode[ch][i], sbr->bs_invf_mode_prev[ch][i]);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
585
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
586 if (sbr->bwArray[ch][i] < sbr->bwArray_prev[ch][i])
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
587 sbr->bwArray[ch][i] = MUL_F(sbr->bwArray[ch][i], FRAC_CONST(0.75)) + MUL_F(sbr->bwArray_prev[ch][i], FRAC_CONST(0.25));
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
588 else
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
589 sbr->bwArray[ch][i] = MUL_F(sbr->bwArray[ch][i], FRAC_CONST(0.90625)) + MUL_F(sbr->bwArray_prev[ch][i], FRAC_CONST(0.09375));
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
590
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
591 if (sbr->bwArray[ch][i] < COEF_CONST(0.015625))
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
592 sbr->bwArray[ch][i] = COEF_CONST(0.0);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
593
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
594 if (sbr->bwArray[ch][i] >= COEF_CONST(0.99609375))
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
595 sbr->bwArray[ch][i] = COEF_CONST(0.99609375);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
596
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
597 sbr->bwArray_prev[ch][i] = sbr->bwArray[ch][i];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
598 sbr->bs_invf_mode_prev[ch][i] = sbr->bs_invf_mode[ch][i];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
599 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
600 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
601
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
602 static void patch_construction(sbr_info *sbr)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
603 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
604 uint8_t i, k;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
605 uint8_t odd, sb;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
606 uint8_t msb = sbr->k0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
607 uint8_t usb = sbr->kx;
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
608 uint8_t goalSbTab[] = { 21, 23, 32, 43, 46, 64, 85, 93, 128, 0, 0, 0 };
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
609 /* (uint8_t)(2.048e6/sbr->sample_rate + 0.5); */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
610 uint8_t goalSb = goalSbTab[get_sr_index(sbr->sample_rate)];
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
611
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
612 sbr->noPatches = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
613
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
614 if (goalSb < (sbr->kx + sbr->M))
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
615 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
616 for (i = 0, k = 0; sbr->f_master[i] < goalSb; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
617 k = i+1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
618 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
619 k = sbr->N_master;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
620 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
621
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
622 do
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
623 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
624 uint8_t j = k + 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
625
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
626 do
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
627 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
628 j--;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
629
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
630 sb = sbr->f_master[j];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
631 odd = (sb - 2 + sbr->k0) % 2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
632 } while (sb > (sbr->k0 - 1 + msb - odd));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
633
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
634 sbr->patchNoSubbands[sbr->noPatches] = max(sb - usb, 0);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
635 sbr->patchStartSubband[sbr->noPatches] = sbr->k0 - odd -
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
636 sbr->patchNoSubbands[sbr->noPatches];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
637
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
638 if (sbr->patchNoSubbands[sbr->noPatches] > 0)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
639 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
640 usb = sb;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
641 msb = sb;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
642 sbr->noPatches++;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
643 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
644 msb = sbr->kx;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
645 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
646
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
647 if (sbr->f_master[k] - sb < 3)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
648 k = sbr->N_master;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
649 } while (sb != (sbr->kx + sbr->M));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
650
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
651 if ((sbr->patchNoSubbands[sbr->noPatches-1] < 3) && (sbr->noPatches > 1))
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
652 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
653 sbr->noPatches--;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
654 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
655
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
656 sbr->noPatches = min(sbr->noPatches, 5);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
657 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
658
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
659 #endif