diff options
author | Marcin Bukat <marcin.bukat@gmail.com> | 2010-10-31 12:40:49 +0000 |
---|---|---|
committer | Marcin Bukat <marcin.bukat@gmail.com> | 2010-10-31 12:40:49 +0000 |
commit | e26d0c62e07d1b1c1087a065242ed7ab1a2c522f (patch) | |
tree | b1e27ee113a94784233ca7aaf5b9d670f303b332 /apps/plugins/imageviewer/png/crc32.c | |
parent | c8901b3506ffb2f18798b005552c61b92b9d6a6c (diff) | |
download | rockbox-e26d0c62e07d1b1c1087a065242ed7ab1a2c522f.tar.gz rockbox-e26d0c62e07d1b1c1087a065242ed7ab1a2c522f.zip |
Fix and extend imageviewer png support. FS#11641 by me
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28413 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/imageviewer/png/crc32.c')
-rw-r--r-- | apps/plugins/imageviewer/png/crc32.c | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/apps/plugins/imageviewer/png/crc32.c b/apps/plugins/imageviewer/png/crc32.c new file mode 100644 index 0000000000..c7921a028b --- /dev/null +++ b/apps/plugins/imageviewer/png/crc32.c | |||
@@ -0,0 +1,89 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Original source: | ||
11 | * Copyright (c) 2003 by Joergen Ibsen / Jibz | ||
12 | * | ||
13 | * Rockbox adaptation: | ||
14 | * Copyright (c) 2010 by Marcin Bukat | ||
15 | * | ||
16 | * This program is free software; you can redistribute it and/or | ||
17 | * modify it under the terms of the GNU General Public License | ||
18 | * as published by the Free Software Foundation; either version 2 | ||
19 | * of the License, or (at your option) any later version. | ||
20 | * | ||
21 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
22 | * KIND, either express or implied. | ||
23 | * | ||
24 | ****************************************************************************/ | ||
25 | |||
26 | /* | ||
27 | * CRC32 checksum | ||
28 | * | ||
29 | * Copyright (c) 1998-2003 by Joergen Ibsen / Jibz | ||
30 | * All Rights Reserved | ||
31 | * | ||
32 | * http://www.ibsensoftware.com/ | ||
33 | * | ||
34 | * This software is provided 'as-is', without any express | ||
35 | * or implied warranty. In no event will the authors be | ||
36 | * held liable for any damages arising from the use of | ||
37 | * this software. | ||
38 | * | ||
39 | * Permission is granted to anyone to use this software | ||
40 | * for any purpose, including commercial applications, | ||
41 | * and to alter it and redistribute it freely, subject to | ||
42 | * the following restrictions: | ||
43 | * | ||
44 | * 1. The origin of this software must not be | ||
45 | * misrepresented; you must not claim that you | ||
46 | * wrote the original software. If you use this | ||
47 | * software in a product, an acknowledgment in | ||
48 | * the product documentation would be appreciated | ||
49 | * but is not required. | ||
50 | * | ||
51 | * 2. Altered source versions must be plainly marked | ||
52 | * as such, and must not be misrepresented as | ||
53 | * being the original software. | ||
54 | * | ||
55 | * 3. This notice may not be removed or altered from | ||
56 | * any source distribution. | ||
57 | */ | ||
58 | |||
59 | /* | ||
60 | * CRC32 algorithm taken from the zlib source, which is | ||
61 | * Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler | ||
62 | */ | ||
63 | |||
64 | #include "tinf.h" | ||
65 | |||
66 | static const unsigned int tinf_crc32tab[16] = { | ||
67 | 0x00000000, 0x1db71064, 0x3b6e20c8, 0x26d930ac, 0x76dc4190, | ||
68 | 0x6b6b51f4, 0x4db26158, 0x5005713c, 0xedb88320, 0xf00f9344, | ||
69 | 0xd6d6a3e8, 0xcb61b38c, 0x9b64c2b0, 0x86d3d2d4, 0xa00ae278, | ||
70 | 0xbdbdf21c | ||
71 | }; | ||
72 | |||
73 | unsigned int tinf_crc32(const void *data, unsigned int length) | ||
74 | { | ||
75 | const unsigned char *buf = (const unsigned char *)data; | ||
76 | unsigned int crc = 0xffffffff; | ||
77 | unsigned int i; | ||
78 | |||
79 | if (length == 0) return 0; | ||
80 | |||
81 | for (i = 0; i < length; ++i) | ||
82 | { | ||
83 | crc ^= buf[i]; | ||
84 | crc = tinf_crc32tab[crc & 0x0f] ^ (crc >> 4); | ||
85 | crc = tinf_crc32tab[crc & 0x0f] ^ (crc >> 4); | ||
86 | } | ||
87 | |||
88 | return crc ^ 0xffffffff; | ||
89 | } | ||