Interleave

A compact disc does not write your music in order. It deals it out across the track like a hand of cards, so that a scratch landing in one place cannot land in one codeword. Drag a scratch below and watch the damage come apart.

The disc

1 The track, as it is written

    No scratch. Drag across the track.

      2 De-interleaved, which is how the decoder sees it

        3 C1 flags, C2 corrects

        4 What reaches the speaker

        Scratch
        0.00 mm
        Symbols destroyed
        0
        Worst codeword
        0 erasures
        Samples exact
        all
        Concealed
        none
        Muted
        none

        Undamaged. Every sample arrives exactly as recorded.

        And what it sounds like

        A 440 Hz tone, 700 ms of it, with the damage above applied at its true length. A frame carries six stereo pairs, so the whole window is 288 samples: 6.53 ms, about three cycles. Nothing here is slowed down or exaggerated.

        Why scattering it first is what saves it

        Reed-Solomon is good at a few wrong symbols and helpless at many. The C2 codeword on a CD carries 24 data symbols and 4 of parity, and four parity symbols buy you either two errors in unknown positions or four erasures in positions somebody has already flagged.

        A scratch does not produce a few wrong symbols. It produces a run of hundreds of consecutive dead ones. Written in order, that run lands inside one or two codewords and takes them out completely, and no amount of parity helps.

        So the encoder deals the symbols out. Symbol i of a codeword is delayed by four frames more than symbol i − 1, so the 28 symbols of one codeword end up spread across 109 frames of track. Run that backwards at playback and a burst that was contiguous on the disc arrives at the decoder as single symbols, one per codeword, which is the case Reed-Solomon is good at.

        The number that falls out of this is the interesting part. With symbols spaced four frames apart, a scratch F frames wide puts about F/4 symbols into each affected codeword. C2 tolerates four erasures. So the correctable scratch is about 16 frames wide, and the page computes what that is in millimetres from the disc's own constants rather than being told.

        It comes out at 2.6 mm. The references say 2.5. Two numbers from the standard, the four-frame spacing and the four parity symbols, land within five percent of a figure that was measured on real discs, and that agreement is the point. They do not land on it exactly, and this page does not round until they do: the disc runs anywhere from 1.2 to 1.4 m/s depending on how far out the track is, so the millimetre value is a range rather than a constant.

        Why there are two decoders and not one

        C1 runs first, over 32-symbol words, and it is deliberately timid: it corrects one symbol and, when it sees more damage than that, refuses and flags the word instead of guessing. A wrong correction is worse than no correction, because it is silent.

        Those flags are the whole point. When C2 sees a symbol that C1 flagged, it does not have to work out where the error is, only what the right value was. Locating an error costs two parity symbols; correcting a known-bad one costs one. That is why the pair together handles four bad symbols where either alone handles two.

        The two codes are also read at right angles to each other. C1 runs along the frame and C2 runs across frames, so a failure that looks catastrophic to one is sparse to the other. Cross-interleaving is the name for exactly that arrangement.

        And when it fails anyway

        Past the correction limit the player stops pretending it has your music and starts covering for the loss. A sample it cannot recover is replaced by the average of its neighbours, which for a waveform sampled 44,100 times a second is usually inaudible. Past that it mutes, briefly, with a ramp rather than a cliff so the silence does not click.

        This is the part that makes a CD feel robust rather than digital-brittle. The failure is graded: exact, then plausible, then quiet. A scratch that is far past correction still plays, and mostly still sounds like music.

        What is real here, and what is not

        The interleave is real; the Reed-Solomon arithmetic is not performed

        The mapping is the real one: symbol i of a C2 codeword is delayed by 4i frames, so this page really does compute which frames a codeword's symbols land in and how many of them a given scratch destroys. What it does not do is run a GF(256) syndrome calculation. Correctability is decided by counting erasures against what four parity symbols can cover, which is the criterion a real decoder applies, but the decoding itself is not being carried out. Building an actual decoder is a different piece.

        The decoder strategy shown is one of several

        C1 correcting a single symbol and flagging anything worse is the conservative strategy, and it is the one most commonly described. Real players differ: some attempt two-symbol C1 correction, some carry flags differently, and manufacturers treated their strategy as a competitive matter. The code sizes are fixed by the standard; how aggressively you decode them is not.

        The frame count on screen is a window, not a disc

        A CD carries about 7,350 frames per second. The strip above shows a few dozen, enough to see a codeword's symbols spread out. The spacing, the codeword sizes and the arithmetic are to scale; the length of track is not.

        Sources disagree about the burst limits, so both are here

        The correctable burst is given as 4,000 data bits, about 2.5 mm of track, in some references and as 3,874 bits over the same 2.5 mm in others. Concealment is given as 12,000 bits and 7.5 mm in the first and 13,282 bits and 8.7 mm in the second. The millimetre figure for correction is the one they agree on, which is why the page leads with millimetres. Neither figure appears to be derived from the other and this page does not pick a winner.

        Millimetres are computed, not typed in

        One frame is 588 channel bits, the channel rate is 4.3218 Mbit/s, and the disc passes the pickup at 1.2 m/s at the slow end of its range. That gives 7,350 frames per second and 0.163 mm of track per frame, which is where every millimetre figure on this page comes from. Real players run 1.2 to 1.4 m/s depending on radius, so treat the figure as the conservative end.

        Interpolation is described, not synthesised

        The readout counts how many samples would be concealed and how many muted. It does not generate audio and there is nothing to listen to. A version that lets you hear the difference would be a good thing to build and this is not it.

        Sources