Lossless vs. lossy compression across audio, video and image formats

Understand how entropy coding (DEFLATE, LZMA, Brotli, FLAC) differs from perceptual transform coding (DCT, MDCT, wavelet, intra-frame prediction), when generation loss occurs, and which formats support both modes.

1. Mathematical definition: exact bit reconstruction vs. perceptual masking

File compression algorithms divide into two fundamentally different categories:

  • Lossless compression exploits statistical redundancy in a byte or sample stream—using techniques such as LZ77 sliding-window dictionary matching, Huffman trees, arithmetic/ANS entropy coding, Burrows-Wheeler block sorting, or linear prediction residuals—so that decompressing the file reconstructs the exact original bit sequence. Every general-purpose data and archive format (ZIP, GZ, 7Z, Parquet) and every document or executable format must be strictly lossless, because flipping a single bit in a database or program corrupts the file.
  • Lossy compression applies a mathematical frequency or spatial transform—such as the Discrete Cosine Transform (DCT) in JPEG and H.264, or the Modified Discrete Cosine Transform (MDCT) in MP3, AAC, and Opus—and intentionally quantizes (rounds off) high-frequency coefficients that human eyes or ears are less sensitive to. The decoded output looks or sounds close to the original at 10% of the byte size, but the discarded high-frequency precision cannot be recovered.

2. Comparison matrix across images, audio and video

Media domainUncompressed baselineLossless compressed formatsLossy compressed formatsDual-mode formats (support both)
Raster ImagesBMP, PPMPNG (DEFLATE + Paeth filter), GIF (LZW, 256-color limit)JPG / JPEG (8×8 DCT + chroma subsampling)WebP (VP8L lossless / VP8 lossy), AVIF, TIFF, JP2
Digital AudioWAV, AIFF, CAFFLAC, TTA, Apple ALAC (in M4A)MP3, AAC, Opus, Vorbis (OGG), AC-3WavPack (.wv), Windows Media Audio (.wma)
Digital VideoRaw YUV / RGB in AVI or MOVFFV1, H.264 -crf 0, UT VideoH.264, HEVC, VP9, AV1, MPEG-2 in MP4/WebM/MKVH.264, HEVC, VP9, and AV1 all support a mathematical lossless mode flag

3. Why transcoding lossy-to-lossy causes generation loss

When an image service accepts a user-uploaded JPEG (already quantized on an 8×8 pixel DCT grid with 4:2:0 chroma subsampling), decodes it to RGB, and re-encodes it as a new JPEG or lossy WebP at quality 75, the second quantization pass compounds rounding errors along the 8×8 block boundaries—producing visible "mosquito noise" halos around sharp text and blocky gradients. The same phenomenon occurs in audio pipelines that decode a 128 kbps MP3 to PCM and re-encode it to AAC or Opus.

To prevent generation loss in your application's media pipeline:

  1. Store master assets in a lossless format: Keep original uploads in PNG, lossless WebP, or FLAC/WAV, and generate lossy delivery derivatives (AVIF, lossy WebP, AAC, Opus) in a single pass from the master.
  2. Never convert screenshots or UI diagrams to baseline 4:2:0 JPEG: Sharp 1-pixel text edges contain extreme high-frequency energy across all three RGB channels. Lossless PNG or lossless WebP compresses flat-color UI screenshots to a smaller byte size than JPEG while keeping every pixel razor-sharp.
  3. Detect lossless vs. lossy WebP by chunk FourCC: Both lossless and lossy WebP files use the .webp extension and start with RIFF....WEBP, but bytes 12–15 are VP8 (with a trailing space) for lossy WebP and VP8L for lossless WebP.

Related guides and test tools

Frequently asked questions

Why did converting my MP3 to WAV or FLAC make the file 8× larger without improving sound quality?
Once a lossy encoder (like MP3 or AAC) discards psychoacoustically masked frequencies, that information is gone forever. Saving the decoded waveform as uncompressed WAV or lossless FLAC simply records the already-degraded waveform bit-for-bit at a much larger file size.
How can I tell if a WebP image is lossless or lossy?
Drop the file into our /inspector/ tool or inspect bytes 12–15: ASCII 'VP8L' indicates WebP Lossless, whereas 'VP8 ' indicates lossy VP8 keyframe coding.