mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-08 12:45:26 -05:00
Performance optimizations for tagcache commit. Still more left to be done.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9721 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
2b18727a8a
commit
fa893c6b88
5 changed files with 282 additions and 126 deletions
57
firmware/common/crc32.c
Normal file
57
firmware/common/crc32.c
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2003 Jörg Hohensohn [IDC]Dragon
|
||||
*
|
||||
* All files in this archive are subject to the GNU General Public License.
|
||||
* See the file COPYING in the source tree root for full license agreement.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/* Code copied from firmware_flash plugin. */
|
||||
|
||||
/* Tool function to calculate a CRC32 across some buffer */
|
||||
/* third argument is either 0xFFFFFFFF to start or value from last piece */
|
||||
unsigned crc_32(unsigned char* buf, unsigned len, unsigned crc32)
|
||||
{
|
||||
/* CCITT standard polynomial 0x04C11DB7 */
|
||||
static const unsigned crc32_lookup[16] =
|
||||
{ /* lookup table for 4 bits at a time is affordable */
|
||||
0x00000000, 0x04C11DB7, 0x09823B6E, 0x0D4326D9,
|
||||
0x130476DC, 0x17C56B6B, 0x1A864DB2, 0x1E475005,
|
||||
0x2608EDB8, 0x22C9F00F, 0x2F8AD6D6, 0x2B4BCB61,
|
||||
0x350C9B64, 0x31CD86D3, 0x3C8EA00A, 0x384FBDBD
|
||||
};
|
||||
|
||||
unsigned char byte;
|
||||
unsigned t;
|
||||
|
||||
while (len--)
|
||||
{
|
||||
byte = *buf++; /* get one byte of data */
|
||||
|
||||
/* upper nibble of our data */
|
||||
t = crc32 >> 28; /* extract the 4 most significant bits */
|
||||
t ^= byte >> 4; /* XOR in 4 bits of data into the extracted bits */
|
||||
crc32 <<= 4; /* shift the CRC register left 4 bits */
|
||||
crc32 ^= crc32_lookup[t]; /* do the table lookup and XOR the result */
|
||||
|
||||
/* lower nibble of our data */
|
||||
t = crc32 >> 28; /* extract the 4 most significant bits */
|
||||
t ^= byte & 0x0F; /* XOR in 4 bits of data into the extracted bits */
|
||||
crc32 <<= 4; /* shift the CRC register left 4 bits */
|
||||
crc32 ^= crc32_lookup[t]; /* do the table lookup and XOR the result */
|
||||
}
|
||||
|
||||
return crc32;
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue