[NTLK] Preliminary results for porting MAD (an MP3 Decoder)

From: Eckhart Koeppen (eck1000_at_gmx.net)
Date: Tue Nov 06 2001 - 19:06:28 EST


[I just posted this to c.s.n.programmer, but I'm sure some people here
are interested as well]

Hello there,

I've completed some tests with my port of MAD, a MP3 decoder written in
C by Robert Lesile (http://www.mars.org/home/rob/proj/mpeg) and I
thought I let you know how far I got. But first of all, I have to say
that MAD is an extremely nice software package. I think Robert did an
outstanding job to create not only a fully functional but also portable
and modular MP3 decoder library.

The port was not too hard, consisting mostly of identifying the
necessairy core parts of MAD, changing the initalization of the Huffman
tables to work with the NCT C compiler and implementing a NS wrapper.

The wrapper works with two buffers: a buffer for the incoming raw MP3
data and an output buffer for the PCM frames. The input buffer is
allocated on the C++ system heap, the output buffer is currently a
NewtonScript binary object. Both buffers can have arbitray sizes to
fine-tune the decoding. Acutal values I used for a 56kbit/s stream with
a 44.1 khz sampling rate were 7KB for the input buffer and 30KB for
the output buffer. Total minimum memory requirements are currently about
50KB on the system heap, that can be reduced however by optimizing the
synthesizer part. How much space you want to allocate on the NS heap
really depends on the bit rate and sample rate of the incoming data and
the desired sound quality.

The API consists of four functions:
- Init: initializes the data structures and allocates the input buffer
on the system heap, returns a frame with pointers to the structures on
the C side.
- FillBuffer: fills the input buffer with a certain amount of MP3 data.
- Decode: as soon as the FillBuffer function fails, Decode can be called
to decode the data in the input buffer into a NS binary object (passed
in as a parameter). The input buffer will be cleared to accept new data
after Decode finished.
- Finish: releases the data structures on the system heap.

Now the important question: does it work? Yes. But there needs to be
work done on the output side. The PCM samples are now crudely rescaled
from 32 bit signed stereo to 16 bit unsigned mono and the sample rate is
divided by two. This can and should be made configurable. More important
seems to me a nice layer for feeding the samples to a sound channel,
ideally in batches of one to two second sized samples. Another problem
might be playing MP3 streams since the network layer of the Newton OS is
probably to slow for anything above 56kbit/s (unless you go down to the
driver level).

I still have to do some packaging but should be able to post at least
the source pretty soon.

Eckhart

-- 
                   -- eck_at_40hz.org -- www.40hz.org --

-- This is the Newtontalk mailinglist - http://www.newtontalk.net To unsubscribe or manage: visit the above link or mailto:newtontalk-request_at_newtontalk.net?Subject=unsubscribe



This archive was generated by hypermail 2.1.2 : Sat Dec 01 2001 - 20:02:15 EST