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,26 +1,26 @@ | |||
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 |
6 | * it under the terms of the GNU General Public License as published by | 6 | * it under the terms of the GNU General Public License as published by |
7 | * the Free Software Foundation; either version 2 of the License, or | 7 | * the Free Software Foundation; either version 2 of the License, or |
8 | * (at your option) any later version. | 8 | * (at your option) any later version. |
9 | * | 9 | * |
10 | * This program is distributed in the hope that it will be useful, | 10 | * This program is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. | 13 | * GNU General Public License for more details. |
14 | * | 14 | * |
15 | * You should have received a copy of the GNU General Public License | 15 | * You should have received a copy of the GNU General Public License |
16 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | * | 18 | * |
19 | * $Id$ | 19 | * $Id$ |
20 | */ | 20 | */ |
21 | 21 | ||
22 | # ifdef HAVE_CONFIG_H | 22 | # ifdef HAVE_CONFIG_H |
23 | # include "libmad_config.h" | 23 | # include "libmad_config.h" |
24 | # endif | 24 | # endif |
25 | 25 | ||
26 | # include "libmad_global.h" | 26 | # include "libmad_global.h" |
@@ -176,45 +176,62 @@ unsigned long mad_bit_read(struct mad_bitptr *bitptr, unsigned int len) | |||
176 | 176 | ||
177 | # if 0 | 177 | # if 0 |
178 | /* | 178 | /* |
179 | * NAME:bit->write() | 179 | * NAME:bit->write() |
180 | * DESCRIPTION:write an arbitrary number of bits | 180 | * DESCRIPTION:write an arbitrary number of bits |
181 | */ | 181 | */ |
182 | void mad_bit_write(struct mad_bitptr *bitptr, unsigned int len, | 182 | void mad_bit_write(struct mad_bitptr *bitptr, unsigned int len, |
183 | unsigned long value) | 183 | unsigned long value) |
184 | { | 184 | { |
185 | unsigned char *ptr; | 185 | unsigned char *ptr; |
186 | 186 | ||
187 | ptr = (unsigned char *) bitptr->byte; | 187 | ptr = (unsigned char *) bitptr->byte; |
188 | 188 | ||
189 | /* ... */ | 189 | /* ... */ |
190 | } | 190 | } |
191 | # endif | 191 | # endif |
192 | 192 | ||
193 | /* | 193 | /* |
194 | * NAME:bit->crc() | 194 | * NAME:bit->crc() |
195 | * DESCRIPTION:compute CRC-check word | 195 | * DESCRIPTION:compute CRC-check word |
196 | */ | 196 | */ |
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 | ||
219 | return crc & 0xffff; | 236 | return crc & 0xffff; |
220 | } | 237 | } |