Public domain mp3 decoder
Branch: master
Clone or download
adalinbv and technosaurus Add a streaming API (#5)
* Implement a subset of a libmpg123 compatible streaming API

* Add two (unused) pointer variables to pdmp3_new just like mpg123p3_new
Add an mpg123_decode equivilant function pdmp3_decode
Make pdmp3_open_feed reset the handle so calling pdmp3_new and pdmp3_delete between songs becomes unnecesary
Make pdmp3_read return PDMP3_NEW_FORMAT when the MP3 header is processed

* Remove solved items from the TODO list and add some documentation about the streaming API

* Make pdmp3_read fill the output buffer with more than one frame if is larger than 2*576 samples

* Search for the MP3 header rather than assuming it always starts at byte 0. This is a requirement for mp3 streams.

* Let PDMP3_NEED_MORE trump over PDMP3_NEW_FORMAT
Latest commit 2a206a3 Aug 13, 2017
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore update gitignore for new binary name May 18, 2015
Makefile Convert to stb_vorbis style code May 18, 2015
README.md Add a streaming API (#5) Aug 12, 2017
main.c Convert to stb_vorbis style code May 18, 2015
pdmp3.c Add a streaming API (#5) Aug 12, 2017

README.md

PDMP3

Public domain mp3 decoder

This project is a fork of the mp3 decoder written by Krister Lagerstrom as part of a master's thesis. This version implements a subset op the libmpg123 API which should be a 100% compatible replacement. If it's not that is considered a bug. In theory more libmpg123 compatible functions could be implemented quite easily.

Available functions for the streaming API are:

pdmp3_handle * pdmp3_new(const char *decoder,int *error); void pdmp3_delete(pdmp3_handle * id); int pdmp3_open_feed(pdmp3_handle * id); int pdmp3_feed(pdmp3_handle * id,const unsigned char * in,size_t size); int pdmp3_read(pdmp3_handle * id,unsigned char * outmemory,size_t outsize,size_t * done); int pdmp3_decode(pdmp3_handle * id,const unsigned char * in,size_t insize,unsigned char * out,size_t outsize,size_t * done); int pdmp3_getformat(pdmp3_handle * id,long * rate,int * channels,int * encoding);

TODO

  • cleanup,
  • switch to bitfields,
  • fix some of the horribly nested logic

License: My work is placed in the public domain. You may do whatever you wish with it, including using it for commercial applications.

The thesis and original code are available at:

From the abstract:

Digital compression of audio data is important due to the bandwidth and storage limitations inherent in networks and computers. Algorithms based on perceptual coding are effective and have become feasible with faster computers. The ISO standard 11172-3 MPEG-1 layer III (a.k.a. MP3) is a perceptual codec that is presently very common for compression of CD quality music. An MP3 decoder has a complex structure and is computationally demanding.

The purpose of this master's thesis is to present a tutorial on the standard. We have analysed several algorithms suitable for implementing an MP3 decoder, their advantages and disadvantages with respect to speed, memory demands and implementation complexity. We have also designed and implemented a portable reference MP3 decoder in C.

If you are trying to implement an mp3 decoder and found the 11172-3 reference to be vague, the thesis is a a good read.

Some other good references are: