Re: Synchronization error near the end of file
Rob Leslie <[email protected]> Wed, 14 Sep 2005 19:16:19 -0700
| Newsgroups | gmane.comp.audio.mad.devel |
|---|---|
| Message-ID | <[email protected]> |
On Sep 14, 2005, at 3:40 AM, Marcello Maggioni wrote: > I'm tring to get started with "libmad" so I've tried to make an > application very similar to "minimad.c" , the one included in the > source code, only that instead of reading and writing from STDIN to > STDOUT it reads and writes from and to files. > > The problem that I get is that I get a strange synchronization > error near the end of the file : > > Decoding /balthasar/****.mp3 > 0 <-- ID3Tad size > decoding error 0x0101 (lost synchronization) at byte offset 3072836 > > > The actual size of the file is : 3072949 > > I get this almost with every file I try to decode. > > I manage the input by creating with "malloc()" a memory area of > "unsigned chars" of the size of the file , then I fread the mp3 > file into memory and pass the pointer to the callback input function . > > I miss something or I made any mistakes? Try this: when you call malloc(), allocate MAD_BUFFER_GUARD extra bytes at the end and fill them with zero bytes. This will allow the decoder to fully decode the last frame. > PS= Do you know how to check the correctness of a Raw 16bit PCM > stream?? I've tried to play my file with many players , but it > doesn't work. Sorry but I'm a newbie of digital audio :) You might want to prepend a WAV or AIFF header to the raw PCM so that other applications can understand the data. See the audio_wave.c and audio_aiff.c files from madplay for an example. -- Rob Leslie [email protected]