annotate libfaad2/sbr_dec.c @ 12625:d81145997036

More information about modifications to comply more closely with GPL 2a.
author diego
date Wed, 23 Jun 2004 13:50:53 +0000
parents 4a370c80fe5c
children 6d50ef45a058
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
d81145997036 More information about modifications to comply more closely with GPL 2a.
diego
parents: 12527
diff changeset
26 ** $Id: sbr_dec.c,v 1.3 2004/06/02 22:59:03 diego Exp $
d81145997036 More information about modifications to comply more closely with GPL 2a.
diego
parents: 12527
diff changeset
27 ** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
10725
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
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
31 #include "common.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
32 #include "structs.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
33
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
34 #ifdef SBR_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
35
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
36 #include <string.h>
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
37 #include <stdlib.h>
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
38
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
39 #include "syntax.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
40 #include "bits.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
41 #include "sbr_syntax.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
42 #include "sbr_qmf.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
43 #include "sbr_hfgen.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
44 #include "sbr_hfadj.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
45
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
46 /* static function declarations */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
47 static uint8_t sbr_save_prev_data(sbr_info *sbr, uint8_t ch);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
48
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
49 sbr_info *sbrDecodeInit(uint16_t framelength, uint8_t id_aac,
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
50 uint32_t sample_rate
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
51 #ifdef DRM
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
52 , uint8_t IsDRM
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
53 #endif
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
54 )
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
55 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
56 sbr_info *sbr = faad_malloc(sizeof(sbr_info));
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
57 memset(sbr, 0, sizeof(sbr_info));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
58
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
59 /* save id of the parent element */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
60 sbr->id_aac = id_aac;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
61 sbr->sample_rate = sample_rate;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
62
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
63 sbr->bs_freq_scale = 2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
64 sbr->bs_alter_scale = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
65 sbr->bs_noise_bands = 2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
66 sbr->bs_limiter_bands = 2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
67 sbr->bs_limiter_gains = 2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
68 sbr->bs_interpol_freq = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
69 sbr->bs_smoothing_mode = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
70 sbr->bs_start_freq = 5;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
71 sbr->bs_amp_res = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
72 sbr->bs_samplerate_mode = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
73 sbr->prevEnvIsShort[0] = -1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
74 sbr->prevEnvIsShort[1] = -1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
75 sbr->header_count = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
76
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
77 #ifdef DRM
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
78 sbr->Is_DRM_SBR = IsDRM;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
79 #endif
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
80 sbr->bs_samplerate_mode = 1;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
81 sbr->tHFGen = T_HFGEN;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
82 sbr->tHFAdj = T_HFADJ;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
83
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
84 /* force sbr reset */
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
85 sbr->bs_start_freq_prev = -1;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
86
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
87 if (framelength == 960)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
88 {
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
89 sbr->numTimeSlotsRate = RATE * NO_TIME_SLOTS_960;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
90 sbr->numTimeSlots = NO_TIME_SLOTS_960;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
91 } else {
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
92 sbr->numTimeSlotsRate = RATE * NO_TIME_SLOTS;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
93 sbr->numTimeSlots = NO_TIME_SLOTS;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
94 }
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
95
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
96 return sbr;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
97 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
98
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
99 void sbrDecodeEnd(sbr_info *sbr)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
100 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
101 uint8_t j;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
102
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
103 if (sbr)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
104 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
105 qmfa_end(sbr->qmfa[0]);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
106 qmfs_end(sbr->qmfs[0]);
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
107 if (sbr->qmfs[1] != NULL)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
108 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
109 qmfa_end(sbr->qmfa[1]);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
110 qmfs_end(sbr->qmfs[1]);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
111 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
112
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
113 for (j = 0; j < 5; j++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
114 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
115 if (sbr->G_temp_prev[0][j]) faad_free(sbr->G_temp_prev[0][j]);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
116 if (sbr->Q_temp_prev[0][j]) faad_free(sbr->Q_temp_prev[0][j]);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
117 if (sbr->G_temp_prev[1][j]) faad_free(sbr->G_temp_prev[1][j]);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
118 if (sbr->Q_temp_prev[1][j]) faad_free(sbr->Q_temp_prev[1][j]);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
119 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
120
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
121 faad_free(sbr);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
122 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
123 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
124
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
125 static uint8_t sbr_save_prev_data(sbr_info *sbr, uint8_t ch)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
126 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
127 uint8_t i;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
128
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
129 /* save data for next frame */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
130 sbr->kx_prev = sbr->kx;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
131
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
132 sbr->L_E_prev[ch] = sbr->L_E[ch];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
133
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
134 /* sbr->L_E[ch] can become 0 on files with bit errors */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
135 if (sbr->L_E[ch] <= 0)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
136 return 19;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
137
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
138 sbr->f_prev[ch] = sbr->f[ch][sbr->L_E[ch] - 1];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
139 for (i = 0; i < 64; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
140 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
141 sbr->E_prev[ch][i] = sbr->E[ch][i][sbr->L_E[ch] - 1];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
142 sbr->Q_prev[ch][i] = sbr->Q[ch][i][sbr->L_Q[ch] - 1];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
143 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
144
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
145 for (i = 0; i < 64; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
146 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
147 sbr->bs_add_harmonic_prev[ch][i] = sbr->bs_add_harmonic[ch][i];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
148 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
149 sbr->bs_add_harmonic_flag_prev[ch] = sbr->bs_add_harmonic_flag[ch];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
150
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
151 if (sbr->l_A[ch] == sbr->L_E[ch])
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
152 sbr->prevEnvIsShort[ch] = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
153 else
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
154 sbr->prevEnvIsShort[ch] = -1;
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
155
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
156 return 0;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
157 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
158
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
159 static void sbr_process_channel(sbr_info *sbr, real_t *channel_buf, qmf_t X[MAX_NTSR][64],
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
160 uint8_t ch, uint8_t dont_process)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
161 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
162 int16_t i, k, l;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
163
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
164 #ifdef SBR_LOW_POWER
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
165 ALIGN real_t deg[64];
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
166 #endif
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
167
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
168 if (sbr->frame == 0)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
169 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
170 uint8_t j;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
171 sbr->qmfa[ch] = qmfa_init(32);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
172 sbr->qmfs[ch] = qmfs_init(64);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
173
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
174 for (j = 0; j < 5; j++)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
175 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
176 sbr->G_temp_prev[ch][j] = faad_malloc(64*sizeof(real_t));
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
177 sbr->Q_temp_prev[ch][j] = faad_malloc(64*sizeof(real_t));
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
178 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
179
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
180 memset(sbr->Xsbr[ch], 0, (sbr->numTimeSlotsRate+sbr->tHFGen)*64 * sizeof(qmf_t));
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
181 memset(sbr->Xcodec[ch], 0, (sbr->numTimeSlotsRate+sbr->tHFGen)*32 * sizeof(qmf_t));
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
182 }
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
183
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
184 /* subband analysis */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
185 if (dont_process)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
186 sbr_qmf_analysis_32(sbr, sbr->qmfa[ch], channel_buf, sbr->Xcodec[ch], sbr->tHFGen, 32);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
187 else
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
188 sbr_qmf_analysis_32(sbr, sbr->qmfa[ch], channel_buf, sbr->Xcodec[ch], sbr->tHFGen, sbr->kx);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
189
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
190 if (!dont_process)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
191 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
192 #if 1
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
193 /* insert high frequencies here */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
194 /* hf generation using patching */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
195 hf_generation(sbr, sbr->Xcodec[ch], sbr->Xsbr[ch]
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
196 #ifdef SBR_LOW_POWER
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
197 ,deg
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
198 #endif
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
199 ,ch);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
200 #endif
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
201
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
202 #ifdef SBR_LOW_POWER
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
203 for (l = sbr->t_E[ch][0]; l < sbr->t_E[ch][sbr->L_E[ch]]; l++)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
204 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
205 for (k = 0; k < sbr->kx; k++)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
206 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
207 QMF_RE(sbr->Xsbr[ch][sbr->tHFAdj + l][k]) = 0;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
208 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
209 }
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
210 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
211
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
212 #if 1
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
213 /* hf adjustment */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
214 hf_adjustment(sbr, sbr->Xsbr[ch]
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
215 #ifdef SBR_LOW_POWER
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
216 ,deg
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
217 #endif
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
218 ,ch);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
219 #endif
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
220 }
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
221
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
222 if ((sbr->just_seeked != 0) || dont_process)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
223 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
224 for (l = 0; l < sbr->numTimeSlotsRate; l++)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
225 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
226 for (k = 0; k < 32; k++)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
227 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
228 QMF_RE(X[l][k]) = QMF_RE(sbr->Xcodec[ch][l + sbr->tHFAdj][k]);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
229 #ifndef SBR_LOW_POWER
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
230 QMF_IM(X[l][k]) = QMF_IM(sbr->Xcodec[ch][l + sbr->tHFAdj][k]);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
231 #endif
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
232 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
233 for (k = 32; k < 64; k++)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
234 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
235 QMF_RE(X[l][k]) = 0;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
236 #ifndef SBR_LOW_POWER
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
237 QMF_IM(X[l][k]) = 0;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
238 #endif
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
239 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
240 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
241 } else {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
242 for (l = 0; l < sbr->numTimeSlotsRate; l++)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
243 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
244 uint8_t xover_band;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
245
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
246 if (l < sbr->t_E[ch][0])
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
247 xover_band = sbr->kx_prev;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
248 else
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
249 xover_band = sbr->kx;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
250
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
251 for (k = 0; k < xover_band; k++)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
252 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
253 QMF_RE(X[l][k]) = QMF_RE(sbr->Xcodec[ch][l + sbr->tHFAdj][k]);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
254 #ifndef SBR_LOW_POWER
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
255 QMF_IM(X[l][k]) = QMF_IM(sbr->Xcodec[ch][l + sbr->tHFAdj][k]);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
256 #endif
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
257 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
258 for (k = xover_band; k < 64; k++)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
259 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
260 QMF_RE(X[l][k]) = QMF_RE(sbr->Xsbr[ch][l + sbr->tHFAdj][k]);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
261 #ifndef SBR_LOW_POWER
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
262 QMF_IM(X[l][k]) = QMF_IM(sbr->Xsbr[ch][l + sbr->tHFAdj][k]);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
263 #endif
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
264 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
265 #ifdef SBR_LOW_POWER
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
266 QMF_RE(X[l][xover_band - 1]) += QMF_RE(sbr->Xsbr[ch][l + sbr->tHFAdj][xover_band - 1]);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
267 #endif
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
268 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
269 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
270
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
271 for (i = 0; i < sbr->tHFGen; i++)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
272 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
273 memmove(sbr->Xcodec[ch][i], sbr->Xcodec[ch][i+sbr->numTimeSlotsRate], 32 * sizeof(qmf_t));
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
274 memmove(sbr->Xsbr[ch][i], sbr->Xsbr[ch][i+sbr->numTimeSlotsRate], 64 * sizeof(qmf_t));
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
275 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
276 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
277
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
278 uint8_t sbrDecodeCoupleFrame(sbr_info *sbr, real_t *left_chan, real_t *right_chan,
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
279 const uint8_t just_seeked, const uint8_t upsample_only)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
280 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
281 uint8_t dont_process = 0;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
282 uint8_t ret = 0;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
283 ALIGN qmf_t X[MAX_NTSR][64];
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
284
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
285 if (sbr == NULL)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
286 return 20;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
287
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
288 /* case can occur due to bit errors */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
289 if (sbr->id_aac != ID_CPE)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
290 return 21;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
291
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
292 if (sbr->ret || (sbr->header_count == 0))
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
293 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
294 /* don't process just upsample */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
295 dont_process = 1;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
296
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
297 /* Re-activate reset for next frame */
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
298 if (sbr->ret && sbr->Reset)
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
299 sbr->bs_start_freq_prev = -1;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
300 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
301
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
302 if (just_seeked)
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
303 {
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
304 sbr->just_seeked = 1;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
305 } else {
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
306 sbr->just_seeked = 0;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
307 }
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
308
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
309 sbr_process_channel(sbr, left_chan, X, 0, dont_process);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
310 /* subband synthesis */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
311 #ifndef USE_SSE
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
312 sbr_qmf_synthesis_64(sbr, sbr->qmfs[0], X, left_chan);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
313 #else
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
314 sbr->qmfs[ch]->qmf_func(sbr, sbr->qmfs[0], X, left_chan);
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
315 #endif
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
316
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
317 sbr_process_channel(sbr, right_chan, X, 1, dont_process);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
318 /* subband synthesis */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
319 #ifndef USE_SSE
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
320 sbr_qmf_synthesis_64(sbr, sbr->qmfs[1], X, right_chan);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
321 #else
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
322 sbr->qmfs[ch]->qmf_func(sbr, sbr->qmfs[1], X, right_chan);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
323 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
324
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
325 if (sbr->bs_header_flag)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
326 sbr->just_seeked = 0;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
327
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
328 if (sbr->header_count != 0 && sbr->ret == 0)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
329 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
330 ret = sbr_save_prev_data(sbr, 0);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
331 if (ret) return ret;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
332 ret = sbr_save_prev_data(sbr, 1);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
333 if (ret) return ret;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
334 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
335
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
336 sbr->frame++;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
337
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
338 return 0;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
339 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
340
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
341 uint8_t sbrDecodeSingleFrame(sbr_info *sbr, real_t *channel,
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
342 const uint8_t just_seeked, const uint8_t upsample_only)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
343 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
344 uint8_t dont_process = 0;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
345 uint8_t ret = 0;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
346 ALIGN qmf_t X[MAX_NTSR][64];
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
347
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
348 if (sbr == NULL)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
349 return 20;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
350
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
351 /* case can occur due to bit errors */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
352 if (sbr->id_aac != ID_SCE && sbr->id_aac != ID_LFE)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
353 return 21;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
354
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
355 if (sbr->ret || (sbr->header_count == 0))
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
356 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
357 /* don't process just upsample */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
358 dont_process = 1;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
359
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
360 /* Re-activate reset for next frame */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
361 if (sbr->ret && sbr->Reset)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
362 sbr->bs_start_freq_prev = -1;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
363 }
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
364
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
365 if (just_seeked)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
366 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
367 sbr->just_seeked = 1;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
368 } else {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
369 sbr->just_seeked = 0;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
370 }
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
371
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
372 sbr_process_channel(sbr, channel, X, 0, dont_process);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
373 /* subband synthesis */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
374 #ifndef USE_SSE
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
375 sbr_qmf_synthesis_64(sbr, sbr->qmfs[0], X, channel);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
376 #else
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
377 sbr->qmfs[ch]->qmf_func(sbr, sbr->qmfs[0], X, channel);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
378 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
379
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
380 if (sbr->bs_header_flag)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
381 sbr->just_seeked = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
382
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
383 if (sbr->header_count != 0 && sbr->ret == 0)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
384 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
385 ret = sbr_save_prev_data(sbr, 0);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
386 if (ret) return ret;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
387 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
388
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
389 sbr->frame++;
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
390
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
391 return 0;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
392 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
393
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
394 static void ps_dummy_function(qmf_t X_mono[MAX_NTSR][64],
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
395 qmf_t X_left[MAX_NTSR][64], qmf_t X_right[MAX_NTSR][64])
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
396 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
397 uint8_t i, j;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
398
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
399 for (i = 0; i < MAX_NTSR; i++)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
400 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
401 for (j = 0; j < 64; j++)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
402 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
403 QMF_RE(X_left[i][j]) = QMF_RE(X_mono[i][j]);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
404 QMF_RE(X_right[i][j]) = QMF_RE(X_mono[i][j]);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
405 #ifndef SBR_LOW_POWER
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
406 QMF_IM(X_left[i][j]) = QMF_IM(X_mono[i][j]);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
407 QMF_IM(X_right[i][j]) = QMF_IM(X_mono[i][j]);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
408 #endif
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
409 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
410 }
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
411 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
412
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
413 #if (defined(PS_DEC) || defined(DRM_PS))
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
414 uint8_t sbrDecodeSingleFramePS(sbr_info *sbr, real_t *left_channel, real_t *right_channel,
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
415 const uint8_t just_seeked, const uint8_t upsample_only)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
416 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
417 uint8_t dont_process = 0;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
418 uint8_t ret = 0;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
419 ALIGN qmf_t X_mono[MAX_NTSR][64];
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
420 ALIGN qmf_t X_left[MAX_NTSR][64];
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
421 ALIGN qmf_t X_right[MAX_NTSR][64];
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
422
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
423 if (sbr == NULL)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
424 return 20;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
425
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
426 /* case can occur due to bit errors */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
427 if (sbr->id_aac != ID_SCE && sbr->id_aac != ID_LFE)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
428 return 21;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
429
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
430 if (sbr->ret || (sbr->header_count == 0))
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
431 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
432 /* don't process just upsample */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
433 dont_process = 1;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
434
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
435 /* Re-activate reset for next frame */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
436 if (sbr->ret && sbr->Reset)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
437 sbr->bs_start_freq_prev = -1;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
438 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
439
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
440 if (just_seeked)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
441 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
442 sbr->just_seeked = 1;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
443 } else {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
444 sbr->just_seeked = 0;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
445 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
446
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
447 if (sbr->frame == 0)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
448 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
449 sbr->qmfs[1] = qmfs_init(64);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
450 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
451
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
452 sbr_process_channel(sbr, left_channel, X_mono, 0, dont_process);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
453
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
454 /* perform parametric stereo */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
455 ps_dummy_function(X_mono, X_left, X_right);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
456
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
457 /* subband synthesis */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
458 #ifndef USE_SSE
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
459 sbr_qmf_synthesis_64(sbr, sbr->qmfs[0], X_left, left_channel);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
460 sbr_qmf_synthesis_64(sbr, sbr->qmfs[1], X_right, right_channel);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
461 #else
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
462 sbr->qmfs[ch]->qmf_func(sbr, sbr->qmfs[0], X_left, left_channel);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
463 sbr->qmfs[ch]->qmf_func(sbr, sbr->qmfs[1], X_right, right_channel);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
464 #endif
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
465
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
466 if (sbr->bs_header_flag)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
467 sbr->just_seeked = 0;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
468
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
469 if (sbr->header_count != 0 && sbr->ret == 0)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
470 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
471 ret = sbr_save_prev_data(sbr, 0);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
472 if (ret) return ret;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
473 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
474
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
475 sbr->frame++;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
476
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
477 return 0;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
478 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
479 #endif
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
480
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
481 #endif