Help - Search - Members - Calendar
Full Version: how does eac compute the crc sum?
Hydrogenaudio Forums > CD-R and Audio Hardware > CD Hardware/Software
TCM
hi,

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
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.

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?
kjoonlee
Have you tried switching algorithms with the -a option?
TCM
QUOTE(kjoonlee @ Nov 24 2005, 04:27 AM)
Have you tried switching algorithms with the -a option?
*

actually no, since crc is the only algorithm that yields a 32bit value. the historical algorithms old1 and old2 both give shorter values and the remaining hashes give values from 128bit onward.

edit: additionally, i thought the term crc referred to a specific method of calculation, i.e. one computes "the" crc value, not "a" crc value.
kjoonlee
Oh. Why don't you ask Andre himself at the EAC forums? smile.gif
TCM
QUOTE(kjoonlee @ Nov 24 2005, 04:33 AM)
Oh. Why don't you ask Andre himself at the EAC forums? smile.gif
*

i just did. i wasn't aware of an eac forum and you can post without registering, nice. smile.gif

edit: and it's solved. crc seems to be != crc32. the cksum utility in freebsd includes on more historical algorithm than netbsd's does. using this algorithm i get matching values.

edit2: makes you wish everyone would use standardized algorithms like md5. but now that i can reproduce it, it's not too bad.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.