Copyright | (c) 2018-2021 Sam May |
---|---|
License | GPL-3.0-or-later |
Maintainer | ag@eitilt.life |
Stability | stable |
Portability | non-portable (requires libcdio) |
Safe Haskell | None |
Language | Haskell2010 |
The bulk of this module deals with the sizes of various parts of disc sectors,
and so a brief description of each is likely helpful; for more information, see
the libcdio user guide, or any of the other various documentation that people
have written. Depending on the accuracy required, multiple methods of encoding
data onto discs were developed enabling different degrees of error detection
and recovery. For ease of implementation, these check regions are spaced
evenly throughout the data, effectively dividing it into blocks of sectorSize
bytes. The inner structure of each block is thus:
Sector layout
Audio
As audio CDs are intended to be listened to by human ears, often in noisy environments, byte-perfect fidelity was deemed unnecessary; data fills the entire sector without leaving room for checksums or synchronization points. This structure is more technically described as "CD-DA" (Digital Audio).
|- sectorSize
-|
Data (Mode 1)
The original structure described in the Yellow Book standard. Mode 1, Form 1 is notably the layout used for CD-ROMs. It would be most correct to describe these as "Mode 1" and "Mode 2" with no reference to form, but the libcdio documentation has adopted the practice below as a parallel to the XA names.
Mode 1, Form 1
|------------------------------------sectorSize
-------------------------------------|syncSize
+headerSize
+dataSize
+errorDetectionSize
+padSize
+errorCorrectionSize
|-------------------------------syncedSize
-------------------------------| |--------------------tailSize
--------------------|
Mode 1, Form 2
|------------sectorSize
-----------|syncSize
+headerSize
+dataSizeRaw
|------syncedSize
------|
XA (Mode 2)
Developed as a later extension to the Mode 1, Form 2 (technically just "Mode 2") standard above to allow different data to be interleaved.
Mode 2, Form 1
|---------------------------------------sectorSize
----------------------------------------|syncSize
+headerSize
+subheaderSize
+dataSize
+errorDetectionSize
+errorCorrectionSize
|----------syncHeaderSizeXa
---------| |--------------tailSizeXa
--------------| |------headerSizeXa
------| |----------------------------------syncedSize
----------------------------------| |---------------------------dataSizeRaw
---------------------------|
Mode 2, Form 2
|---------------------------sectorSize
--------------------------|syncSize
+headerSize
+subheaderSize
+dataSizeRawXa
+padSizeXa
|----------syncHeaderSizeXa
---------| |------headerSizeXa
------| |---------------------syncedSize
---------------------| |--------------dataSizeRaw
--------------| |-----taggedDataSizeRaw
-----|
sector.h
Defines
CDIO_CD_CHUNK_SIZE
->chunkSize
CDIO_CD_ECC_SIZE
->errorCorrectionSize
CDIO_CD_EDC_SIZE
->errorDetectionSize
CDIO_CD_FRAMESIZE
->dataSize
CDIO_CD_FRAMESIZE_RAW
->sectorSize
CDIO_CD_FRAMESIZE_RAW0
->dataSizeRaw
CDIO_CD_FRAMESIZE_RAW1
->syncedSize
CDIO_CD_FRAMESIZE_RAWER
->sectorSizeMax
CDIO_CD_FRAMESIZE_SUB
->framesizeSub
CDIO_CD_FRAMES_PER_MIN
->framesPerMin
CDIO_CD_FRAMES_PER_SEC
->framesPerSec
CDIO_CD_HEADER_SIZE
->headerSize
CDIO_CD_M1F1_ZERO_SIZE
->padSize
CDIO_CD_MAX_LSN
(removed; identical to
)maxBound
::Lsn
CDIO_CD_MAX_SESSIONS
->maxSessions
CDIO_CD_MINS
->cdMins
CDIO_CD_MIN_LSN
(removed; identical to
)minBound
::Lsn
CDIO_CD_MIN_SESSION_NO
->minSessionNo
CDIO_CD_NUM_OF_CHUNKS
->chunksPerSector
CDIO_CD_SECS_PER_MIN
->secsPerMin
CDIO_CD_SUBHEADER_SIZE
->subheaderSize
CDIO_CD_SYNC_SIZE
->syncSize
CDIO_CD_XA_HEADER
->headerSizeXa
CDIO_CD_XA_SYNC_HEADER
->syncHeaderSizeXa
CDIO_CD_XA_TAIL
->tailSizeXa
CDIO_POSTGAP_SECTORS
->postgapSectors
CDIO_PREGAP_SECTORS
->pregapSectors
M2F2_SECTOR_SIZE
->dataSizeRawXa
M2RAW_SECTOR_SIZE
(removed; identical todataSizeRaw
)M2SUB_SECTOR_SIZE
->taggedDataSizeRaw
msf_t_SIZEOF
(removed; structural constant not required for Haskell)
Types
cdio_cd_minutes_sectors
(removed; most values were simple calculations onCDIO_CD_FRAMES_PER_MIN
, which can be done manually)CDIO_CD_MAX_SECTORS
->maxSectors
cdio_subchannel
->SubchannelData
CDIO_SUBCHANNEL_SUBQ_DATA
->QChannelData
SCMS
->SerialCopyManagement
Symbols
CDIO_SECTOR_SYNC_HEADER
->sectorSyncHeader
cdio_lba_to_lsn
->lbaToLsn
cdio_lba_to_msf
->lbaToMsf
cdio_lba_to_msf_str
->lbaToMsfStr
cdio_lsn_to_lba
->lsnToLba
cdio_lsn_to_msf
->lsnToMsf
cdio_msf_to_lba
->msfToLba
cdio_msf_to_lsn
->msfToLsn
cdio_msf_to_str
->msfToStr
Sound.Libcdio.Read.Data
Flag
(currently removed; unused in the translated portion of the interface)Flags
(currently removed; unused in the translated portion of the interface)Lba
(removed; only one address format is needed, andLsn
is more widespread)Msf
(removed; only one address format is needed, and timestamps can be confusing for non-audio data)SubchannelData
(currently removed; unused in the translated portion of the interface)cdMins
->maxCdMinutes
chunkSize
(removed; unnecessary low-level detail)chunksPerSector
(removed; unnecessary low-level detail)framesizeSub
(removed; unnecessary low-level detail)lbaToLsn
(removed; onlyLsn
is used inSound
)lbaToMsf
(removed; onlyLsn
is used inSound
)lbaToMsfStr
->audioTimestamp
lsnToLba
(removed; onlyLsn
is used inSound
)lsnToMsf
(removed; onlyLsn
is used inSound
)maxSectors
->maxSectors
maxSessions
(removed; explicit session handling not yet implemented by libcdio)minSessionNo
(removed; explicit session handling not yet implemented by libcdio)msfToLba
(removed; onlyLsn
is used inSound
)msfToLsn
(removed; onlyLsn
is used inSound
)msfToStr
(removed; onlyLsn
is used inSound
)postgapSectors
->defaultPostgapSectors
pregapSectors
->defaultPregapSectors
secsPerMin
(removed; real-world constant)sectorSyncHeader
(removed; unnecessary low-level detail)framesPerMin
(removed; simple arithmatic offramesPerSec
All size constants (e.g. sectorSize
) likewise removed as unnecessary.
Synopsis
- data SubchannelData
- type Flags = BitArray Flag
- data Flag
- data Lba
- data Lsn
- data Msf = Msf {}
- lbaToLsn :: Lba -> Lsn
- lsnToLba :: Lsn -> Lba
- lbaToMsf :: Lba -> Msf
- msfToLba :: Msf -> Lba
- lsnToMsf :: Lsn -> Msf
- msfToLsn :: Msf -> Lsn
- lbaToMsfStr :: Lba -> String
- msfToStr :: Msf -> String
- chunkSize :: Word
- minSessionNo :: Word
- maxSessions :: Word
- pregapSectors :: Word
- postgapSectors :: Word
- maxSectors :: Word
- framesizeSub :: Word
- chunksPerSector :: Word
- framesPerSec :: Word
- secsPerMin :: Word
- framesPerMin :: Word
- cdMins :: Word
- sectorSize :: Word
- syncedSize :: Word
- sectorSizeMax :: Word
- sectorSyncHeader :: ByteString
- syncSize :: Word
- headerSize :: Word
- subheaderSize :: Word
- headerSizeXa :: Word
- syncHeaderSizeXa :: Word
- dataSize :: Word
- dataSizeRaw :: Word
- dataSizeRawXa :: Word
- taggedDataSizeRaw :: Word
- errorDetectionSize :: Word
- errorCorrectionSize :: Word
- padSize :: Word
- padSizeXa :: Word
- tailSize :: Word
- tailSizeXa :: Word
Types
data SubchannelData Source #
Types of information stored on disc subchannels.
Instances
Metadata describing the layout or type of data on a track.
The type-safe representation of a Logical Block Address, counting sectors
from the very beginning of the write session. See also Lsn
.
Instances
Bounded Lba Source # | |
Enum Lba Source # | |
Eq Lba Source # | |
Integral Lba Source # | |
Num Lba Source # | |
Ord Lba Source # | |
Read Lba Source # | |
Real Lba Source # | |
Defined in Foreign.Libcdio.Types.Internal toRational :: Lba -> Rational # | |
Show Lba Source # | |
Ix Lba Source # | |
PrintfArg Lba Source # | |
Defined in Foreign.Libcdio.Types.Internal formatArg :: Lba -> FieldFormatter # parseFormat :: Lba -> ModifierParser # | |
Storable Lba Source # | |
Defined in Foreign.Libcdio.Types.Internal | |
Bits Lba Source # | |
Defined in Foreign.Libcdio.Types.Internal | |
FiniteBits Lba Source # | |
Defined in Foreign.Libcdio.Types.Internal |
The type-safe representation of a Logical Sector Number, counting sectors
from the start of track 1; this notably excludes the blank session lead-in.
See also Lba
.
Instances
Bounded Lsn Source # | |
Enum Lsn Source # | |
Eq Lsn Source # | |
Integral Lsn Source # | |
Num Lsn Source # | |
Ord Lsn Source # | |
Read Lsn Source # | |
Real Lsn Source # | |
Defined in Foreign.Libcdio.Types.Internal toRational :: Lsn -> Rational # | |
Show Lsn Source # | |
Ix Lsn Source # | |
PrintfArg Lsn Source # | |
Defined in Foreign.Libcdio.Types.Internal formatArg :: Lsn -> FieldFormatter # parseFormat :: Lsn -> ModifierParser # | |
Storable Lsn Source # | |
Defined in Foreign.Libcdio.Types.Internal | |
Bits Lsn Source # | |
Defined in Foreign.Libcdio.Types.Internal | |
FiniteBits Lsn Source # | |
Defined in Foreign.Libcdio.Types.Internal |
Minute/second/frame structure for addresses. Generally only makes sense for audio discs.
Conversions
lbaToMsf :: Lba -> Msf Source #
Convert an LBA address into the corresponding timestamp, assuming audio data.
msfToLba :: Msf -> Lba Source #
Convert a timestamp into the corresponding LBA address, assuming audio data.
lsnToMsf :: Lsn -> Msf Source #
Convert an LSN address into the corresponding timestamp, assuming audio data.
msfToLsn :: Msf -> Lsn Source #
Convert a timestamp into the corresponding LSN address, assuming audio data.
lbaToMsfStr :: Lba -> String Source #
Print a logical address as the corresponding timestamp, assuming audio data.
Basic counts
minSessionNo :: Word Source #
The smallest session number on a disc.
maxSessions :: Word Source #
How many sessions are allowed on a disc.
pregapSectors :: Word Source #
The number of sectors spanned by a track pre-gap by default.
postgapSectors :: Word Source #
The number of sectors spanned by a track post-gap by default.
maxSectors :: Word Source #
The maximum number of sectors allowed to be stored on a disc.
framesizeSub :: Word Source #
The size of a segment of data in the subchannel, in bytes.
Units of time
chunksPerSector :: Word Source #
The number of data chunks comprising a disc sector.
framesPerSec :: Word Source #
The number of disc sectors comprising a second of audio data.
secsPerMin :: Word Source #
The number of seconds in a minute.
framesPerMin :: Word Source #
A shortcut for calculating framesPerSec
* secsPerMin
Sector blocks
sectorSize :: Word Source #
The size of an entire disc sector, in bytes.
syncedSize :: Word Source #
The size of a disc sector in bytes, ignoring the sync header.
sectorSizeMax :: Word Source #
The maximum number of bytes that may be returned from a single call.
Headers
sectorSyncHeader :: ByteString Source #
The byte sequence used to mark the start of a disc sector, to allow correcting drift while reading.
headerSize :: Word Source #
The size of the address of a data sector, in bytes.
subheaderSize :: Word Source #
The size of the subheader of an XA sector, in bytes.
headerSizeXa :: Word Source #
The total size of the meaningful XA sector headers, in bytes.
syncHeaderSizeXa :: Word Source #
The total size of all headers in an XA sector, including the sync marker.
Data
The amount of data which may be contained in a disc sector with error correction, in bytes.
dataSizeRaw :: Word Source #
The amount of data which may be contained in a disc sector without error correction, in bytes.
dataSizeRawXa :: Word Source #
The amount of data contained in an XA sector without error correction, in bytes.
taggedDataSizeRaw :: Word Source #
The size of tagged data (counting the subheader) contained in an XA sector without error correction, in bytes.
Error correction
errorDetectionSize :: Word Source #
The size of the EDC error correction segment, in bytes.
errorCorrectionSize :: Word Source #
The size of the ECC error correction segment, in bytes.
The amount of padding between the EDC and ECC segments in a Mode 1 sector, in bytes.
The amount of padding at the end of an XA sector without error correction, in bytes.
tailSizeXa :: Word Source #
The total size of all XA sector error correction segments, in bytes.