i've been trying to reproduce eac's crc calculation with an external program.
i have setup eac to include silence in tracks in its crc calculation. i ripped the second track of a disc to a wav file. as expected, eac showed identical crc values for test + copy.
then i tried to get the same crc value using the wav file as input. i fed the wav file into sox (http://sox.sourceforge.net/), converting it into a raw file on-the-fly and piping it into netbsd's cksum(1) utility, whose man page (http://netbsd.gw.com/cgi-bin/man-cgi?cksum++NetBSD-current) says:
CODE
-a algorithm
When invoked as cksum, use the specified algorithm. Valid algo-
rithms are MD2, MD4, MD5, SHA1, RMD160, SHA256, SHA384, SHA512,
CRC, old1, and old2. Old1 and old2 are equal to -o 1 and -o 2,
respectively. The default is CRC.
and When invoked as cksum, use the specified algorithm. Valid algo-
rithms are MD2, MD4, MD5, SHA1, RMD160, SHA256, SHA384, SHA512,
CRC, old1, and old2. Old1 and old2 are equal to -o 1 and -o 2,
respectively. The default is CRC.
CODE
The default CRC used is based on the polynomial used for CRC error check-
ing in the networking standard ISO/IEC 8802-3:1989. The CRC checksum
encoding is defined by the generating polynomial:
G(x) = x^32 + x^26 + x^23 + x^22 + x^16 + x^12 +
x^11 + x^10 + x^8 + x^7 + x^5 + x^4 + x^2 + x + 1
Mathematically, the CRC value corresponding to a given file is defined by
the following procedure:
The n bits to be evaluated are considered to be the coefficients of
a mod 2 polynomial M(x) of degree n-1. These n bits are the bits
from the file, with the most significant bit being the most signif-
icant bit of the first octet of the file and the last bit being the
least significant bit of the last octet, padded with zero bits (if
necessary) to achieve an integral number of octets, followed by one
or more octets representing the length of the file as a binary
value, least significant octet first. The smallest number of
octets capable of representing this integer are used.
M(x) is multiplied by x^32 (i.e., shifted left 32 bits) and divided
by G(x) using mod 2 division, producing a remainder R(x) of degree
<= 31.
The coefficients of R(x) are considered to be a 32-bit sequence.
The bit sequence is complemented and the result is the CRC.
since the value is printed in decimal, i feed it into bc(1) to convert it into hexadecimal.ing in the networking standard ISO/IEC 8802-3:1989. The CRC checksum
encoding is defined by the generating polynomial:
G(x) = x^32 + x^26 + x^23 + x^22 + x^16 + x^12 +
x^11 + x^10 + x^8 + x^7 + x^5 + x^4 + x^2 + x + 1
Mathematically, the CRC value corresponding to a given file is defined by
the following procedure:
The n bits to be evaluated are considered to be the coefficients of
a mod 2 polynomial M(x) of degree n-1. These n bits are the bits
from the file, with the most significant bit being the most signif-
icant bit of the first octet of the file and the last bit being the
least significant bit of the last octet, padded with zero bits (if
necessary) to achieve an integral number of octets, followed by one
or more octets representing the length of the file as a binary
value, least significant octet first. The smallest number of
octets capable of representing this integer are used.
M(x) is multiplied by x^32 (i.e., shifted left 32 bits) and divided
by G(x) using mod 2 division, producing a remainder R(x) of degree
<= 31.
The coefficients of R(x) are considered to be a 32-bit sequence.
The bit sequence is complemented and the result is the CRC.
thus, my whole command line looks like:
CODE
sox Track02.wav -t raw - | cksum | read sum size; echo "obase=16; ${sum}" | bc
however, i have not been able to reproduce the crc value that eac gives. i have tried different modi of output (big/little-endian, signed/unsigned) but each time i get a crc that's different from eac's.
what am i doing wrong?
