26 #if CONFIG_HARDCODED_TABLES
64 if (bits < 8 || bits > 32 || poly >= (1LL << bits))
66 if (ctx_size !=
sizeof(
AVCRC) * 257 && ctx_size !=
sizeof(
AVCRC) * 1024)
69 for (i = 0; i < 256; i++) {
71 for (c = i, j = 0; j < 8; j++)
72 c = (c >> 1) ^ (poly & (-(c & 1)));
75 for (c = i << 24, j = 0; j < 8; j++)
76 c = (c << 1) ^ ((poly << (32 -
bits)) & (((int32_t) c) >> 31));
82 if (ctx_size >=
sizeof(
AVCRC) * 1024)
83 for (i = 0; i < 256; i++)
84 for (j = 0; j < 3; j++)
85 ctx[256 *(j + 1) + i] =
86 (ctx[256 * j + i] >> 8) ^ ctx[ctx[256 * j + i] & 0xFF];
99 #if !CONFIG_HARDCODED_TABLES
119 const uint8_t *
buffer,
size_t length)
121 const uint8_t *end = buffer + length;
125 while (((intptr_t) buffer & 3) && buffer < end)
126 crc = ctx[((uint8_t) crc) ^ *buffer++] ^ (crc >> 8);
128 while (buffer < end - 3) {
129 crc ^=
av_le2ne32(*(
const uint32_t *) buffer); buffer += 4;
130 crc = ctx[3 * 256 + ( crc & 0xFF)] ^
131 ctx[2 * 256 + ((crc >> 8 ) & 0xFF)] ^
132 ctx[1 * 256 + ((crc >> 16) & 0xFF)] ^
133 ctx[0 * 256 + ((crc >> 24) )];
138 crc = ctx[((uint8_t) crc) ^ *buffer++] ^ (crc >> 8);
156 for (i = 0; i <
sizeof(buf); i++)
159 for (i = 0; i < 4; i++) {
161 printf(
"crc %08X = %X\n", p[i][1],
av_crc(ctx, 0, buf,
sizeof(buf)));