Hi,
I was wondering if there was anything in the current libmad API for frame skipping? For example, skipping ahead 1,2, or 4 frames and same for rewind.
I understand I can do this directly on my stream but then what would be a clean way to update the mad_stream, and does it need updating? Or can I just call mad_stream_buffer() and it'll figure things out itself?
I checked the list archives but couldn't find exactly what I needed, sorry if this question is redudant, as I'm sure it is.
Thanks,
ani
On Tuesday, July 30, 2002, at 01:43 PM, ajoshi@kernel.crashing.org wrote:
I was wondering if there was anything in the current libmad API for frame skipping? For example, skipping ahead 1,2, or 4 frames and same for rewind.
I understand I can do this directly on my stream but then what would be a clean way to update the mad_stream, and does it need updating? Or can I just call mad_stream_buffer() and it'll figure things out itself?
For general seeking, you can just call mad_stream_buffer() with the location from which you want to continue decoding. For details and caveats, see:
http://www.mars.org/mailman/public/mad-dev/2001-August/000321.html
Using this method, it's not necessary to align your new seek position with a frame boundary; you can seek to any arbitrary byte and the decoder will automatically resync.
You can also seek forward a frame at a time just by calling mad_header_decode() in a loop without calling mad_frame_decode() or mad_synth_frame(). (Using the high-level API, return MAD_FLOW_IGNORE from your header callback.) This is fast because the full frame is not decoded and PCM samples are not synthesized. Unfortunately this API does not have an equivalent for seeking backwards.
If you want to keep track of frame boundaries for backward seeking, you can pull them from stream->this_frame and/or stream->next_frame as you decode each frame. These are pointers into your buffer passed to mad_stream_buffer(), so calculate offsets as appropriate if necessary.
-- Rob Leslie rob@mars.org