diff options
Diffstat (limited to 'apps/codecs/libalac/alac.c')
-rw-r--r-- | apps/codecs/libalac/alac.c | 64 |
1 files changed, 27 insertions, 37 deletions
diff --git a/apps/codecs/libalac/alac.c b/apps/codecs/libalac/alac.c index 0082b6dd42..5487c68961 100644 --- a/apps/codecs/libalac/alac.c +++ b/apps/codecs/libalac/alac.c | |||
@@ -184,50 +184,40 @@ static inline void unreadbits(alac_file *alac, int bits) | |||
184 | alac->input_buffer_bitaccumulator *= -1; | 184 | alac->input_buffer_bitaccumulator *= -1; |
185 | } | 185 | } |
186 | 186 | ||
187 | static const unsigned char bittab[16] ICONST_ATTR = { | ||
188 | 0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4 | ||
189 | }; | ||
190 | |||
187 | static inline int count_leading_zeros(int input) | 191 | static inline int count_leading_zeros(int input) |
188 | { | 192 | { |
189 | int output = 0; | 193 | int output = 32; |
190 | int curbyte = 0; | ||
191 | |||
192 | curbyte = input >> 24; | ||
193 | if (curbyte) goto found; | ||
194 | output += 8; | ||
195 | |||
196 | curbyte = input >> 16; | ||
197 | if (curbyte & 0xff) goto found; | ||
198 | output += 8; | ||
199 | |||
200 | curbyte = input >> 8; | ||
201 | if (curbyte & 0xff) goto found; | ||
202 | output += 8; | ||
203 | |||
204 | curbyte = input; | ||
205 | if (curbyte & 0xff) goto found; | ||
206 | output += 8; | ||
207 | 194 | ||
208 | return output; | 195 | #if 0 |
209 | 196 | /* Experimentation has shown that the following test is always false, | |
210 | found: | 197 | so we don't bother to perform it. */ |
211 | if (!(curbyte & 0xf0)) | 198 | if (input & 0xffff0000) |
212 | { | 199 | { |
213 | output += 4; | 200 | input >>= 16; |
201 | output -= 16; | ||
214 | } | 202 | } |
215 | else | 203 | #endif |
216 | curbyte >>= 4; | 204 | if (input & 0xff00) |
217 | 205 | { | |
218 | if (curbyte & 0x8) | 206 | input >>= 8; |
219 | return output; | 207 | output -= 8; |
220 | if (curbyte & 0x4) | 208 | } |
221 | return output + 1; | 209 | if (input & 0xf0) |
222 | if (curbyte & 0x2) | 210 | { |
223 | return output + 2; | 211 | input >>= 4; |
224 | if (curbyte & 0x1) | 212 | output -= 4; |
225 | return output + 3; | 213 | } |
226 | 214 | output -= bittab[input]; | |
227 | /* shouldn't get here: */ | 215 | return output; |
228 | return output + 4; | ||
229 | } | 216 | } |
230 | 217 | ||
218 | |||
219 | |||
220 | |||
231 | void basterdised_rice_decompress(alac_file *alac, | 221 | void basterdised_rice_decompress(alac_file *alac, |
232 | int32_t *output_buffer, | 222 | int32_t *output_buffer, |
233 | int output_size, | 223 | int output_size, |