Howdy,
> I'd like to know where to find some sources or specifications
> on the CRC used
> on MP3 frames. I know I could get it in the lame sources, but
> I'd like to know
> first if it's fully compliant !
The polynomial used for CRC on all layers of MPEG audio is given on p.30 of
ISO/IEC 11172-3:
If the protection bit in the header equals '0', a CRC-check word
has been inserted in the bitstream just after the header. The error
detection method used is 'CRC-16' whose generator polynomial is:
G(X) = X^16 + X^15 + X^2 + 1
The bits included into the CRC-check are given by table B.5.
Figure A.9 on p.44 (CRC-check diagram) also represents this polynomial
graphically.
Here's my code for the polynomial part:
#define CRC16_POLYNOMIAL 0x8005
// Pass length (<32) bits of data through the CRC-16 polynomial with initial
state crc
static void CRC_poly(unsigned data, unsigned char length, unsigned short
*crc)
{
bool carry,data_bit;
unsigned mask;
mask = 1<<length;
while(mask >>= 1) {
data_bit = (data & mask)!=0; // mask off data bit and convert to
boolean
carry = (*crc & 0x8000)!=0; // mask off carry bit and convert to
boolean
*crc <<= 1; // shift in LSB
if(carry^data_bit) // if not, we'd be XOR'ing with 0...
*crc ^= CRC16_POLYNOMIAL;
}
}
My code is derived from the ISO 'dist10' source.
Hope that helps,
Alex
--
MP3 ENCODER mailing list ( http://geek.rcc.se/mp3encoder/ )