Fabien Petitcolas

MPEG for Matlab

When we started looking at MPEG compression algorithms for audio we tried to find an implementation for MATLAB. Unfortunately it seems that nothing is available apart some libraries written in C and that one can call from MATLAB. This is one of the reasons why I decided to make my own implementation of the psychoacoustic model.

Only psychoacoustic model 1 (see Davis Pan, A tutorial on MPEG audio compression, IEEE multimedia magazine, vol. 2, no. 2, pp. 60–74, Summer 1995) for layer I is available. During the implementation I have tried to stick as much as possible to the ISO/IEC 11172-3:1993 standard. The code contains a lot of comments and graphs can be drawn at any step of the process; this should help to understand how MPEG compression works. Additional documents are available online. It has not been optimised for speed but rather for understanding.

Don’t forget to let me know your suggestions, comments and improvements: fabien18@petitcolas.net

There is also an MPEG Encoding library for MATLAB Movies, created by David Foti. This enables MATLAB users to read (MPGREAD) or write (MPGWRITE) MPEG movies.

See www.mathtools.net for more scientific tools on the net.

This page is also available in Hindi and in Estonian.

Sample graphs

Local maxima

Tonal components

Tonal and non-tonal components

Non-tonal components v. absolute threshold

Tonal components v. absolute threshold

Tonal components too closed to each other eliminated



Minimum masking threshold



This computer program is based on ISO/IEC 11172-3:1993, Information technology – Coding of moving pictures and associated audio for digital storage media at up to about 1,5 Mbit/s – Part 3: Audio, with the permission of ISO. Copies of this standards can be purchased from the British Standards Institution, 389 Chiswick High Road, GB-London W4 4AL, Telephone:+ 44 181 996 90 00, Telefax:+ 44 181 996 74 00 or from ISO, postal box 56, CH-1211 Geneva 20, Telephone +41 22 749 0111, Telefax +4122 734 1079. Copyright remains with ISO.

Thank you to Jovana Milutinovich for the translation of this page into Serbo-Croatian and to Milos Onichanu for the Romanian translation.