[mad-dev] frame decoding questions
Sat, 25 May 2002 00:15:02 -0700 (PDT)
-----BEGIN PGP SIGNED MESSAGE-----
On Fri, 24 May 2002, Rob Leslie wrote:
> I'm not sure what units you're using, so to clarify: the number of samples
> per channel in a frame is generally
> 32 * MAD_NSBSAMPLES(&frame.header)
> however after synthesis it is best to use the value in synth.pcm.length
> instead. (The above expression is wrong if MAD_OPTION_HALFSAMPLERATE is in
Hmmm, basically I'm looking for the length in bytes. Since the bytes per
sample per channel is 2, then we get 64*NBSAMPLES*NCHANNELS. Or so I was
Since I'm seeking though the file to get the the spot the user has
requested, I don't want to be synthing data.
> > I think decode_frame returns -1 after I call decode_header. I'm not sure
> > if this the the behaviour to expect, or if I'm doing something wrong.
> Probably this is due to a real decoding error. If you're seeking around a
> Layer III stream, the bit reservoir may not have had an opportunity to be
> refilled, and it's normal to get errors on a few frames in this case.
So since I haven't decoded the last couple of frames, getting an error on
the first frame I decode in the middle of the stream is to be expeded?
Do you know how many frames back I would at most have to decode before I
can correctly decode my target frame? Do I need to synth those frames
So basically to do perfect seeking in MP3, I would have to skip though the
headers, and keep a point back n number of frames, until I find where I
want to be. Reinitalize mad_stream, etc. Seek the file to where my back
pointer is indicating. Decode n frames silently, and then start playing
at the appropriate place in the nth frame. Whew.
Russell O'Connor email@example.com
``Later generations will regard set theory as a disease from which one
has recovered.'' -- Poincare
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (SunOS)
Comment: For info see http://www.gnupg.org
-----END PGP SIGNATURE-----