Mercurial > audlegacy-plugins
annotate src/aac/libfaad2/bits.c @ 681:1d8b08df98c3 trunk
[svn] - synchronise with FAAD 2.5
author | nenolod |
---|---|
date | Tue, 20 Feb 2007 04:37:37 -0800 |
parents | 3da1b8942b8b |
children | e6c5fdae6e88 |
rev | line source |
---|---|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
1 /* |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
2 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
681 | 3 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
4 ** |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
5 ** This program is free software; you can redistribute it and/or modify |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
6 ** it under the terms of the GNU General Public License as published by |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
7 ** the Free Software Foundation; either version 2 of the License, or |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
8 ** (at your option) any later version. |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
9 ** |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
10 ** This program is distributed in the hope that it will be useful, |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
13 ** GNU General Public License for more details. |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
14 ** |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
15 ** You should have received a copy of the GNU General Public License |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
16 ** along with this program; if not, write to the Free Software |
681 | 17 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
18 ** |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
19 ** Any non-GPL usage of this software or parts of this software is strictly |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
20 ** forbidden. |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
21 ** |
681 | 22 ** Software using this code must display the following message visibly in or |
23 ** on each copy of the software: | |
24 ** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com" | |
25 ** in, for example, the about-box or help/startup screen. | |
26 ** | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
27 ** Commercial non-GPL licensing of this software is possible. |
681 | 28 ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
29 ** |
681 | 30 ** $Id: bits.c,v 1.42 2006/07/07 12:35:24 sur Exp $ |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
31 **/ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
32 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
33 #include "common.h" |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
34 #include "structs.h" |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
35 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
36 #include <stdlib.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
37 #include "bits.h" |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
38 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
39 /* initialize buffer, call once before first getbits or showbits */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
40 void faad_initbits(bitfile *ld, const void *_buffer, const uint32_t buffer_size) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
41 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
42 uint32_t tmp; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
43 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
44 if (ld == NULL) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
45 return; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
46 |
681 | 47 // useless |
48 //memset(ld, 0, sizeof(bitfile)); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
49 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
50 if (buffer_size == 0 || _buffer == NULL) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
51 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
52 ld->error = 1; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
53 return; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
54 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
55 |
681 | 56 ld->buffer = _buffer; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
57 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
58 ld->buffer_size = buffer_size; |
681 | 59 ld->bytes_left = buffer_size; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
60 |
681 | 61 if (ld->bytes_left >= 4) |
62 { | |
63 tmp = getdword((uint32_t*)ld->buffer); | |
64 ld->bytes_left -= 4; | |
65 } else { | |
66 tmp = getdword_n((uint32_t*)ld->buffer, ld->bytes_left); | |
67 ld->bytes_left = 0; | |
68 } | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
69 ld->bufa = tmp; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
70 |
681 | 71 if (ld->bytes_left >= 4) |
72 { | |
73 tmp = getdword((uint32_t*)ld->buffer + 1); | |
74 ld->bytes_left -= 4; | |
75 } else { | |
76 tmp = getdword_n((uint32_t*)ld->buffer + 1, ld->bytes_left); | |
77 ld->bytes_left = 0; | |
78 } | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
79 ld->bufb = tmp; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
80 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
81 ld->start = (uint32_t*)ld->buffer; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
82 ld->tail = ((uint32_t*)ld->buffer + 2); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
83 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
84 ld->bits_left = 32; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
85 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
86 ld->error = 0; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
87 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
88 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
89 void faad_endbits(bitfile *ld) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
90 { |
681 | 91 // void |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
92 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
93 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
94 uint32_t faad_get_processed_bits(bitfile *ld) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
95 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
96 return (uint32_t)(8 * (4*(ld->tail - ld->start) - 4) - (ld->bits_left)); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
97 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
98 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
99 uint8_t faad_byte_align(bitfile *ld) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
100 { |
681 | 101 int remainder = (32 - ld->bits_left) & 0x7; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
102 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
103 if (remainder) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
104 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
105 faad_flushbits(ld, 8 - remainder); |
681 | 106 return (uint8_t)(8 - remainder); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
107 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
108 return 0; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
109 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
110 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
111 void faad_flushbits_ex(bitfile *ld, uint32_t bits) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
112 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
113 uint32_t tmp; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
114 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
115 ld->bufa = ld->bufb; |
681 | 116 if (ld->bytes_left >= 4) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
117 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
118 tmp = getdword(ld->tail); |
681 | 119 ld->bytes_left -= 4; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
120 } else { |
681 | 121 tmp = getdword_n(ld->tail, ld->bytes_left); |
122 ld->bytes_left = 0; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
123 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
124 ld->bufb = tmp; |
681 | 125 ld->tail++; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
126 ld->bits_left += (32 - bits); |
681 | 127 //ld->bytes_left -= 4; |
128 // if (ld->bytes_left == 0) | |
129 // ld->no_more_reading = 1; | |
130 // if (ld->bytes_left < 0) | |
131 // ld->error = 1; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
132 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
133 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
134 /* rewind to beginning */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
135 void faad_rewindbits(bitfile *ld) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
136 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
137 uint32_t tmp; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
138 |
681 | 139 ld->bytes_left = ld->buffer_size; |
140 | |
141 if (ld->bytes_left >= 4) | |
142 { | |
143 tmp = getdword((uint32_t*)&ld->start[0]); | |
144 ld->bytes_left -= 4; | |
145 } else { | |
146 tmp = getdword_n((uint32_t*)&ld->start[0], ld->bytes_left); | |
147 ld->bytes_left = 0; | |
148 } | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
149 ld->bufa = tmp; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
150 |
681 | 151 if (ld->bytes_left >= 4) |
152 { | |
153 tmp = getdword((uint32_t*)&ld->start[1]); | |
154 ld->bytes_left -= 4; | |
155 } else { | |
156 tmp = getdword_n((uint32_t*)&ld->start[1], ld->bytes_left); | |
157 ld->bytes_left = 0; | |
158 } | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
159 ld->bufb = tmp; |
681 | 160 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
161 ld->bits_left = 32; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
162 ld->tail = &ld->start[2]; |
681 | 163 } |
164 | |
165 /* reset to a certain point */ | |
166 void faad_resetbits(bitfile *ld, int bits) | |
167 { | |
168 uint32_t tmp; | |
169 int words = bits >> 5; | |
170 int remainder = bits & 0x1F; | |
171 | |
172 ld->bytes_left = ld->buffer_size - words*4; | |
173 | |
174 if (ld->bytes_left >= 4) | |
175 { | |
176 tmp = getdword(&ld->start[words]); | |
177 ld->bytes_left -= 4; | |
178 } else { | |
179 tmp = getdword_n(&ld->start[words], ld->bytes_left); | |
180 ld->bytes_left = 0; | |
181 } | |
182 ld->bufa = tmp; | |
183 | |
184 if (ld->bytes_left >= 4) | |
185 { | |
186 tmp = getdword(&ld->start[words+1]); | |
187 ld->bytes_left -= 4; | |
188 } else { | |
189 tmp = getdword_n(&ld->start[words+1], ld->bytes_left); | |
190 ld->bytes_left = 0; | |
191 } | |
192 ld->bufb = tmp; | |
193 | |
194 ld->bits_left = 32 - remainder; | |
195 ld->tail = &ld->start[words+2]; | |
196 | |
197 /* recheck for reading too many bytes */ | |
198 ld->error = 0; | |
199 // if (ld->bytes_left == 0) | |
200 // ld->no_more_reading = 1; | |
201 // if (ld->bytes_left < 0) | |
202 // ld->error = 1; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
203 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
204 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
205 uint8_t *faad_getbitbuffer(bitfile *ld, uint32_t bits |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
206 DEBUGDEC) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
207 { |
681 | 208 int i; |
209 unsigned int temp; | |
210 int bytes = bits >> 3; | |
211 int remainder = bits & 0x7; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
212 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
213 uint8_t *buffer = (uint8_t*)faad_malloc((bytes+1)*sizeof(uint8_t)); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
214 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
215 for (i = 0; i < bytes; i++) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
216 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
217 buffer[i] = (uint8_t)faad_getbits(ld, 8 DEBUGVAR(print,var,dbg)); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
218 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
219 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
220 if (remainder) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
221 { |
681 | 222 temp = faad_getbits(ld, remainder DEBUGVAR(print,var,dbg)) << (8-remainder); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
223 |
681 | 224 buffer[bytes] = (uint8_t)temp; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
225 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
226 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
227 return buffer; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
228 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
229 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
230 #ifdef DRM |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
231 /* return the original data buffer */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
232 void *faad_origbitbuffer(bitfile *ld) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
233 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
234 return (void*)ld->start; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
235 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
236 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
237 /* return the original data buffer size */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
238 uint32_t faad_origbitbuffer_size(bitfile *ld) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
239 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
240 return ld->buffer_size; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
241 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
242 #endif |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
243 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
244 /* reversed bit reading routines, used for RVLC and HCR */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
245 void faad_initbits_rev(bitfile *ld, void *buffer, |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
246 uint32_t bits_in_buffer) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
247 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
248 uint32_t tmp; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
249 int32_t index; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
250 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
251 ld->buffer_size = bit2byte(bits_in_buffer); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
252 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
253 index = (bits_in_buffer+31)/32 - 1; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
254 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
255 ld->start = (uint32_t*)buffer + index - 2; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
256 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
257 tmp = getdword((uint32_t*)buffer + index); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
258 ld->bufa = tmp; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
259 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
260 tmp = getdword((uint32_t*)buffer + index - 1); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
261 ld->bufb = tmp; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
262 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
263 ld->tail = (uint32_t*)buffer + index; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
264 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
265 ld->bits_left = bits_in_buffer % 32; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
266 if (ld->bits_left == 0) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
267 ld->bits_left = 32; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
268 |
681 | 269 ld->bytes_left = ld->buffer_size; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
270 ld->error = 0; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
271 } |
681 | 272 |
273 /* EOF */ |