Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Format:CD-ROM raw sector layouts

From ReverseEngineering.wiki
Format
On this wiki Facts · Code · Notes · Topics

How a 2352-byte raw CD sector is organized (sync, header, mode byte, user data, EDC/ECC), the sector sizes of the CD data modes, and the 96-byte subchannel stored beside it by disc image formats.

Raw sector

A CD sector read in raw mode is 2352 bytes. Disc image formats that keep raw sectors (BIN/IMG files, CHD, NRG, MDF, CloneCD) therefore use a 2352 byte stride, plus 96 bytes of subchannel data per sector when they store it (2448 total, as in the CD frame of a CHD).

Offsets read in libchdr's cdrom.c:

  • 0x000 to 0x00B: 12-byte sync pattern 00 FF FF FF FF FF FF FF FF FF FF 00.
  • 0x00C to 0x00E: 3-byte header (minute, second, frame address). Unverified: BCD coded.
  • 0x00F: mode byte (libchdr's MODE_OFFSET is 0x00f); the ECC code treats mode 2 specially.
  • Mode 1 (data starts at 0x010, 2048 bytes): Unverified: EDC 4 bytes at 0x810 and 8 zero bytes at 0x814 (ECMA-130 layout, not read here); P parity at 0x81C (172 bytes) and Q parity at 0x8C8 (104 bytes), which end at 0x930 = 2352. The P and Q offsets are from libchdr (ECC_P_OFFSET 0x81c, 2 x 86 bytes; ECC_Q_OFFSET after it, 2 x 52 bytes).
  • Mode 2: the 8-byte subheader and, for Form 1, 2048 data bytes, EDC and ECC; Form 2 has 2324 data bytes and no ECC. Unverified (ECMA-130 / CD-ROM XA, not read here).

In libchdr's ECC generator, for a mode 2 sector the 4 bytes after the sync pattern (the header) are treated as zero when computing parity.

Sizes by track type

Sizes per sector in libchdr's cdrom.h comments: Mode 1 cooked 2048, Mode 1 raw 2352, Mode 2 2336, Mode 2 Form 1 2048, Mode 2 Form 2 2324, Mode 2 form-mix 2336, Mode 2 raw 2352, audio 2352 (588 samples). See the CHD page for the CD frame (2448 = 2352 + 96) and how CHD strips sync and ECC.

Subchannel

Image formats store 96 subchannel bytes per sector (CloneCD .sub, CHD frames, Alcohol MDF with subchannel mode 0x08); libchdr distinguishes cooked 96 bytes, raw uninterleaved 96 bytes and none. Subchannel contents used by copy protection are out of scope here (recognition only).

Image formats

Format:Nero NRG, Format:Alcohol MDS and MDF, Format:CloneCD CCD, IMG and SUB, Format:DiscJuggler CDI, Format:CHD (MAME Compressed Hunks of Data).

Related: Format:ISO 9660 (the file system on the 2048-byte user data), Format:CD-ROM XA (Mode 2 Form 1/2 sectors), Format:CSO (compressed ISO).

Code & repositories

  • https://github.com/rtissera/libchdr @ 47d794151b2b64f6aba60304e6480f4f5a2bc24b · license: BSD-3-Clause
    Standalone CHD reader (BSD-3-Clause) with the format comment in chd.h and the CD codecs/ECC in libchdr_cdrom.c.
    Tested on: source read, not run: read only, no build · checked 2026-10-19; last activity 2026-10-11
  • https://github.com/aaru-dps/Aaru @ 1eaee6f63254f85e8a1119f4fce1e55f276e0846 · license: LGPL-2.1-or-later (declared by the contributor; GitHub's detector did not recognize LICENSE)
    Aaru Data Preservation Suite; Aaru.Images has readers for Nero, Alcohol 120%, CloneCD, DiscJuggler, CHD and more (image plugins are LGPL-2.1-or-later per file headers).
    Tested on: source read, not run: read only, no build · checked 2026-10-19; last activity 2026-10-18; Note: the latest release ships binaries; the wiki links only the source, never the binaries