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
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)));