Mercurial > mplayer.hg
annotate libfaad2/sbr_dec.c @ 15255:e9b4eeb31768
synced with 1.73
author | gabrov |
---|---|
date | Sun, 24 Apr 2005 22:16:09 +0000 |
parents | 2ae5ab4331ca |
children | 0b6c9d7387b4 |
rev | line source |
---|---|
10725 | 1 /* |
2 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding | |
12527 | 3 ** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com |
10725 | 4 ** |
5 ** This program is free software; you can redistribute it and/or modify | |
6 ** it under the terms of the GNU General Public License as published by | |
7 ** the Free Software Foundation; either version 2 of the License, or | |
8 ** (at your option) any later version. | |
9 ** | |
10 ** This program is distributed in the hope that it will be useful, | |
11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 ** GNU General Public License for more details. | |
14 ** | |
15 ** You should have received a copy of the GNU General Public License | |
16 ** along with this program; if not, write to the Free Software | |
17 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
18 ** | |
19 ** Any non-GPL usage of this software or parts of this software is strictly | |
20 ** forbidden. | |
21 ** | |
22 ** Commercial non-GPL licensing of this software is possible. | |
23 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | |
24 ** | |
14727
2ae5ab4331ca
Remove modification notice from files that have not been locally modified.
diego
parents:
13453
diff
changeset
|
25 ** $Id: sbr_dec.c,v 1.37 2004/06/30 12:45:56 menno Exp $ |
10725 | 26 **/ |
27 | |
28 | |
29 #include "common.h" | |
30 #include "structs.h" | |
31 | |
32 #ifdef SBR_DEC | |
33 | |
12527 | 34 #include <string.h> |
10725 | 35 #include <stdlib.h> |
36 | |
37 #include "syntax.h" | |
38 #include "bits.h" | |
39 #include "sbr_syntax.h" | |
40 #include "sbr_qmf.h" | |
41 #include "sbr_hfgen.h" | |
42 #include "sbr_hfadj.h" | |
43 | |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
44 |
12527 | 45 /* static function declarations */ |
46 static uint8_t sbr_save_prev_data(sbr_info *sbr, uint8_t ch); | |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
47 static void sbr_save_matrix(sbr_info *sbr, uint8_t ch); |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
48 |
10725 | 49 |
12527 | 50 sbr_info *sbrDecodeInit(uint16_t framelength, uint8_t id_aac, |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
51 uint32_t sample_rate, uint8_t downSampledSBR |
10989 | 52 #ifdef DRM |
53 , uint8_t IsDRM | |
54 #endif | |
55 ) | |
10725 | 56 { |
12527 | 57 sbr_info *sbr = faad_malloc(sizeof(sbr_info)); |
10725 | 58 memset(sbr, 0, sizeof(sbr_info)); |
59 | |
12527 | 60 /* save id of the parent element */ |
61 sbr->id_aac = id_aac; | |
62 sbr->sample_rate = sample_rate; | |
63 | |
10725 | 64 sbr->bs_freq_scale = 2; |
65 sbr->bs_alter_scale = 1; | |
66 sbr->bs_noise_bands = 2; | |
67 sbr->bs_limiter_bands = 2; | |
68 sbr->bs_limiter_gains = 2; | |
69 sbr->bs_interpol_freq = 1; | |
70 sbr->bs_smoothing_mode = 1; | |
71 sbr->bs_start_freq = 5; | |
72 sbr->bs_amp_res = 1; | |
73 sbr->bs_samplerate_mode = 1; | |
74 sbr->prevEnvIsShort[0] = -1; | |
75 sbr->prevEnvIsShort[1] = -1; | |
76 sbr->header_count = 0; | |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
77 sbr->Reset = 1; |
10725 | 78 |
10989 | 79 #ifdef DRM |
12527 | 80 sbr->Is_DRM_SBR = IsDRM; |
10989 | 81 #endif |
12527 | 82 sbr->bs_samplerate_mode = 1; |
83 sbr->tHFGen = T_HFGEN; | |
84 sbr->tHFAdj = T_HFADJ; | |
10989 | 85 |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
86 sbr->bsco = 0; |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
87 sbr->bsco_prev = 0; |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
88 sbr->M_prev = 0; |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
89 sbr->frame_len = framelength; |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
90 |
10989 | 91 /* force sbr reset */ |
92 sbr->bs_start_freq_prev = -1; | |
93 | |
94 if (framelength == 960) | |
95 { | |
96 sbr->numTimeSlotsRate = RATE * NO_TIME_SLOTS_960; | |
97 sbr->numTimeSlots = NO_TIME_SLOTS_960; | |
98 } else { | |
99 sbr->numTimeSlotsRate = RATE * NO_TIME_SLOTS; | |
100 sbr->numTimeSlots = NO_TIME_SLOTS; | |
101 } | |
102 | |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
103 sbr->GQ_ringbuf_index[0] = 0; |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
104 sbr->GQ_ringbuf_index[1] = 0; |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
105 |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
106 if (id_aac == ID_CPE) |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
107 { |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
108 /* stereo */ |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
109 uint8_t j; |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
110 sbr->qmfa[0] = qmfa_init(32); |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
111 sbr->qmfa[1] = qmfa_init(32); |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
112 sbr->qmfs[0] = qmfs_init((downSampledSBR)?32:64); |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
113 sbr->qmfs[1] = qmfs_init((downSampledSBR)?32:64); |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
114 |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
115 for (j = 0; j < 5; j++) |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
116 { |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
117 sbr->G_temp_prev[0][j] = faad_malloc(64*sizeof(real_t)); |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
118 sbr->G_temp_prev[1][j] = faad_malloc(64*sizeof(real_t)); |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
119 sbr->Q_temp_prev[0][j] = faad_malloc(64*sizeof(real_t)); |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
120 sbr->Q_temp_prev[1][j] = faad_malloc(64*sizeof(real_t)); |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
121 } |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
122 |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
123 memset(sbr->Xsbr[0], 0, (sbr->numTimeSlotsRate+sbr->tHFGen)*64 * sizeof(qmf_t)); |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
124 memset(sbr->Xsbr[1], 0, (sbr->numTimeSlotsRate+sbr->tHFGen)*64 * sizeof(qmf_t)); |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
125 } else { |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
126 /* mono */ |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
127 uint8_t j; |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
128 sbr->qmfa[0] = qmfa_init(32); |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
129 sbr->qmfs[0] = qmfs_init((downSampledSBR)?32:64); |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
130 sbr->qmfs[1] = NULL; |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
131 |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
132 for (j = 0; j < 5; j++) |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
133 { |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
134 sbr->G_temp_prev[0][j] = faad_malloc(64*sizeof(real_t)); |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
135 sbr->Q_temp_prev[0][j] = faad_malloc(64*sizeof(real_t)); |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
136 } |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
137 |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
138 memset(sbr->Xsbr[0], 0, (sbr->numTimeSlotsRate+sbr->tHFGen)*64 * sizeof(qmf_t)); |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
139 } |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
140 |
10725 | 141 return sbr; |
142 } | |
143 | |
144 void sbrDecodeEnd(sbr_info *sbr) | |
145 { | |
146 uint8_t j; | |
147 | |
148 if (sbr) | |
149 { | |
150 qmfa_end(sbr->qmfa[0]); | |
151 qmfs_end(sbr->qmfs[0]); | |
12527 | 152 if (sbr->qmfs[1] != NULL) |
10725 | 153 { |
154 qmfa_end(sbr->qmfa[1]); | |
155 qmfs_end(sbr->qmfs[1]); | |
156 } | |
157 | |
158 for (j = 0; j < 5; j++) | |
159 { | |
12527 | 160 if (sbr->G_temp_prev[0][j]) faad_free(sbr->G_temp_prev[0][j]); |
161 if (sbr->Q_temp_prev[0][j]) faad_free(sbr->Q_temp_prev[0][j]); | |
162 if (sbr->G_temp_prev[1][j]) faad_free(sbr->G_temp_prev[1][j]); | |
163 if (sbr->Q_temp_prev[1][j]) faad_free(sbr->Q_temp_prev[1][j]); | |
10725 | 164 } |
165 | |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
166 #ifdef PS_DEC |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
167 if (sbr->ps != NULL) |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
168 ps_free(sbr->ps); |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
169 #endif |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
170 |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
171 #ifdef DRM_PS |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
172 if (sbr->drm_ps != NULL) |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
173 drm_ps_free(sbr->drm_ps); |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
174 #endif |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
175 |
12527 | 176 faad_free(sbr); |
10725 | 177 } |
178 } | |
179 | |
12527 | 180 static uint8_t sbr_save_prev_data(sbr_info *sbr, uint8_t ch) |
10725 | 181 { |
182 uint8_t i; | |
183 | |
184 /* save data for next frame */ | |
185 sbr->kx_prev = sbr->kx; | |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
186 sbr->M_prev = sbr->M; |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
187 sbr->bsco_prev = sbr->bsco; |
10725 | 188 |
189 sbr->L_E_prev[ch] = sbr->L_E[ch]; | |
190 | |
12527 | 191 /* sbr->L_E[ch] can become 0 on files with bit errors */ |
192 if (sbr->L_E[ch] <= 0) | |
193 return 19; | |
194 | |
10725 | 195 sbr->f_prev[ch] = sbr->f[ch][sbr->L_E[ch] - 1]; |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
196 for (i = 0; i < MAX_M; i++) |
10725 | 197 { |
198 sbr->E_prev[ch][i] = sbr->E[ch][i][sbr->L_E[ch] - 1]; | |
199 sbr->Q_prev[ch][i] = sbr->Q[ch][i][sbr->L_Q[ch] - 1]; | |
200 } | |
201 | |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
202 for (i = 0; i < MAX_M; i++) |
10725 | 203 { |
204 sbr->bs_add_harmonic_prev[ch][i] = sbr->bs_add_harmonic[ch][i]; | |
205 } | |
206 sbr->bs_add_harmonic_flag_prev[ch] = sbr->bs_add_harmonic_flag[ch]; | |
207 | |
208 if (sbr->l_A[ch] == sbr->L_E[ch]) | |
209 sbr->prevEnvIsShort[ch] = 0; | |
210 else | |
211 sbr->prevEnvIsShort[ch] = -1; | |
12527 | 212 |
213 return 0; | |
10725 | 214 } |
215 | |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
216 static void sbr_save_matrix(sbr_info *sbr, uint8_t ch) |
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 uint8_t i; |
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 for (i = 0; i < sbr->tHFGen; i++) |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
221 { |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
222 memmove(sbr->Xsbr[ch][i], sbr->Xsbr[ch][i+sbr->numTimeSlotsRate], 64 * sizeof(qmf_t)); |
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 for (i = sbr->tHFGen; i < MAX_NTSRHFG; i++) |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
225 { |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
226 memset(sbr->Xsbr[ch][i], 0, 64 * sizeof(qmf_t)); |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
227 } |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
228 } |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
229 |
12527 | 230 static void sbr_process_channel(sbr_info *sbr, real_t *channel_buf, qmf_t X[MAX_NTSR][64], |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
231 uint8_t ch, uint8_t dont_process, |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
232 const uint8_t downSampledSBR) |
10725 | 233 { |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
234 int16_t k, l; |
10725 | 235 |
12527 | 236 #ifdef SBR_LOW_POWER |
237 ALIGN real_t deg[64]; | |
238 #endif | |
239 | |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
240 #ifdef DRM |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
241 if (sbr->Is_DRM_SBR) |
12527 | 242 { |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
243 sbr->bsco = max((int32_t)sbr->maxAACLine*32/(int32_t)sbr->frame_len - (int32_t)sbr->kx, 0); |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
244 } else { |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
245 #endif |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
246 sbr->bsco = 0; |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
247 #ifdef DRM |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
248 } |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
249 #endif |
12527 | 250 |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
251 |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
252 //#define PRE_QMF_PRINT |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
253 #ifdef PRE_QMF_PRINT |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
254 { |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
255 int i; |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
256 for (i = 0; i < 1024; i++) |
12527 | 257 { |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
258 printf("%d\n", channel_buf[i]); |
12527 | 259 } |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
260 } |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
261 #endif |
12527 | 262 |
10725 | 263 |
12527 | 264 /* subband analysis */ |
265 if (dont_process) | |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
266 sbr_qmf_analysis_32(sbr, sbr->qmfa[ch], channel_buf, sbr->Xsbr[ch], sbr->tHFGen, 32); |
12527 | 267 else |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
268 sbr_qmf_analysis_32(sbr, sbr->qmfa[ch], channel_buf, sbr->Xsbr[ch], sbr->tHFGen, sbr->kx); |
12527 | 269 |
270 if (!dont_process) | |
271 { | |
272 #if 1 | |
273 /* insert high frequencies here */ | |
274 /* hf generation using patching */ | |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
275 hf_generation(sbr, sbr->Xsbr[ch], sbr->Xsbr[ch] |
10725 | 276 #ifdef SBR_LOW_POWER |
12527 | 277 ,deg |
278 #endif | |
279 ,ch); | |
280 #endif | |
281 | |
282 #ifdef SBR_LOW_POWER | |
283 for (l = sbr->t_E[ch][0]; l < sbr->t_E[ch][sbr->L_E[ch]]; l++) | |
284 { | |
285 for (k = 0; k < sbr->kx; k++) | |
286 { | |
287 QMF_RE(sbr->Xsbr[ch][sbr->tHFAdj + l][k]) = 0; | |
288 } | |
289 } | |
10725 | 290 #endif |
291 | |
12527 | 292 #if 1 |
293 /* hf adjustment */ | |
294 hf_adjustment(sbr, sbr->Xsbr[ch] | |
295 #ifdef SBR_LOW_POWER | |
296 ,deg | |
297 #endif | |
298 ,ch); | |
299 #endif | |
10989 | 300 } |
301 | |
12527 | 302 if ((sbr->just_seeked != 0) || dont_process) |
303 { | |
304 for (l = 0; l < sbr->numTimeSlotsRate; l++) | |
305 { | |
306 for (k = 0; k < 32; k++) | |
307 { | |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
308 QMF_RE(X[l][k]) = QMF_RE(sbr->Xsbr[ch][l + sbr->tHFAdj][k]); |
12527 | 309 #ifndef SBR_LOW_POWER |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
310 QMF_IM(X[l][k]) = QMF_IM(sbr->Xsbr[ch][l + sbr->tHFAdj][k]); |
12527 | 311 #endif |
312 } | |
313 for (k = 32; k < 64; k++) | |
314 { | |
315 QMF_RE(X[l][k]) = 0; | |
316 #ifndef SBR_LOW_POWER | |
317 QMF_IM(X[l][k]) = 0; | |
318 #endif | |
319 } | |
320 } | |
321 } else { | |
322 for (l = 0; l < sbr->numTimeSlotsRate; l++) | |
323 { | |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
324 uint8_t kx_band, M_band, bsco_band; |
12527 | 325 |
326 if (l < sbr->t_E[ch][0]) | |
327 { | |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
328 kx_band = sbr->kx_prev; |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
329 M_band = sbr->M_prev; |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
330 bsco_band = sbr->bsco_prev; |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
331 } else { |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
332 kx_band = sbr->kx; |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
333 M_band = sbr->M; |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
334 bsco_band = sbr->bsco; |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
335 } |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
336 |
12527 | 337 #ifndef SBR_LOW_POWER |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
338 for (k = 0; k < kx_band + bsco_band; k++) |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
339 { |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
340 QMF_RE(X[l][k]) = QMF_RE(sbr->Xsbr[ch][l + sbr->tHFAdj][k]); |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
341 QMF_IM(X[l][k]) = QMF_IM(sbr->Xsbr[ch][l + sbr->tHFAdj][k]); |
12527 | 342 } |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
343 for (k = kx_band + bsco_band; k < kx_band + M_band; k++) |
12527 | 344 { |
345 QMF_RE(X[l][k]) = QMF_RE(sbr->Xsbr[ch][l + sbr->tHFAdj][k]); | |
346 QMF_IM(X[l][k]) = QMF_IM(sbr->Xsbr[ch][l + sbr->tHFAdj][k]); | |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
347 } |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
348 for (k = max(kx_band + bsco_band, kx_band + M_band); k < 64; k++) |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
349 { |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
350 QMF_RE(X[l][k]) = 0; |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
351 QMF_IM(X[l][k]) = 0; |
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 #else |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
354 for (k = 0; k < kx_band + bsco_band; k++) |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
355 { |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
356 QMF_RE(X[l][k]) = QMF_RE(sbr->Xsbr[ch][l + sbr->tHFAdj][k]); |
12527 | 357 } |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
358 for (k = kx_band + bsco_band; k < min(kx_band + M_band, 63); k++) |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
359 { |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
360 QMF_RE(X[l][k]) = QMF_RE(sbr->Xsbr[ch][l + sbr->tHFAdj][k]); |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
361 } |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
362 for (k = max(kx_band + bsco_band, kx_band + M_band); k < 64; k++) |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
363 { |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
364 QMF_RE(X[l][k]) = 0; |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
365 } |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
366 QMF_RE(X[l][kx_band - 1 + bsco_band]) += |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
367 QMF_RE(sbr->Xsbr[ch][l + sbr->tHFAdj][kx_band - 1 + bsco_band]); |
12527 | 368 #endif |
369 } | |
370 } | |
371 } | |
372 | |
373 uint8_t sbrDecodeCoupleFrame(sbr_info *sbr, real_t *left_chan, real_t *right_chan, | |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
374 const uint8_t just_seeked, const uint8_t downSampledSBR) |
12527 | 375 { |
376 uint8_t dont_process = 0; | |
377 uint8_t ret = 0; | |
378 ALIGN qmf_t X[MAX_NTSR][64]; | |
379 | |
380 if (sbr == NULL) | |
381 return 20; | |
382 | |
383 /* case can occur due to bit errors */ | |
384 if (sbr->id_aac != ID_CPE) | |
385 return 21; | |
386 | |
387 if (sbr->ret || (sbr->header_count == 0)) | |
10725 | 388 { |
389 /* don't process just upsample */ | |
390 dont_process = 1; | |
10989 | 391 |
392 /* Re-activate reset for next frame */ | |
12527 | 393 if (sbr->ret && sbr->Reset) |
10989 | 394 sbr->bs_start_freq_prev = -1; |
10725 | 395 } |
396 | |
397 if (just_seeked) | |
10989 | 398 { |
10725 | 399 sbr->just_seeked = 1; |
10989 | 400 } else { |
10725 | 401 sbr->just_seeked = 0; |
10989 | 402 } |
10725 | 403 |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
404 sbr_process_channel(sbr, left_chan, X, 0, dont_process, downSampledSBR); |
12527 | 405 /* subband synthesis */ |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
406 if (downSampledSBR) |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
407 { |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
408 sbr_qmf_synthesis_32(sbr, sbr->qmfs[0], X, left_chan); |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
409 } else { |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
410 sbr_qmf_synthesis_64(sbr, sbr->qmfs[0], X, left_chan); |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
411 } |
10725 | 412 |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
413 sbr_process_channel(sbr, right_chan, X, 1, dont_process, downSampledSBR); |
12527 | 414 /* subband synthesis */ |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
415 if (downSampledSBR) |
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 sbr_qmf_synthesis_32(sbr, sbr->qmfs[1], X, right_chan); |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
418 } else { |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
419 sbr_qmf_synthesis_64(sbr, sbr->qmfs[1], X, right_chan); |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
420 } |
10725 | 421 |
12527 | 422 if (sbr->bs_header_flag) |
423 sbr->just_seeked = 0; | |
424 | |
425 if (sbr->header_count != 0 && sbr->ret == 0) | |
426 { | |
427 ret = sbr_save_prev_data(sbr, 0); | |
428 if (ret) return ret; | |
429 ret = sbr_save_prev_data(sbr, 1); | |
430 if (ret) return ret; | |
431 } | |
432 | |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
433 sbr_save_matrix(sbr, 0); |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
434 sbr_save_matrix(sbr, 1); |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
435 |
12527 | 436 sbr->frame++; |
437 | |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
438 //#define POST_QMF_PRINT |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
439 #ifdef POST_QMF_PRINT |
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 int i; |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
442 for (i = 0; i < 2048; i++) |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
443 { |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
444 printf("%d\n", left_chan[i]); |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
445 } |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
446 for (i = 0; i < 2048; i++) |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
447 { |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
448 printf("%d\n", right_chan[i]); |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
449 } |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
450 } |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
451 #endif |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
452 |
12527 | 453 return 0; |
454 } | |
455 | |
456 uint8_t sbrDecodeSingleFrame(sbr_info *sbr, real_t *channel, | |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
457 const uint8_t just_seeked, const uint8_t downSampledSBR) |
12527 | 458 { |
459 uint8_t dont_process = 0; | |
460 uint8_t ret = 0; | |
461 ALIGN qmf_t X[MAX_NTSR][64]; | |
462 | |
463 if (sbr == NULL) | |
464 return 20; | |
10725 | 465 |
12527 | 466 /* case can occur due to bit errors */ |
467 if (sbr->id_aac != ID_SCE && sbr->id_aac != ID_LFE) | |
468 return 21; | |
469 | |
470 if (sbr->ret || (sbr->header_count == 0)) | |
471 { | |
472 /* don't process just upsample */ | |
473 dont_process = 1; | |
474 | |
475 /* Re-activate reset for next frame */ | |
476 if (sbr->ret && sbr->Reset) | |
477 sbr->bs_start_freq_prev = -1; | |
478 } | |
10725 | 479 |
12527 | 480 if (just_seeked) |
481 { | |
482 sbr->just_seeked = 1; | |
483 } else { | |
484 sbr->just_seeked = 0; | |
485 } | |
10725 | 486 |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
487 sbr_process_channel(sbr, channel, X, 0, dont_process, downSampledSBR); |
12527 | 488 /* subband synthesis */ |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
489 if (downSampledSBR) |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
490 { |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
491 sbr_qmf_synthesis_32(sbr, sbr->qmfs[0], X, channel); |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
492 } else { |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
493 sbr_qmf_synthesis_64(sbr, sbr->qmfs[0], X, channel); |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
494 } |
10725 | 495 |
496 if (sbr->bs_header_flag) | |
497 sbr->just_seeked = 0; | |
498 | |
12527 | 499 if (sbr->header_count != 0 && sbr->ret == 0) |
10725 | 500 { |
12527 | 501 ret = sbr_save_prev_data(sbr, 0); |
502 if (ret) return ret; | |
10725 | 503 } |
504 | |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
505 sbr_save_matrix(sbr, 0); |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
506 |
10725 | 507 sbr->frame++; |
12527 | 508 |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
509 //#define POST_QMF_PRINT |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
510 #ifdef POST_QMF_PRINT |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
511 { |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
512 int i; |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
513 for (i = 0; i < 2048; i++) |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
514 { |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
515 printf("%d\n", channel[i]); |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
516 } |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
517 } |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
518 #endif |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
519 |
12527 | 520 return 0; |
521 } | |
522 | |
523 #if (defined(PS_DEC) || defined(DRM_PS)) | |
524 uint8_t sbrDecodeSingleFramePS(sbr_info *sbr, real_t *left_channel, real_t *right_channel, | |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
525 const uint8_t just_seeked, const uint8_t downSampledSBR) |
12527 | 526 { |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
527 uint8_t l, k; |
12527 | 528 uint8_t dont_process = 0; |
529 uint8_t ret = 0; | |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
530 ALIGN qmf_t X_left[38][64] = {{0}}; |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
531 ALIGN qmf_t X_right[38][64] = {{0}}; /* must set this to 0 */ |
12527 | 532 |
533 if (sbr == NULL) | |
534 return 20; | |
535 | |
536 /* case can occur due to bit errors */ | |
537 if (sbr->id_aac != ID_SCE && sbr->id_aac != ID_LFE) | |
538 return 21; | |
539 | |
540 if (sbr->ret || (sbr->header_count == 0)) | |
541 { | |
542 /* don't process just upsample */ | |
543 dont_process = 1; | |
544 | |
545 /* Re-activate reset for next frame */ | |
546 if (sbr->ret && sbr->Reset) | |
547 sbr->bs_start_freq_prev = -1; | |
548 } | |
549 | |
550 if (just_seeked) | |
551 { | |
552 sbr->just_seeked = 1; | |
553 } else { | |
554 sbr->just_seeked = 0; | |
555 } | |
556 | |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
557 if (sbr->qmfs[1] == NULL) |
12527 | 558 { |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
559 sbr->qmfs[1] = qmfs_init((downSampledSBR)?32:64); |
12527 | 560 } |
561 | |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
562 sbr_process_channel(sbr, left_channel, X_left, 0, dont_process, downSampledSBR); |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
563 |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
564 /* copy some extra data for PS */ |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
565 for (l = 32; l < 38; l++) |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
566 { |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
567 for (k = 0; k < 5; k++) |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
568 { |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
569 QMF_RE(X_left[l][k]) = QMF_RE(sbr->Xsbr[0][sbr->tHFAdj+l][k]); |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
570 QMF_IM(X_left[l][k]) = QMF_IM(sbr->Xsbr[0][sbr->tHFAdj+l][k]); |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
571 } |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
572 } |
12527 | 573 |
574 /* perform parametric stereo */ | |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
575 #ifdef DRM_PS |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
576 if (sbr->Is_DRM_SBR) |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
577 { |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
578 drm_ps_decode(sbr->drm_ps, sbr->sample_rate, X_left, X_right); |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
579 } else { |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
580 #endif |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
581 #ifdef PS_DEC |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
582 ps_decode(sbr->ps, X_left, X_right); |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
583 #endif |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
584 #ifdef DRM_PS |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
585 } |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
586 #endif |
12527 | 587 |
588 /* subband synthesis */ | |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
589 if (downSampledSBR) |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
590 { |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
591 sbr_qmf_synthesis_32(sbr, sbr->qmfs[0], X_left, left_channel); |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
592 sbr_qmf_synthesis_32(sbr, sbr->qmfs[1], X_right, right_channel); |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
593 } else { |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
594 sbr_qmf_synthesis_64(sbr, sbr->qmfs[0], X_left, left_channel); |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
595 sbr_qmf_synthesis_64(sbr, sbr->qmfs[1], X_right, right_channel); |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
596 } |
12527 | 597 |
598 if (sbr->bs_header_flag) | |
599 sbr->just_seeked = 0; | |
600 | |
601 if (sbr->header_count != 0 && sbr->ret == 0) | |
602 { | |
603 ret = sbr_save_prev_data(sbr, 0); | |
604 if (ret) return ret; | |
605 } | |
606 | |
13453
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
607 sbr_save_matrix(sbr, 0); |
6d50ef45a058
Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents:
12625
diff
changeset
|
608 |
12527 | 609 sbr->frame++; |
610 | |
611 return 0; | |
612 } | |
613 #endif | |
614 | |
615 #endif |