Lossless Audio Compression
Lossless audio compression stores audio efficiently while preserving the encoded source sample values exactly.
The samples 100, 104, 107, 109 can be stored directly, or described as a starting value followed by differences. Both descriptions contain the same information. Lossless audio compression searches for a description that uses fewer bits without merging distinguishable source values.
Reconstruct the differences exactly
| Stored item | Decoder operation | Restored sample |
|---|---|---|
| Starting sample: 100 | Retain 100 | 100 |
| Difference: +4 | 100 + 4 | 104 |
| Difference: +3 | 104 + 3 | 107 |
| Difference: +2 | 107 + 2 | 109 |
The decoder needs both the prediction rule and its initial values. It then follows the same arithmetic as the encoder. Even when the prediction is poor, keeping the entire difference allows exact reconstruction.
A better predictor can make the remaining numbers smaller. Suppose the rule predicts the next sample as twice the preceding sample minus the one before it. Start with 100 and 104:
- Prediction for the third sample: 2 × 104 − 100 = 108. Store the residual −1 to restore 107.
- Prediction for the fourth: 2 × 107 − 104 = 110. Store another −1 to restore 109.
These are illustrative predictors, not a complete implementation of a particular codec.
Smaller numbers are useful only if they are coded efficiently
A residual array alone is not compressed merely because its numbers are smaller. The next step assigns compact bit representations to likely residual values and sufficient representations to larger ones.
The encoder also stores the predictor description, initial samples, and framing. If an elaborate predictor saves too few bits to repay its description, a simpler one is better. A nearly unpredictable or already noisy passage may compress less efficiently; a format can use a direct representation where that is appropriate.
This accounts for variable lossless bitrate: different source passages have different redundancy. The encoder is changing the size of a reversible description, not the accuracy of the reconstruction.
Compression levels change the search
A stronger compression preset can spend more effort finding predictors, partitions, or coding parameters. If two valid lossless encodes preserve the same supported input samples, decoding either returns those samples. Their different file sizes are a measure of representation efficiency.
Decoding cost and random-access structure also matter. A music archive and a constrained player can prefer different compromises among size, encoding time, and reading requirements without choosing different audio fidelity.
Decide which equality to verify
Two files using different lossless codecs cannot have identical compressed bytes. Their decoded audio can nevertheless be identical when sample representation, order, rate, and count are preserved.
| Comparison | Question answered |
|---|---|
| Whole-file checksum | Are these exact files unchanged? |
| Decoded sample comparison | Do they represent the same audio values? |
| Metadata comparison | Did tags, artwork, and other descriptions survive? |
| Actual output-path check | Did playback later alter the decoded presentation? |
A lossless encode preserves its input. If that input was an MP3 reconstruction, the restored samples match that reconstruction, not an unavailable earlier master.
Likewise, an Emby session can decode a lossless source exactly and then downmix or resample it. The source-codec promise has been fulfilled at decoding; preservation beyond that point is a separate question about the subsequent operations.