Discussion:
[mad-user] Decoding small blocks of data
p***@neocoder.net
2004-06-27 15:21:37 UTC
Permalink
Hi

I am trying to decode a mp3-file 100kB at a time.
My problem is that with each new block some errors occur
"Huffman data overrun"
"bad main_data_begin pointer"
"lost synchronization"

I'm not familiar with the mp3-format structure but i guess that the data in the file should be sent to the decoder in complete blocks.
I was hoping that the decoder would save incomplete data from the end of the previous buffer sent and join them with the next buffer sent. But it isn't ?

So if I want to decode small blocks of the file.
If I look through the file and only send complete blocks of data to the decoder.
Will this solve my problem?
Is it the way it is supposed to work?


Peter Hultqvist
***@neocoder.net
2004-06-27, 16:54:17
Jamie Wilkinson
2004-06-28 04:40:17 UTC
Permalink
Post by p***@neocoder.net
I am trying to decode a mp3-file 100kB at a time.
The core of the problem is that your mpeg frames may not be an integer
divisor of 100kB.
Post by p***@neocoder.net
I'm not familiar with the mp3-format structure but i guess that the data in the file should be sent to the decoder in complete blocks.
I was hoping that the decoder would save incomplete data from the end of the previous buffer sent and join them with the next buffer sent. But it isn't ?
Nah, you should do that yourself.
Post by p***@neocoder.net
So if I want to decode small blocks of the file.
If I look through the file and only send complete blocks of data to the decoder.
It's been a while since I wrote any code against libmad, but I'm pretty
sure you get back a count of how much data was eaten.

So, feed the decoder data until you've done 100kB and then finish the
frame. You get back a count of how much data was eaten and how much is
left in the buffer, and you can then feed that remaining data to the
decoder the next time around.
--
***@spacepants.org http://spacepants.org/jaq.gpg
Continue reading on narkive:
Loading...