Add filter support to vorbis decoding
WHAT: Support for specifying a filter function when decoding a vorbis stream. The filter function can do anything to the stream, like for example applying ReplayGain.
WHEN: Done. Had been sitting on my disk for a couple of months now.
WHY: I wanted to add ReplayGain (VorbisGain) support to ogg123, and found that everything could be made remarkably simpler if we can have a filter function available.
HOW: See attached patch. It's quite simple, actually: Just create a function ov_read_filter() with the same parameters as ov_read() except that ov_read_filter() takes two extra arguments: a pointer to the filter function (filter()) and a pointer to the data to be passed to the filter function (filter_param). The filter function takes four arguments: 1. pointer to buffer containing the pcm samples in floating point format, 2. the number of channels, 3. the number of samples, and 4. the data (filter_param). The data passed in filter_param can be anything and is to be decided by the application. In my case, I used it to implement ReplayGain in ogg123 (the implementation is basically a much stripped-down version of vgplay).
WHO: Me. williampoetra at gmail dot com
I would love to see this patch merged. Comments and suggestion please.