How Unrar Extracts Multimedia Compressed RAR Files

This article explains how the unrar utility processes and extracts RAR archives created using proprietary multimedia compression algorithms. It explores the detection of multimedia data streams, the reverse execution of delta and predictive filters, and how modern versions of unrar maintain backward compatibility with legacy RAR2 and RAR3 compression formats where multimedia-specific algorithms were used.

The Role of Multimedia Compression in RAR

In older versions of the RAR format—specifically RAR 2.0 through RAR 3.x—the archiver included a dedicated multimedia compression mode (enabled via the -mm command-line switch). This algorithm was designed to improve compression ratios on uncompressed raw audio (such as 8-bit and 16-bit PCM WAV files) and raw bitmap images.

Rather than relying purely on standard LZSS dictionary compression and Huffman coding, the multimedia algorithm implemented predictive coding. It analyzed patterns in sequential audio samples or pixel channels, predicted incoming data points, and stored only the difference (delta) between the predicted value and the actual value.

The Decompression Process in Unrar

When unrar extracts an archive containing multimedia-compressed streams, it processes the data through a multi-step decoding pipeline:

  1. Header and Method Detection
    unrar reads the archive headers and block flags. When it encounters blocks marked with multimedia compression flags, it routes the compressed stream to legacy unpack routines rather than standard general-purpose decoders.

  2. Entropy Decoding
    The compressed data is first passed through standard entropy decoding (Huffman tree parsing) to reconstruct the intermediate byte stream. This stream does not contain the original raw data directly; instead, it contains compressed residuals and predictor state directives.

  3. Inverse Predictive Filtering
    The core of multimedia handling occurs in the inverse transform stage. For audio, unrar uses an inverse delta filter that tracks multiple channels simultaneously. It takes previous sample values, calculates the expected sample based on the algorithm's fixed prediction weights, and adds the decoded delta to rebuild the original waveform. For multi-channel streams (such as stereo 16-bit audio), it reconstructs channel interleaving that was split during compression to optimize spatial correlation.

  4. Buffer Reconstruction and Output
    Once the delta values are integrated back into absolute sample or pixel values, the reconstructed data is sent to the write buffer and flushed to disk as the original uncompressed file.

Backward Compatibility and RAR5

In 2013, RARLAB introduced the RAR 5.0 archive format, which officially removed the dedicated multimedia compression algorithm. The decision was made because modern media files (such as MP3, FLAC, JPEG, and MP4) are already heavily compressed, making dedicated linear prediction filters largely obsolete and computationally inefficient for modern workloads.

To maintain complete backward compatibility, the modern unrar source code retains dedicated legacy unpack modules (such as the legacy unpack routines for RAR 2.9/3.0 algorithms). When opening a legacy archive containing multimedia-compressed content, unrar transparently switches from the RAR5 decompressor to the appropriate legacy unpack engine, ensuring full data fidelity without requiring any manual configuration by the user.