summaryrefslogtreecommitdiff
path: root/apps/codecs
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs')
-rw-r--r--apps/codecs/libalac/alac.c64
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
187static 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
187static inline int count_leading_zeros(int input) 191static 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,
210found: 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
231void basterdised_rice_decompress(alac_file *alac, 221void basterdised_rice_decompress(alac_file *alac,
232 int32_t *output_buffer, 222 int32_t *output_buffer,
233 int output_size, 223 int output_size,