previous page: 2-43-3] What's a frame? CIRC encoding? How does ECC work?
page up: CD-Recordable FAQ
next page: 2-43-5] What's in a subcode channel?

2-43-4] What's in a sector?


This article is from the CD-Recordable FAQ, by Andy McFadden (fadden@fadden.com) with numerous contributions by others.

2-43-4] What's in a sector?


98 frames of 24 bytes are combined to form a 2352-byte sector and 98
bytes of subcode data. The sector is assembled from F1 Frames, which are
byte-swapped, shuffled, and run through a descrambler. The purpose of
the scrambler is to reduce the likelihood that regular bit patterns will
induce a large digital sum value.

It should be pointed out that the 2352-byte sector is the smallest unit
most CD-ROM drives will allow software to manipulate. It's only after all
of the above that low-level CD-ROM operations, like "RAW DAO-96" reads and
writes, begin. This is why making a "bit-for-bit" copy of a disc is tricky.

A sector on an audio CD holds 2352 bytes of data. 16-bit stereo samples
require 4 bytes per sample, so there's 2352/4 = 588 samples per sector.
At 75 sectors per second, that's 44100 samples per second (44.1KHz).
At this point, the processing for an audio CD is essentially complete.
CD players feed the samples through a DAC (or S/PDIF connector) and
eventually out to the speakers, and send the subcode data to the front
panel controller so it can update the HH:MM counter and track number.

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 sync field and address are important because early CD-ROM drives
weren't able to accurately determine the start of a sector. The drives
were based on CD players, which just shoved the decoded frames into one
FIFO and the subcode data into another. The CD-ROM firmware was presented
with a stream of bytes, and expected to make sense of it. This situation
is also responsible for audio extraction "jitter", discussed at length in
section (2-15).

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 (see below)

The Mode 1 CD-ROM ECC is independent of and in addition to the CIRC encoding.
It uses a Reed-Solomon Product Code (RSPC) to achieve a combined error
rate of 1 error per 1e15 (quadrillion) bits.

CD-ROM/XA (eXtended Architecture) Mode 2 extends the definition of a Mode
2 CD-ROM. Form 1 looks like a slight rearrangement of a Mode 1 sector,
with the 8 bytes of space moved ahead of the user data and filled with
a sub-header. Form 2, intended for compressed audio/video data, has the
8-byte sub-header, 2324 bytes of data, and an optional 4-byte EDC code.
The sub-header contains some channel and data type flags.

A CD session must be written in a single mode, but the XA spec allows the
form to change. Using CD-ROM/XA Mode 2 allows you to choose between extended
error correction and increased data capacity, and also change your mind
several times in a single track.


Continue to:

previous page: 2-43-3] What's a frame? CIRC encoding? How does ECC work?
page up: CD-Recordable FAQ
next page: 2-43-5] What's in a subcode channel?