26 #if CONFIG_HARDCODED_TABLES
48 if (bits < 8 || bits > 32 || poly >= (1LL << bits))
50 if (ctx_size !=
sizeof(
AVCRC) * 257 && ctx_size !=
sizeof(
AVCRC) * 1024)
53 for (i = 0; i < 256; i++) {
55 for (c = i, j = 0; j < 8; j++)
56 c = (c >> 1) ^ (poly & (-(c & 1)));
59 for (c = i << 24, j = 0; j < 8; j++)
60 c = (c << 1) ^ ((poly << (32 -
bits)) & (((
int32_t) c) >> 31));
66 if (ctx_size >=
sizeof(
AVCRC) * 1024)
67 for (i = 0; i < 256; i++)
68 for (j = 0; j < 3; j++)
69 ctx[256 *(j + 1) + i] =
70 (ctx[256 * j + i] >> 8) ^ ctx[ctx[256 * j + i] & 0xFF];
78 #if !CONFIG_HARDCODED_TABLES
93 const uint8_t *end = buffer + length;
97 while (((intptr_t) buffer & 3) && buffer < end)
98 crc = ctx[((
uint8_t) crc) ^ *buffer++] ^ (crc >> 8);
100 while (buffer < end - 3) {
101 crc ^=
av_le2ne32(*(
const uint32_t *) buffer); buffer += 4;
102 crc = ctx[3 * 256 + ( crc & 0xFF)] ^
103 ctx[2 * 256 + ((crc >> 8 ) & 0xFF)] ^
104 ctx[1 * 256 + ((crc >> 16) & 0xFF)] ^
105 ctx[0 * 256 + ((crc >> 24) )];
110 crc = ctx[((
uint8_t) crc) ^ *buffer++] ^ (crc >> 8);
127 for (i = 0; i <
sizeof(buf); i++)
130 for (i = 0; i < 4; i++) {
132 printf(
"crc %08X = %X\n", p[i][1],
av_crc(ctx, 0, buf,
sizeof(buf)));
uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length)
Calculate the CRC of a block.
int av_crc_init(AVCRC *ctx, int le, int bits, uint32_t poly, int ctx_size)
Initialize a CRC table.
static struct @107 av_crc_table_params[AV_CRC_MAX]
const AVCRC * av_crc_get_table(AVCRCId crc_id)
Get an initialized standard CRC table.
static AVCRC av_crc_table[AV_CRC_MAX][257]
int main(int argc, char **argv)
#define FF_ARRAY_ELEMS(a)
common internal and external API header