author | harlekin <harlekin> | 2002-04-19 16:08:55 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-04-19 16:08:55 (UTC) |
commit | 7ea4abeb652e6787e57a938e1ca028d25fd249ce (patch) (unidiff) | |
tree | ee08f2d9d6aaa8adb1c5f07f4124da8a61eb8cd5 /core/multimedia/opieplayer/libmad/bit.c | |
parent | caa7ced77b9014526607f9f65c58aabe7e0ba631 (diff) | |
download | opie-7ea4abeb652e6787e57a938e1ca028d25fd249ce.zip opie-7ea4abeb652e6787e57a938e1ca028d25fd249ce.tar.gz opie-7ea4abeb652e6787e57a938e1ca028d25fd249ce.tar.bz2 |
new libmad version, less cpu usage
Diffstat (limited to 'core/multimedia/opieplayer/libmad/bit.c') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/multimedia/opieplayer/libmad/bit.c | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/core/multimedia/opieplayer/libmad/bit.c b/core/multimedia/opieplayer/libmad/bit.c index 2466c5f..4a4661b 100644 --- a/core/multimedia/opieplayer/libmad/bit.c +++ b/core/multimedia/opieplayer/libmad/bit.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * mad - MPEG audio decoder | 2 | * libmad - MPEG audio decoder library |
3 | * Copyright (C) 2000-2001 Robert Leslie | 3 | * Copyright (C) 2000-2001 Robert Leslie |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify | 5 | * This program is free software; you can redistribute it and/or modify |
@@ -197,22 +197,39 @@ void mad_bit_write(struct mad_bitptr *bitptr, unsigned int len, | |||
197 | unsigned short mad_bit_crc(struct mad_bitptr bitptr, unsigned int len, | 197 | unsigned short mad_bit_crc(struct mad_bitptr bitptr, unsigned int len, |
198 | unsigned short init) | 198 | unsigned short init) |
199 | { | 199 | { |
200 | register unsigned int crc, data; | 200 | register unsigned int crc; |
201 | 201 | ||
202 | # if CHAR_BIT == 8 | 202 | for (crc = init; len >= 32; len -= 32) { |
203 | for (crc = init; len >= 8; len -= 8) { | 203 | register unsigned long data; |
204 | crc = (crc << 8) ^ | 204 | |
205 | crc_table[((crc >> 8) ^ mad_bit_read(&bitptr, 8)) & 0xff]; | 205 | data = mad_bit_read(&bitptr, 32); |
206 | |||
207 | crc = (crc << 8) ^ crc_table[((crc >> 8) ^ (data >> 24)) & 0xff]; | ||
208 | crc = (crc << 8) ^ crc_table[((crc >> 8) ^ (data >> 16)) & 0xff]; | ||
209 | crc = (crc << 8) ^ crc_table[((crc >> 8) ^ (data >> 8)) & 0xff]; | ||
210 | crc = (crc << 8) ^ crc_table[((crc >> 8) ^ (data >> 0)) & 0xff]; | ||
211 | } | ||
212 | |||
213 | switch (len / 8) { | ||
214 | case 3: crc = (crc << 8) ^ | ||
215 | crc_table[((crc >> 8) ^ mad_bit_read(&bitptr, 8)) & 0xff]; | ||
216 | case 2: crc = (crc << 8) ^ | ||
217 | crc_table[((crc >> 8) ^ mad_bit_read(&bitptr, 8)) & 0xff]; | ||
218 | case 1: crc = (crc << 8) ^ | ||
219 | crc_table[((crc >> 8) ^ mad_bit_read(&bitptr, 8)) & 0xff]; | ||
220 | |||
221 | len %= 8; | ||
222 | |||
223 | case 0: break; | ||
206 | } | 224 | } |
207 | # else | ||
208 | crc = init; | ||
209 | # endif | ||
210 | 225 | ||
211 | while (len--) { | 226 | while (len--) { |
212 | data = mad_bit_read(&bitptr, 1) ^ (crc >> 15); | 227 | register unsigned int msb; |
228 | |||
229 | msb = mad_bit_read(&bitptr, 1) ^ (crc >> 15); | ||
213 | 230 | ||
214 | crc <<= 1; | 231 | crc <<= 1; |
215 | if (data & 1) | 232 | if (msb & 1) |
216 | crc ^= CRC_POLY; | 233 | crc ^= CRC_POLY; |
217 | } | 234 | } |
218 | 235 | ||