annotate libfaad2/bits.c @ 18171:6019c54e3b11

1.260: 10l 1.259: syntax fix for "s" (keyboard control) 1.258: minor markup fixes
author kraymer
date Fri, 21 Apr 2006 10:54:00 +0000
parents 59b6fa5b4201
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: 14727
diff changeset
25 ** $Id: bits.c,v 1.39 2004/09/04 14:56:27 menno Exp $
10725
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 #include "common.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
29 #include "structs.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
30
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
31 #include <stdlib.h>
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
32 #include <string.h>
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
33 #include "bits.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
34
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
35 /* initialize buffer, call once before first getbits or showbits */
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
36 void faad_initbits(bitfile *ld, const void *_buffer, const uint32_t buffer_size)
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
37 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
38 uint32_t tmp;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
39
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
40 if (ld == NULL)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
41 return;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
42
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
43 memset(ld, 0, sizeof(bitfile));
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
44
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
45 if (buffer_size == 0 || _buffer == NULL)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
46 {
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
47 ld->error = 1;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
48 ld->no_more_reading = 1;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
49 return;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
50 }
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
51
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
52 ld->buffer = faad_malloc((buffer_size+12)*sizeof(uint8_t));
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
53 memset(ld->buffer, 0, (buffer_size+12)*sizeof(uint8_t));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
54 memcpy(ld->buffer, _buffer, buffer_size*sizeof(uint8_t));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
55
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
56 ld->buffer_size = buffer_size;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
57
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
58 tmp = getdword((uint32_t*)ld->buffer);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
59 ld->bufa = tmp;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
60
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
61 tmp = getdword((uint32_t*)ld->buffer + 1);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
62 ld->bufb = tmp;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
63
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
64 ld->start = (uint32_t*)ld->buffer;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
65 ld->tail = ((uint32_t*)ld->buffer + 2);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
66
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
67 ld->bits_left = 32;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
68
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
69 ld->bytes_used = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
70 ld->no_more_reading = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
71 ld->error = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
72 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
73
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
74 void faad_endbits(bitfile *ld)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
75 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
76 if (ld)
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
77 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
78 if (ld->buffer)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
79 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
80 faad_free(ld->buffer);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
81 ld->buffer = NULL;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
82 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
83 }
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
84 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
85
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
86 uint32_t faad_get_processed_bits(bitfile *ld)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
87 {
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
88 return (uint32_t)(8 * (4*(ld->tail - ld->start) - 4) - (ld->bits_left));
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
89 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
90
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
91 uint8_t faad_byte_align(bitfile *ld)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
92 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
93 uint8_t remainder = (uint8_t)((32 - ld->bits_left) % 8);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
94
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
95 if (remainder)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
96 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
97 faad_flushbits(ld, 8 - remainder);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
98 return (8 - remainder);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
99 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
100 return 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
101 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
102
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
103 void faad_flushbits_ex(bitfile *ld, uint32_t bits)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
104 {
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
105 uint32_t tmp;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
106
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
107 ld->bufa = ld->bufb;
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
108 if (ld->no_more_reading == 0)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
109 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
110 tmp = getdword(ld->tail);
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
111 ld->tail++;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
112 } else {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
113 tmp = 0;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
114 }
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
115 ld->bufb = tmp;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
116 ld->bits_left += (32 - bits);
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
117 ld->bytes_used += 4;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
118 if (ld->bytes_used == ld->buffer_size)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
119 ld->no_more_reading = 1;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
120 if (ld->bytes_used > ld->buffer_size)
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
121 ld->error = 1;
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
122 }
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
123
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
124 /* rewind to beginning */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
125 void faad_rewindbits(bitfile *ld)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
126 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
127 uint32_t tmp;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
128
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
129 tmp = ld->start[0];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
130 #ifndef ARCH_IS_BIG_ENDIAN
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
131 BSWAP(tmp);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
132 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
133 ld->bufa = tmp;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
134
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
135 tmp = ld->start[1];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
136 #ifndef ARCH_IS_BIG_ENDIAN
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
137 BSWAP(tmp);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
138 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
139 ld->bufb = tmp;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
140 ld->bits_left = 32;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
141 ld->tail = &ld->start[2];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
142 ld->bytes_used = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
143 ld->no_more_reading = 0;
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 uint8_t *faad_getbitbuffer(bitfile *ld, uint32_t bits
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
147 DEBUGDEC)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
148 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
149 uint16_t i;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
150 uint8_t temp;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
151 uint16_t bytes = (uint16_t)bits / 8;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
152 uint8_t remainder = (uint8_t)bits % 8;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
153
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
154 uint8_t *buffer = (uint8_t*)faad_malloc((bytes+1)*sizeof(uint8_t));
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
155
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
156 for (i = 0; i < bytes; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
157 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
158 buffer[i] = (uint8_t)faad_getbits(ld, 8 DEBUGVAR(print,var,dbg));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
159 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
160
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
161 if (remainder)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
162 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
163 temp = (uint8_t)faad_getbits(ld, remainder DEBUGVAR(print,var,dbg)) << (8-remainder);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
164
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
165 buffer[bytes] = temp;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
166 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
167
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
168 return buffer;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
169 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
170
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
171 #ifdef DRM
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
172 /* return the original data buffer */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
173 void *faad_origbitbuffer(bitfile *ld)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
174 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
175 return (void*)ld->start;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
176 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
177
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
178 /* return the original data buffer size */
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
179 uint32_t faad_origbitbuffer_size(bitfile *ld)
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
180 {
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
181 return ld->buffer_size;
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
182 }
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
183 #endif
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
184
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
185 /* reversed bit reading routines, used for RVLC and HCR */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
186 void faad_initbits_rev(bitfile *ld, void *buffer,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
187 uint32_t bits_in_buffer)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
188 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
189 uint32_t tmp;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
190 int32_t index;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
191
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
192 ld->buffer_size = bit2byte(bits_in_buffer);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
193
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
194 index = (bits_in_buffer+31)/32 - 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
195
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
196 ld->start = (uint32_t*)buffer + index - 2;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
197
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
198 tmp = getdword((uint32_t*)buffer + index);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
199 ld->bufa = tmp;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
200
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
201 tmp = getdword((uint32_t*)buffer + index - 1);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
202 ld->bufb = tmp;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
203
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
204 ld->tail = (uint32_t*)buffer + index;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
205
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
206 ld->bits_left = bits_in_buffer % 32;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
207 if (ld->bits_left == 0)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
208 ld->bits_left = 32;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
209
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
210 ld->bytes_used = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
211 ld->no_more_reading = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
212 ld->error = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
213 }