add CRC-16 code, more methods

This commit is contained in:
Josh Coalson
2001-03-27 01:14:25 +00:00
parent 1e1509fb35
commit 6351ef6c1e
2 changed files with 129 additions and 42 deletions

View File

@@ -23,8 +23,23 @@
#include "FLAC/ordinals.h"
/* 8 bit CRC generator, MSB shifted first
** polynomial = x^8 + x^2 + x^1 + 1
** polynomial = x^8 + x^2 + x^1 + x^0
** init = 0
*/
byte FLAC__crc8(const byte *data, const unsigned len);
extern byte const FLAC__crc8_table[256];
#define FLAC__CRC8_UPDATE(data, crc) crc = FLAC__crc8_table[crc ^ data];
void FLAC__crc8_update(const byte data, uint8 *crc);
void FLAC__crc8_update_block(const byte *data, unsigned len, uint8 *crc);
uint8 FLAC__crc8(const byte *data, unsigned len);
/* 16 bit CRC generator, MSB shifted first
** polynomial = x^16 + x^15 + x^2 + x^0
** init = 0
*/
extern uint16 FLAC__crc16_table[256];
#define FLAC__CRC16_UPDATE(data, crc) crc = (crc<<8) ^ FLAC__crc16_table[(crc>>8) ^ data];
void FLAC__crc16_update(const byte data, uint16 *crc);
void FLAC__crc16_update_block(const byte *data, unsigned len, uint16 *crc);
uint16 FLAC__crc16(const byte *data, unsigned len);
#endif