Lossy and Lossless Compression
Lossless compression preserves the encoded input exactly, while lossy compression permits changes to reduce the amount of data.
Take four invented digital sample values:
100, 101, 101, 100
One way to describe them is to store the first value and then the differences: 100, +1, 0, −1. Reconstruction adds each difference to the previous result: 100, then 101, then 101, then 100. Nothing was approximated. A compressor can exploit such predictable differences to use fewer bits, while retaining a reversible description.
That is the essential bargain of lossless compression. The exact representation differs among codecs, but a correct decoder recovers the encoder's input samples. FLAC, for example, predicts audio samples and codes the remaining differences without discarding them.
What changes when approximation is allowed?
Now round the invented inputs to the nearest multiple of four:
| Input | Rounded output | Output minus input |
|---|---|---|
| 100 | 100 | 0 |
| 101 | 100 | −1 |
| 101 | 100 | −1 |
| 100 | 100 | 0 |
The resulting constant sequence may be easier to describe. However, decoding it yields four values of 100. It gives no way to determine that the middle two were originally 101. Several possible inputs have become the same output.
This is a simplified example of lossy approximation, not the full operation of an audio or video codec. Real codecs apply coding tools, predictions, transforms, and models that decide which changes are worthwhile. The video compression walkthrough follows those stages. A changed numerical value may have little visible or audible effect, so lossiness and an obvious defect are different judgments.
Locate the lossless boundary in a conversion
Consider this route:
MP3 file → MP3 decoder → PCM samples → FLAC encoder → FLAC decoder
The two PCM sequences surrounding FLAC can match exactly. They are still the samples reconstructed from MP3, including changes made when that MP3 was encoded. A lossless stage preserves its own input; it cannot infer an earlier input that no longer exists.
A resampler, a volume adjustment, or a pixel-format conversion before the lossless encoder introduces another boundary. To test the lossless codec itself, compare the samples immediately before encoding with those immediately after decoding in the same representation. Comparing entire files also includes containers and tags, which may differ even with identical samples.
For an Emby collection, copying the encoded source or remuxing its tracks can preserve an existing lossy representation without adding a new coding generation. Re-encoding reconstructs samples and produces a new encoded representation; a lossless encoding stage can retain their values exactly. The useful question is which representation you want to preserve and at which stage you are comparing it.