[vorbis-dev] float to PCM packing in libvorbisfile
John Morton
jwm at eslnz.co.nz
Wed Apr 30 19:18:33 PDT 2003
On Thu, 01 May 2003 13:31, Michael Smith wrote:
> John Morton <jwm at eslnz.co.nz> said:
> > Is there any particular reason why ov_read() packs floats to integer PCM
> > inline, rather than being implemented in terms of ov_read_float() and a
> > separate packing fucntion?
>
> Historical reasons, mostly. ov_read() existed long before ov_read_float()
> did. There's no compelling reason to change it.
Thought so.
> > There are obviously many advantages doing audio manipulation on the
> > floats before packing, but right now you have to reinvent the packing
> > stage yourself - in a replaygain backend that I'm working on, I ended up
> > copying the packing code from ov_read verbatim. Would a patch that split
> > the packing out to a separate function be considered for inclusion in a
> > future libvorbis release?
> Well, ov_read() does this packing for you as a convenience, but providing
> it seperately is really going beyond what vorbisfile is for - it's a
> library for decoding vorbis, not a library of generic audio manipulation
> functions. My opinion is that this wouldn't really be suitable for going
> into libvorbisfile. It's not exactly complex code (since for most purposes
> you don't care about things like 8 bit output, signed/unsigned options,
> etc, it's trivial to reimplement the bits of interest).
However, the devil is in the details - the code in ov_read looks like some
time has been taken to optimise it, and the header file is full of hacks to
make float to int conversion behave itself under several arch/os/compiler
combinations. It would suck to have to reimpliment this just to get
replaygain, a preamp, limiting or other not uncommon player features to work,
when the code is already in libvorbisfile in one form. Additionally,
converting audio from float to int seems to be fairly peculiar to vorbis (at
least, in the context of common audio decoders).
Suppose I wrote and tested a patch to move float to pcm packing out of the
inside of ov_read, making as little change to the API as possible. Would you
be interested in entertaining the idea of future inclusion?
John
--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'vorbis-dev-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the Vorbis-dev
mailing list