annotate libfaad2/sbr_tf_grid.c @ 10725:e989150f8216

libfaad2 v2.0rc1 imported
author arpi
date Sat, 30 Aug 2003 22:30:28 +0000
parents
children 3185f64f6350
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1 /*
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
3 ** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
4 **
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
5 ** This program is free software; you can redistribute it and/or modify
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
6 ** it under the terms of the GNU General Public License as published by
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
7 ** the Free Software Foundation; either version 2 of the License, or
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
8 ** (at your option) any later version.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
9 **
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
10 ** This program is distributed in the hope that it will be useful,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
13 ** GNU General Public License for more details.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
14 **
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
15 ** You should have received a copy of the GNU General Public License
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
16 ** along with this program; if not, write to the Free Software
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
17 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
18 **
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
19 ** Any non-GPL usage of this software or parts of this software is strictly
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
20 ** forbidden.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
21 **
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
22 ** Commercial non-GPL licensing of this software is possible.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
23 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
24 **
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
25 ** $Id: sbr_tf_grid.c,v 1.1 2003/07/29 08:20:13 menno Exp $
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
26 **/
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
27
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
28 /* Time/Frequency grid */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
29
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
30 #include "common.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
31 #include "structs.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
32
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
33 #ifdef SBR_DEC
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
34
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
35 #include <stdlib.h>
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
36
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
37 #include "sbr_syntax.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
38 #include "sbr_tf_grid.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
39
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
40 void envelope_time_border_vector(sbr_info *sbr, uint8_t ch)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
41 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
42 uint8_t l, border;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
43
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
44 for (l = 0; l <= sbr->L_E[ch]; l++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
45 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
46 sbr->t_E[ch][l] = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
47 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
48
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
49 sbr->t_E[ch][0] = sbr->rate * sbr->abs_bord_lead[ch];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
50 sbr->t_E[ch][sbr->L_E[ch]] = sbr->rate * sbr->abs_bord_trail[ch];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
51
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
52 switch (sbr->bs_frame_class[ch])
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
53 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
54 case FIXFIX:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
55 switch (sbr->L_E[ch])
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
56 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
57 case 4:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
58 sbr->t_E[ch][3] = sbr->rate * 12;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
59 sbr->t_E[ch][2] = sbr->rate * 8;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
60 sbr->t_E[ch][1] = sbr->rate * 4;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
61 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
62 case 2:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
63 sbr->t_E[ch][1] = sbr->rate * 8;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
64 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
65 default:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
66 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
67 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
68 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
69
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
70 case FIXVAR:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
71 if (sbr->L_E[ch] > 1)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
72 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
73 int8_t i = sbr->L_E[ch];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
74 border = sbr->abs_bord_trail[ch];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
75
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
76 for (l = 0; l < (sbr->L_E[ch] - 1); l++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
77 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
78 border -= sbr->bs_rel_bord[ch][l];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
79 sbr->t_E[ch][--i] = sbr->rate * border;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
80 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
81 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
82 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
83
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
84 case VARFIX:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
85 if (sbr->L_E[ch] > 1)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
86 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
87 int8_t i = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
88 border = sbr->abs_bord_lead[ch];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
89
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
90 for (l = 0; l < (sbr->L_E[ch] - 1); l++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
91 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
92 border += sbr->bs_rel_bord[ch][l];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
93 sbr->t_E[ch][i++] = sbr->rate * border;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
94 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
95 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
96 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
97
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
98 case VARVAR:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
99 if (sbr->bs_num_rel_0[ch])
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
100 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
101 int8_t i = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
102 border = sbr->abs_bord_lead[ch];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
103
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
104 for (l = 0; l < sbr->bs_num_rel_0[ch]; l++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
105 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
106 border += sbr->bs_rel_bord_0[ch][l];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
107 sbr->t_E[ch][i++] = sbr->rate * border;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
108 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
109 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
110
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
111 if (sbr->bs_num_rel_1[ch])
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
112 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
113 int8_t i = sbr->L_E[ch];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
114 border = sbr->abs_bord_trail[ch];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
115
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
116 for (l = 0; l < sbr->bs_num_rel_1[ch]; l++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
117 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
118 border -= sbr->bs_rel_bord_1[ch][l];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
119 sbr->t_E[ch][--i] = sbr->rate * border;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
120 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
121 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
122 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
123 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
124 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
125
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
126 void noise_floor_time_border_vector(sbr_info *sbr, uint8_t ch)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
127 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
128 sbr->t_Q[ch][0] = sbr->t_E[ch][0];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
129
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
130 if (sbr->L_E[ch] == 1)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
131 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
132 sbr->t_Q[ch][1] = sbr->t_E[ch][1];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
133 sbr->t_Q[ch][2] = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
134 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
135 uint8_t index = middleBorder(sbr, ch);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
136 sbr->t_Q[ch][1] = sbr->t_E[ch][index];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
137 sbr->t_Q[ch][2] = sbr->t_E[ch][sbr->L_E[ch]];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
138 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
139 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
140
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
141 static int16_t rel_bord_lead(sbr_info *sbr, uint8_t ch, uint8_t l)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
142 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
143 uint8_t i;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
144 int16_t acc = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
145
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
146 switch (sbr->bs_frame_class[ch])
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
147 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
148 case FIXFIX:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
149 return NO_TIME_SLOTS/sbr->L_E[ch];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
150 case FIXVAR:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
151 return 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
152 case VARFIX:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
153 for (i = 0; i < l; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
154 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
155 acc += sbr->bs_rel_bord[ch][i];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
156 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
157 return acc;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
158 case VARVAR:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
159 for (i = 0; i < l; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
160 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
161 acc += sbr->bs_rel_bord_0[ch][i];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
162 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
163 return acc;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
164 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
165
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
166 return 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
167 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
168
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
169 static int16_t rel_bord_trail(sbr_info *sbr, uint8_t ch, uint8_t l)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
170 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
171 uint8_t i;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
172 int16_t acc = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
173
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
174 switch (sbr->bs_frame_class[ch])
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
175 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
176 case FIXFIX:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
177 case VARFIX:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
178 return 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
179 case FIXVAR:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
180 for (i = 0; i < l; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
181 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
182 acc += sbr->bs_rel_bord[ch][i];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
183 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
184 return acc;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
185 case VARVAR:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
186 for (i = 0; i < l; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
187 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
188 acc += sbr->bs_rel_bord_1[ch][i];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
189 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
190 return acc;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
191 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
192
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
193 return 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
194 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
195
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
196 static uint8_t middleBorder(sbr_info *sbr, uint8_t ch)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
197 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
198 int8_t retval;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
199
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
200 switch (sbr->bs_frame_class[ch])
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
201 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
202 case FIXFIX:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
203 retval = sbr->L_E[ch]/2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
204 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
205 case VARFIX:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
206 if (sbr->bs_pointer[ch] == 0)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
207 retval = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
208 else if (sbr->bs_pointer[ch] == 1)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
209 retval = sbr->L_E[ch] - 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
210 else
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
211 retval = sbr->bs_pointer[ch] - 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
212 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
213 case FIXVAR:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
214 case VARVAR:
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
215 if (sbr->bs_pointer[ch] > 1)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
216 retval = sbr->L_E[ch] + 1 - sbr->bs_pointer[ch];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
217 else
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
218 retval = sbr->L_E[ch] - 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
219 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
220 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
221
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
222 return (retval > 0) ? retval : 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
223 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
224
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
225
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
226 #endif