[FFmpeg-devel] [PATCH] MLP Encoder

Ramiro Polla ramiro.polla
Thu Aug 14 07:08:45 CEST 2008


Attached is the MLP encoder written as part of the Google Summer of
Code project and mentored by Justin Ruggles.

Things that are not quite complete:
- 24-bit support. I'm waiting to see what will become of
SAMPLE_FMT_S24, and the code might need a few changes. But mostly it
- The filters... The filtering code is there and it works, but finding
good coefficients is not. The FIR code from flacenc.c can be plugged
in there quite easily, but it takes more bits to encode the
coefficients than the raw data. It might be because of the small frame
size (40 samples @ 44100kHz). If the frame size was raised to
something like 256 samples, the compression would be much better, but
the RE work shows that the bitstream doesn't allow this. Also my
attempts with IIR filters weren't successful.

Things that are awfully suboptimal:
- The search for the best offset for the codebooks. If just one offset
(the average) is taken into account and no search is done, encoding is
30% faster and the resulting filesize is 0.5% bigger. At one point I
thought taking the median (instead of the average) of all the samples
would compress better (more values close to 0), but it took longer to
calculate and would have highly inaccurate offsets, having to search
even more.

Things that have not been implemented:
- The lossless matrix. I don't know what to do of it. So there is no
channel decorrelation.
- More than 2 channels. This shouldn't be too hard, I just didn't put
it high on my priorities.

Things that can be reused from existing code:
- A pending patch for END_OF_STREAM in mlp.h.
- More structs can be reused from mlpdec.c. I would prefer to split
Substr into DecodingParams and RestartHeader (like the encoder does),
and move that to mlp.h. I'll send a patch about this depending on the
- The noise code can be reused if the noise generation functions are
cleaned up to use shared structs or more generic parameters. This code
is still not being needed by the encoder though, since it does no

There's also another patch pending to simplify quant_step_size in mlpdec.c.

Example of file sizes and compression using sample "luckynight.mlp":
decoded wav: 10668844
original mlp: 7899056  25.9%
encoded  mlp: 8563354  19.7%

Besides this, the bitstream is very robust. You can trash it at will
and the decoder will play as much as possible, resuming lossless
playback usually in less than 70ms (for 44100kHz, with 40 samples per
frame and 16 frames per major sync).

Please review.

Ramiro Polla
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mlpenc.c
Type: text/x-csrc
Size: 38526 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080814/ce55b5cf/attachment.c>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: libavformat_mlpenc.diff
Type: text/x-diff
Size: 1645 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080814/ce55b5cf/attachment.diff>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: libavcodec_mlpenc.diff
Type: text/x-diff
Size: 2528 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080814/ce55b5cf/attachment-0001.diff>

More information about the ffmpeg-devel mailing list