After entropy decoding, the values pass through up to three adaptive filters, then a predictor, and finally stereo reconstruction. This page follows FFmpeg’s decoder, which handles file versions 3800 to 3990.
Filters by compression level
The level picks a row: row = level ÷ 1000 − 1. An order of 0 means the stage
is absent, so Fast has no filter stage at all.
| Level | Name | Filter orders | Fractional bits |
|---|---|---|---|
| 1000 | Fast | none | |
| 2000 | Normal | 16 | 11 |
| 3000 | High | 64 | 11 |
| 4000 | Extra high | 32, 256 | 10, 13 |
| 5000 | Insane | 16, 256, 1280 | 11, 13, 15 |
How a filter adapts
Each filter keeps a history and a set of coefficients, predicts by their dot product, and changes the coefficients according to the sign of the result. The history values are clipped to 16 bits. The size of the adaptation step depends on the version:
| Version | Adaptation value | Older values halved |
|---|---|---|
| Below 3980 | ±4 from the sign of the result; 0 when the result is 0 | At offsets −4 and −8 |
| 3980 and later | The sign of the result times 8, doubled for each of two thresholds passed. The thresholds are 3 × the running average and 4/3 × the average, with the average updated by (|result| − average) ÷ 16 | At offsets −1, −2 and −8 |
Predictors by version
| Version | Predictor |
|---|---|
| Below 3930 | Older filters: a fast first-order form at level 1000, and longer filters at 3000 and 4000 |
| 3930 to 3949 | A single-stage predictor of four coefficients |
| 3950 and later | The stereo predictor described below, with 64-bit sums where needed |
The 3950 predictor
Stereo decoding uses two channels called Y and X. Each sample is predicted from its own channel’s last four values with coefficient set A and, using the other channel, five values with set B. The output is the input plus the combined prediction shifted right by 10. Each coefficient then moves by 1, or not at all, according to the signs of the input and of its history value.
| Item | Value |
|---|---|
| History buffer | HISTORY_SIZE 512, plus PREDICTOR_SIZE 50 |
| Predictor order | PREDICTOR_ORDER 8 |
| Delay offsets | YDELAYA 50, YDELAYB 42, XDELAYA 34, XDELAYB 26 |
| Adaptation offsets | YADAPTCOEFFSA 18, XADAPTCOEFFSA 14, YADAPTCOEFFSB 10, XADAPTCOEFFSB 5 |
| Initial A coefficients | 360, 317, −109, 98 |
| Initial B coefficients | All 0 |
A mono stream uses only the Y side and set A. For 24-bit stereo, FFmpeg runs a second pass on a copy and watches for overflow past 2²³; it calls this interim mode. There is no clipping of the output in this predictor.
Stereo reconstruction
The encoder converts left and right to a mid and a side signal. The decoder reverses that:
left = decoded[1] − (decoded[0] ÷ 2)
right = left + decoded[0]
Here decoded[0] is the difference and decoded[1] the mid signal.
The conversion is a whole-number one that loses nothing. For files of more than two channels
(added in version 4.86), or for 32-bit and floating-point audio, the layout could not be
confirmed.