annotate libfaad2/sbr_dec.c @ 25503:9f8f66eca56e

Remove unused static variable pass, fixes the warning: ae_lame.c:72: warning: 'pass' defined but not used
author diego
date Thu, 27 Dec 2007 11:19:54 +0000
parents 0783dd397f74
children e83eef58b30a
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 **
18141
59b6fa5b4201 Update to faad2 cvs 20040915+MPlayer fixes
rtognimp
parents: 17098
diff changeset
25 ** Initially modified for use with MPlayer on 2005/12/05
59b6fa5b4201 Update to faad2 cvs 20040915+MPlayer fixes
rtognimp
parents: 17098
diff changeset
26 ** $Id: sbr_dec.c,v 1.39 2004/09/04 14:56:28 menno Exp $
18783
0783dd397f74 CVS --> Subversion in copyright notices
diego
parents: 18141
diff changeset
27 ** detailed changelog at http://svn.mplayerhq.hu/mplayer/trunk/
18141
59b6fa5b4201 Update to faad2 cvs 20040915+MPlayer fixes
rtognimp
parents: 17098
diff changeset
28 ** local_changes.diff contains the exact changes to this file.
10725
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
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
32 #include "common.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
33 #include "structs.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
34
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
35 #ifdef SBR_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
36
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
37 #include <string.h>
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
38 #include <stdlib.h>
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
39
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
40 #include "syntax.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
41 #include "bits.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
42 #include "sbr_syntax.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
43 #include "sbr_qmf.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
44 #include "sbr_hfgen.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
45 #include "sbr_hfadj.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
46
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
47
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
48 /* static function declarations */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
49 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
50 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
51
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
52
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
53 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
54 uint32_t sample_rate, uint8_t downSampledSBR
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
55 #ifdef DRM
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
56 , uint8_t IsDRM
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
57 #endif
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
58 )
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
59 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
60 sbr_info *sbr = faad_malloc(sizeof(sbr_info));
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
61 memset(sbr, 0, sizeof(sbr_info));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
62
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
63 /* save id of the parent element */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
64 sbr->id_aac = id_aac;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
65 sbr->sample_rate = sample_rate;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
66
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
67 sbr->bs_freq_scale = 2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
68 sbr->bs_alter_scale = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
69 sbr->bs_noise_bands = 2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
70 sbr->bs_limiter_bands = 2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
71 sbr->bs_limiter_gains = 2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
72 sbr->bs_interpol_freq = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
73 sbr->bs_smoothing_mode = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
74 sbr->bs_start_freq = 5;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
75 sbr->bs_amp_res = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
76 sbr->bs_samplerate_mode = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
77 sbr->prevEnvIsShort[0] = -1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
78 sbr->prevEnvIsShort[1] = -1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
79 sbr->header_count = 0;
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
80 sbr->Reset = 1;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
81
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
82 #ifdef DRM
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
83 sbr->Is_DRM_SBR = IsDRM;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
84 #endif
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
85 sbr->tHFGen = T_HFGEN;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
86 sbr->tHFAdj = T_HFADJ;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
87
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
88 sbr->bsco = 0;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
89 sbr->bsco_prev = 0;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
90 sbr->M_prev = 0;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
91 sbr->frame_len = framelength;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
92
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
93 /* force sbr reset */
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
94 sbr->bs_start_freq_prev = -1;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
95
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
96 if (framelength == 960)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
97 {
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
98 sbr->numTimeSlotsRate = RATE * NO_TIME_SLOTS_960;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
99 sbr->numTimeSlots = NO_TIME_SLOTS_960;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
100 } else {
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
101 sbr->numTimeSlotsRate = RATE * NO_TIME_SLOTS;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
102 sbr->numTimeSlots = NO_TIME_SLOTS;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
103 }
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
104
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
105 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
106 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
107
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
108 if (id_aac == ID_CPE)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
109 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
110 /* stereo */
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
111 uint8_t j;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
112 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
113 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
114 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
115 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
116
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
117 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
118 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
119 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
120 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
121 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
122 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
123 }
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
124
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
125 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
126 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
127 } else {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
128 /* mono */
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
129 uint8_t j;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
130 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
131 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
132 sbr->qmfs[1] = NULL;
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 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
135 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
136 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
137 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
138 }
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 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
141 }
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
142
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
143 return sbr;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
144 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
145
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
146 void sbrDecodeEnd(sbr_info *sbr)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
147 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
148 uint8_t j;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
149
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
150 if (sbr)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
151 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
152 qmfa_end(sbr->qmfa[0]);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
153 qmfs_end(sbr->qmfs[0]);
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
154 if (sbr->qmfs[1] != NULL)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
155 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
156 qmfa_end(sbr->qmfa[1]);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
157 qmfs_end(sbr->qmfs[1]);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
158 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
159
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
160 for (j = 0; j < 5; j++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
161 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
162 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
163 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
164 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
165 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
166 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
167
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
168 #ifdef PS_DEC
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
169 if (sbr->ps != NULL)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
170 ps_free(sbr->ps);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
171 #endif
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
172
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
173 #ifdef DRM_PS
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
174 if (sbr->drm_ps != NULL)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
175 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
176 #endif
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
177
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
178 faad_free(sbr);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
179 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
180 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
181
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
182 static uint8_t sbr_save_prev_data(sbr_info *sbr, uint8_t ch)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
183 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
184 uint8_t i;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
185
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
186 /* save data for next frame */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
187 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
188 sbr->M_prev = sbr->M;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
189 sbr->bsco_prev = sbr->bsco;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
190
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
191 sbr->L_E_prev[ch] = sbr->L_E[ch];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
192
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
193 /* 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
194 if (sbr->L_E[ch] <= 0)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
195 return 19;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
196
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
197 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
198 for (i = 0; i < MAX_M; i++)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
199 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
200 sbr->E_prev[ch][i] = sbr->E[ch][i][sbr->L_E[ch] - 1];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
201 sbr->Q_prev[ch][i] = sbr->Q[ch][i][sbr->L_Q[ch] - 1];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
202 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
203
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
204 for (i = 0; i < MAX_M; i++)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
205 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
206 sbr->bs_add_harmonic_prev[ch][i] = sbr->bs_add_harmonic[ch][i];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
207 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
208 sbr->bs_add_harmonic_flag_prev[ch] = sbr->bs_add_harmonic_flag[ch];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
209
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
210 if (sbr->l_A[ch] == sbr->L_E[ch])
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
211 sbr->prevEnvIsShort[ch] = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
212 else
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
213 sbr->prevEnvIsShort[ch] = -1;
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
214
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
215 return 0;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
216 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
217
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
218 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
219 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
220 uint8_t 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 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
223 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
224 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
225 }
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
226 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
227 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
228 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
229 }
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
230 }
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
231
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
232 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
233 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
234 const uint8_t downSampledSBR)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
235 {
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
236 int16_t k, l;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
237
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
238 #ifdef SBR_LOW_POWER
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
239 ALIGN real_t deg[64];
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
240 #endif
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
241
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
242 #ifdef DRM
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
243 if (sbr->Is_DRM_SBR)
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
244 {
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
245 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
246 } else {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
247 #endif
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
248 sbr->bsco = 0;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
249 #ifdef DRM
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
250 }
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
251 #endif
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
252
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
253
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
254 //#define PRE_QMF_PRINT
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
255 #ifdef PRE_QMF_PRINT
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
256 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
257 int i;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
258 for (i = 0; i < 1024; i++)
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
259 {
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
260 printf("%d\n", channel_buf[i]);
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
261 }
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
262 }
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
263 #endif
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
264
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
265
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
266 /* subband analysis */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
267 if (dont_process)
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, 32);
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
269 else
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
270 sbr_qmf_analysis_32(sbr, sbr->qmfa[ch], channel_buf, sbr->Xsbr[ch], sbr->tHFGen, sbr->kx);
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
271
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
272 if (!dont_process)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
273 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
274 #if 1
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
275 /* insert high frequencies here */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
276 /* hf generation using patching */
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
277 hf_generation(sbr, sbr->Xsbr[ch], sbr->Xsbr[ch]
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
278 #ifdef SBR_LOW_POWER
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
279 ,deg
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
280 #endif
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
281 ,ch);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
282 #endif
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
283
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
284 #ifdef SBR_LOW_POWER
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
285 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
286 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
287 for (k = 0; k < sbr->kx; k++)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
288 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
289 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
290 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
291 }
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
292 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
293
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
294 #if 1
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
295 /* hf adjustment */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
296 hf_adjustment(sbr, sbr->Xsbr[ch]
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
297 #ifdef SBR_LOW_POWER
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
298 ,deg
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
299 #endif
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
300 ,ch);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
301 #endif
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
302 }
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
303
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
304 if ((sbr->just_seeked != 0) || dont_process)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
305 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
306 for (l = 0; l < sbr->numTimeSlotsRate; l++)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
307 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
308 for (k = 0; k < 32; k++)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
309 {
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
310 QMF_RE(X[l][k]) = QMF_RE(sbr->Xsbr[ch][l + sbr->tHFAdj][k]);
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
311 #ifndef SBR_LOW_POWER
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
312 QMF_IM(X[l][k]) = QMF_IM(sbr->Xsbr[ch][l + sbr->tHFAdj][k]);
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
313 #endif
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
314 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
315 for (k = 32; k < 64; k++)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
316 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
317 QMF_RE(X[l][k]) = 0;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
318 #ifndef SBR_LOW_POWER
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
319 QMF_IM(X[l][k]) = 0;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
320 #endif
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
321 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
322 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
323 } else {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
324 for (l = 0; l < sbr->numTimeSlotsRate; l++)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
325 {
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
326 uint8_t kx_band, M_band, bsco_band;
12527
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 (l < sbr->t_E[ch][0])
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
329 {
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
330 kx_band = sbr->kx_prev;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
331 M_band = sbr->M_prev;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
332 bsco_band = sbr->bsco_prev;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
333 } else {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
334 kx_band = sbr->kx;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
335 M_band = sbr->M;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
336 bsco_band = sbr->bsco;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
337 }
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
338
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
339 #ifndef SBR_LOW_POWER
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
340 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
341 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
342 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
343 QMF_IM(X[l][k]) = QMF_IM(sbr->Xsbr[ch][l + sbr->tHFAdj][k]);
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
344 }
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
345 for (k = kx_band + bsco_band; k < kx_band + M_band; k++)
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
346 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
347 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
348 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
349 }
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
350 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
351 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
352 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
353 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
354 }
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
355 #else
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
356 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
357 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
358 QMF_RE(X[l][k]) = QMF_RE(sbr->Xsbr[ch][l + sbr->tHFAdj][k]);
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
359 }
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
360 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
361 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
362 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
363 }
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
364 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
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][k]) = 0;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
367 }
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
368 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
369 QMF_RE(sbr->Xsbr[ch][l + sbr->tHFAdj][kx_band - 1 + bsco_band]);
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
370 #endif
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
371 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
372 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
373 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
374
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
375 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
376 const uint8_t just_seeked, const uint8_t downSampledSBR)
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
377 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
378 uint8_t dont_process = 0;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
379 uint8_t ret = 0;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
380 ALIGN qmf_t X[MAX_NTSR][64];
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
381
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
382 if (sbr == NULL)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
383 return 20;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
384
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
385 /* case can occur due to bit errors */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
386 if (sbr->id_aac != ID_CPE)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
387 return 21;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
388
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
389 if (sbr->ret || (sbr->header_count == 0))
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
390 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
391 /* don't process just upsample */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
392 dont_process = 1;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
393
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
394 /* Re-activate reset for next frame */
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
395 if (sbr->ret && sbr->Reset)
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
396 sbr->bs_start_freq_prev = -1;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
397 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
398
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
399 if (just_seeked)
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
400 {
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
401 sbr->just_seeked = 1;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
402 } else {
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
403 sbr->just_seeked = 0;
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
404 }
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
405
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
406 sbr_process_channel(sbr, left_chan, X, 0, dont_process, downSampledSBR);
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
407 /* subband synthesis */
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
408 if (downSampledSBR)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
409 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
410 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
411 } else {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
412 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
413 }
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
414
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
415 sbr_process_channel(sbr, right_chan, X, 1, dont_process, downSampledSBR);
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
416 /* subband synthesis */
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
417 if (downSampledSBR)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
418 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
419 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
420 } else {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
421 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
422 }
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
423
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
424 if (sbr->bs_header_flag)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
425 sbr->just_seeked = 0;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
426
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
427 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
428 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
429 ret = sbr_save_prev_data(sbr, 0);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
430 if (ret) return ret;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
431 ret = sbr_save_prev_data(sbr, 1);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
432 if (ret) return ret;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
433 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
434
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
435 sbr_save_matrix(sbr, 0);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
436 sbr_save_matrix(sbr, 1);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
437
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
438 sbr->frame++;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
439
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
440 //#define POST_QMF_PRINT
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
441 #ifdef POST_QMF_PRINT
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
442 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
443 int i;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
444 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
445 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
446 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
447 }
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
448 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
449 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
450 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
451 }
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
452 }
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
453 #endif
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
454
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
455 return 0;
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
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
458 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
459 const uint8_t just_seeked, const uint8_t downSampledSBR)
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
460 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
461 uint8_t dont_process = 0;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
462 uint8_t ret = 0;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
463 ALIGN qmf_t X[MAX_NTSR][64];
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
464
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
465 if (sbr == NULL)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
466 return 20;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
467
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
468 /* case can occur due to bit errors */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
469 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
470 return 21;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
471
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
472 if (sbr->ret || (sbr->header_count == 0))
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 /* don't process just upsample */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
475 dont_process = 1;
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 /* Re-activate reset for next frame */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
478 if (sbr->ret && sbr->Reset)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
479 sbr->bs_start_freq_prev = -1;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
480 }
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
481
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
482 if (just_seeked)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
483 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
484 sbr->just_seeked = 1;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
485 } else {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
486 sbr->just_seeked = 0;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
487 }
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
488
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
489 sbr_process_channel(sbr, channel, X, 0, dont_process, downSampledSBR);
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
490 /* subband synthesis */
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
491 if (downSampledSBR)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
492 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
493 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
494 } else {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
495 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
496 }
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
497
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
498 if (sbr->bs_header_flag)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
499 sbr->just_seeked = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
500
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
501 if (sbr->header_count != 0 && sbr->ret == 0)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
502 {
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
503 ret = sbr_save_prev_data(sbr, 0);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
504 if (ret) return ret;
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
505 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
506
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
507 sbr_save_matrix(sbr, 0);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
508
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
509 sbr->frame++;
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
510
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
511 //#define POST_QMF_PRINT
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
512 #ifdef POST_QMF_PRINT
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
513 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
514 int i;
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
515 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
516 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
517 printf("%d\n", channel[i]);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
518 }
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
519 }
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
520 #endif
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
521
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
522 return 0;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
523 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
524
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
525 #if (defined(PS_DEC) || defined(DRM_PS))
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
526 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
527 const uint8_t just_seeked, const uint8_t downSampledSBR)
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
528 {
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
529 uint8_t l, k;
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
530 uint8_t dont_process = 0;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
531 uint8_t ret = 0;
17098
rathann
parents: 14727
diff changeset
532 ALIGN qmf_t X_left[38][64] = {{{0}}};
rathann
parents: 14727
diff changeset
533 ALIGN qmf_t X_right[38][64] = {{{0}}}; /* must set this to 0 */
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
534
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
535 if (sbr == NULL)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
536 return 20;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
537
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
538 /* case can occur due to bit errors */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
539 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
540 return 21;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
541
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
542 if (sbr->ret || (sbr->header_count == 0))
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
543 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
544 /* don't process just upsample */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
545 dont_process = 1;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
546
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
547 /* Re-activate reset for next frame */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
548 if (sbr->ret && sbr->Reset)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
549 sbr->bs_start_freq_prev = -1;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
550 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
551
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
552 if (just_seeked)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
553 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
554 sbr->just_seeked = 1;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
555 } else {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
556 sbr->just_seeked = 0;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
557 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
558
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
559 if (sbr->qmfs[1] == NULL)
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
560 {
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
561 sbr->qmfs[1] = qmfs_init((downSampledSBR)?32:64);
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
562 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
563
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
564 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
565
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
566 /* 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
567 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
568 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
569 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
570 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
571 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
572 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
573 }
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
574 }
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
575
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
576 /* perform parametric stereo */
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
577 #ifdef DRM_PS
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
578 if (sbr->Is_DRM_SBR)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
579 {
18141
59b6fa5b4201 Update to faad2 cvs 20040915+MPlayer fixes
rtognimp
parents: 17098
diff changeset
580 drm_ps_decode(sbr->drm_ps, (sbr->ret > 0), sbr->sample_rate, X_left, X_right);
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
581 } else {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
582 #endif
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
583 #ifdef PS_DEC
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
584 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
585 #endif
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
586 #ifdef DRM_PS
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
587 }
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
588 #endif
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
589
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
590 /* subband synthesis */
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
591 if (downSampledSBR)
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
592 {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
593 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
594 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
595 } else {
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
596 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
597 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
598 }
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
599
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
600 if (sbr->bs_header_flag)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
601 sbr->just_seeked = 0;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
602
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
603 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
604 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
605 ret = sbr_save_prev_data(sbr, 0);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
606 if (ret) return ret;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
607 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
608
13453
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
609 sbr_save_matrix(sbr, 0);
6d50ef45a058 Update FAAD to a 2.1 beta CVS snapshot from 2004.07.12.
diego
parents: 12625
diff changeset
610
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
611 sbr->frame++;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
612
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
613 return 0;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
614 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
615 #endif
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
616
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
617 #endif