Crate cdrom_crc[][src]

This module contains functions for calculating CRCs as defined in the CD-DA and CD-ROM standards.

The CD standards use CRCs (cyclic redundancy checks) as a way to allow a player to check for corruption of low-level metadata. Since CDs are a physical medium that can suffer from scratches, dust, and other damage, it's important to be able to know that playback metadata is actually accurate before trying to read it.

The CD-DA and CD-ROM standards use two types of CRC functions in different parts of each sector:

  1. A 32-bit CRC within the error correction metadata located within each sector.
  2. A 16-bit CRC within the second subcode.

This crate currently only provides the 16-bit CRC.

This crate incorporates an adaptation of a CRC function from the Ruby crc gem by dearblue.

Constants

CRC16_BITMASK
CRC16_BITSIZE
CRC16_INITIAL_CRC
CRC16_POLYNOMIAL
CRC16_REFLECT_INPUT
CRC16_REFLECT_OUTPUT
CRC16_XOR_OUTPUT

Functions

crc16

Calculates a 16-bit CRC for the supplied data. This is the form of CRC used by the CD standard's Q subcode data. initial_crc is an initial CRC value which will be updated as calculations are performed; for Q subcode data, use the value of the CRC16_INITIAL_CRC constant.