Lars von Wedel
2004-Sep-10 16:47 UTC
[Flac-users] Extending mp3/ogg application to play flac
Hello, Flac is great and I have encoded all my "good" CDs into it! Now I want to extend an existing application able to decode mp3 and ogg vorbis to replay flac as well. It is a plugin to a set top box application on Linux (VDR). The existing code decodes into a mad_pcm structure using mad fixed point format (mad_fixed_t). I have read the API of libFlac++ and I understand what I have to do in general. However there are two issues I'm unsure about: - Do I need to convert the decoded audio data delivered to the FileDecoderWriteCallback to be compatible with mad_pcm/mad_fixed_t data? - The mad_pcm structure expects 1152 samples per channel. How Do I obtain 1152 samples from the Flac decoder? Any help is appreciated, Lars
Lars von Wedel
2004-Sep-10 16:47 UTC
[Flac-users] Extending mp3/ogg application to play flac
> not sure about the mad_fixed_t format, but probably. all> samples coming out of the FLAC decoder are linear PCM 32-bit > signed ints. e.g. a sample from CD audio will be in the > range -32768 (0xFFFF8000) to 32767 (0x00007FFF) Mad_fixed_t is defined as a 4-byte signed int in the headers. As the subsequent application seems to expect linear PCM, I'll simply give it a try... > since the write callback will be called once for each frame, > and the number of samples in a FLAC frame can vary, your > write callback will probably have to write to an > intermediate buffer. Okay, I had this in mind but wasn't sure. Thanks for the reference. Lars
Josh Coalson
2004-Sep-10 16:47 UTC
[Flac-users] Extending mp3/ogg application to play flac
--- Lars von Wedel <vonwedel@web.de> wrote:> However there are two issues I'm unsure about: > > - Do I need to convert the decoded audio data delivered to the > FileDecoderWriteCallback to be compatible with mad_pcm/mad_fixed_t > data?not sure about the mad_fixed_t format, but probably. all samples coming out of the FLAC decoder are linear PCM 32-bit signed ints. e.g. a sample from CD audio will be in the range -32768 (0xFFFF8000) to 32767 (0x00007FFF)> - The mad_pcm structure expects 1152 samples per channel. > How Do I obtain 1152 samples from the Flac decoder?since the write callback will be called once for each frame, and the number of samples in a FLAC frame can vary, your write callback will probably have to write to an intermediate buffer. the same thing has to happen in the winamp2 plugin, so you can look at that code for an example (search for reservoir_ and SAMPLES_PER_WRITE). http://cvs.sourceforge.net/viewcvs.py/flac/flac/src/plugin_winamp2/in_flac.c?view=markup Josh __________________________________ Do you Yahoo!? Yahoo! Mail - 50x more storage than other providers! http://promotions.yahoo.com/new_mail