In order to get the total disk capacity you need to multiply the number of sectors by the length of the user data field on each sector(which on CD-ROM/XA (eXtended Architecture) Mode 2 would be 2336 bytes instead of 2048)
A sector on a CD-ROM holds 2048 bytes of user data, leaving 304 bytes for other purposes. Every data sector begins with a 16-byte header:
- 12-byte sync field (00 ff ff ff ff ff ff ff ff ff ff 00)
- 3 byte address (minute, second, fraction (1/75th) of a second)
- 1 byte mode
The mode byte determines what the remaining 2336 bytes in the sector looks like:
- Mode 0: null data; serves no practical purpose for CD recording
- Mode 1: the typical CD-ROM layout
2048 bytes of user data
4 bytes of EDC (Error Detection Code, a 32-bit CRC)
8 bytes of reserved space, set to zeros
172 bytes of "P" parity
104 bytes of "Q" parity
- Mode 2: 2336 bytes of user data, usually used for CD-ROM/XA
In order to retrieve the type of data provided for the sectors in one track you can use the method get_SectorType from IRawCDImageTrackInfo interface.
The possible sector types are defined by the IMAPI_CD_SECTOR_TYPE enumeration:
typedef enum {
IMAPI_CD_SECTOR_AUDIO = 0x00,
IMAPI_CD_SECTOR_MODE_ZERO = 0x01,
IMAPI_CD_SECTOR_MODE1 = 0x02,
IMAPI_CD_SECTOR_MODE2FORM0 = 0x03,
IMAPI_CD_SECTOR_MODE2FORM1 = 0x04,
IMAPI_CD_SECTOR_MODE2FORM2 = 0x05,
IMAPI_CD_SECTOR_MODE1RAW = 0x06,
IMAPI_CD_SECTOR_MODE2FORM0RAW = 0x07,
IMAPI_CD_SECTOR_MODE2FORM1RAW = 0x08,
IMAPI_CD_SECTOR_MODE2FORM2RAW = 0x09
} IMAPI_CD_SECTOR_TYPE;
- IMAPI_CD_SECTOR_AUDIO
With this sector type, Audio data has 2352 bytes per sector/frame. This can be broken down into 588 contiguous samples, each sample being four bytes. The layout of a single sample matches the 16-bit stereo 44.1KHz WAV file data. This type of sector has no additional error correcting codes.
- IMAPI_CD_SECTOR_MODE_ZERO
With this sector type, user data has 2336 bytes per sector/frame. This seldom-used sector type contains all zero data, and is almost never seen in media today.
- IMAPI_CD_SECTOR_MODE1
With this sector type, user data has 2048 bytes per sector/frame. Mode1 data is the most common data form for pressed CD-ROM media. This data type also provides the greatest level of ECC/EDC among the standard sector types.
- IMAPI_CD_SECTOR_MODE2FORM0
With this sector type, user data has 2336 bytes per sector/frame. All Mode 2 sector types are also known as "CD-ROM XA" modes, which allows mixing of audio and data tracks on a single disc. This sector type is also known as Mode 2 "Formless", is considered deprecated, and is very seldom used.
- IMAPI_CD_SECTOR_MODE2FORM1
With this sector type, user data has 2048 bytes per sector/frame. All Mode 2 sector types are also known as "CD-ROM XA" modes, which allows mixing of audio and data tracks on a single disc.
- IMAPI_CD_SECTOR_MODE2FORM2
With this sector type, user data has 2336 bytes per sector/frame, of which the final four bytes are an optional CRC code (zero if not used). All Mode 2 sector types are also known as "CD-ROM XA" modes, which allows mixing of audio and data tracks on a single disc. This sector type is most often used when writing VideoCD discs.
- IMAPI_CD_SECTOR_MODE1RAW
With this sector type, user data has 2352 bytes per sector/frame. This is pre-processed Mode1Cooked data sectors, with sector header, ECC/EDC, and scrambling already added to the data stream.
- IMAPI_CD_SECTOR_MODE2FORM0RAW
With this sector type, user data has 2352 bytes per sector/frame. This is pre-processed Mode2Form0 data sectors, with sector header, ECC/EDC, and scrambling already added to the data stream.
- IMAPI_CD_SECTOR_MODE2FORM1RAW
With this sector type, user data has 2352 bytes per sector/frame. This is pre-processed Mode2Form1 data sectors, with sector header, ECC/EDC, and scrambling already added to the data stream.
- IMAPI_CD_SECTOR_MODE2FORM2RAW
With this sector type, user data has 2352 bytes per sector/frame. This is pre-processed Mode2Form2 data sectors, with sector header, ECC/EDC, and scrambling already added to the data stream.
Remarks:
Some sector types are not compatible with other sector types within a single image. The following are typical examples of this condition:
If the first track is audio, then all tracks must be audio.
If the first track is Mode1, then all tracks must be Mode1.
Only the three Mode2 (XA) sectors (Mode 2 Form 0, Mode 2 Form 1, and Mode 2 Form 2) may be mixed within a single disc image, and even then, only with other Mode 2 (XA) sector types.