Annotation of margi2/crc.h, revision 1.1.1.1
1.1 cvs 1: /*
2: crc.h
3:
4: Copyright (C) Christian Wolff for convergence integrated media.
5:
6: This program is free software; you can redistribute it and/or modify
7: it under the terms of the GNU General Public License as published by
8: the Free Software Foundation; either version 2 of the License, or
9: (at your option) any later version.
10:
11: This program is distributed in the hope that it will be useful,
12: but WITHOUT ANY WARRANTY; without even the implied warranty of
13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14: GNU General Public License for more details.
15:
16: You should have received a copy of the GNU General Public License
17: along with this program; if not, write to the Free Software
18: Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19: */
20:
21: /*---------------------------------------------------------
22:
23: Cyclic Redundancy Check 16 and 32 Bit - Header File
24:
25: Christian Wolff, 19990122
26:
27: ---------------------------------------------------------*/
28:
29: #ifndef _CRC_H_
30: #define _CRC_H_
31:
32: // 16 Bit CCITT standard polynomial x^16 + x^12 + x^5 + x^1 + x^0
33: #define POLYNOMIAL_16 0x1021
34: // 32 Bit standard polynomial x^32 + x^26 + x^23 + x^22 + x^16 +
35: // x^12 + x^11 + x^10 + x^8 + x^7 + x^5 + x^4 + x^2 + x^1 + x^0
36: #define POLYNOMIAL_32 0x04C11DB7L
37:
38: #define CRC_INIT_16 0xFFFF
39: #define CRC_INIT_32 0xFFFFFFFFL
40:
41: #define update_crc_16(crc, data) ((crc << 8) ^ crc_16_table[((int)(crc >> 8 ) ^ (data)) & 0xFF])
42: #define update_crc_32(crc, data) ((crc << 8) ^ crc_32_table[((int)(crc >> 24) ^ (data)) & 0xFF])
43:
44: extern unsigned short crc_16_table[256];
45: extern unsigned long crc_32_table[256];
46:
47: extern void gen_crc_table(void);
48:
49: extern unsigned short update_crc_16_block(unsigned short crc,
50: char *data_block_ptr,
51: int data_block_size);
52: extern unsigned long update_crc_32_block(unsigned long crc,
53: char *data_block_ptr,
54: int data_block_size);
55:
56: #endif
LinuxTV legacy CVS <linuxtv.org/cvs>