[FFmpeg-devel] [RFC] lavc/ffmpeg sample_fmt implementation

Michael Niedermayer michaelni
Sat Jul 26 11:33:32 CEST 2008


On Sat, Jul 26, 2008 at 12:42:26PM +1000, pross at xvid.org wrote:
> On Fri, Jul 25, 2008 at 11:32:33PM +0200, Michael Niedermayer wrote:
> > On Sat, Jul 26, 2008 at 01:08:09AM +1000, pross at xvid.org wrote:
> > > Hi.
> > > 
> > > This patch adds sample_fmt conversion support to lavc (and ffmpeg).
> > > 
> > > The sample_fmt behavior is modelled on pix_fmt. Codecs will need minor
> > > modification to support sample_fmt correctly. Namely, decoders need to
> > > report their output sample format, and encoders validate the input sample
> > > format (or publish a list of supported formats via the AVCodec struct).
> > > The PCM codecs are modified in this patch, and the more useful ones have
> > > been tested.
> > 
> > First id like to say that iam very happy that someone is finally working
> > on the sample_fmt issue :)
> > 
> > now the review ...
> 
> > > +        if (av_audio_convert(NULL, obuf, ostride, enc->sample_fmt,
> > > +                                   ibuf, istride, dec->sample_fmt, len)<0) {
> > 
> > this definitly needs a context, otherwise we might end in a situation
> > similar to the current swscale vs. img convert. That is a future context
> > based converter would require its context to be created and destroyed
> > on each such call to emulate the API ...
> 
> Would something like this suffice?
> 
> struct AVAudioConvert;
> struct AVAudioConvert *av_audio_convert_alloc(SampleFormat in_fmt, SampleFormat out_fmt, int dsp_mask);

s/dsp_mask/flags/ (we might want other flags as well)
i also would add the number of src and dst channels.
And a matrix of coeffs to convert between different channel numbers 
(theres no need at all to do anything with that in the code, i just think
it could be added to the API.)

The reason why i suggest to make the sample format convertion merged with
channel num convertion is simply that later is hard to use if the input
and output sample formats mismatch what the code expects.

the matrix could be int values that store 8.24 fixed point values or float.
(iam not sure which is better ...)


> void av_audio_convert_free(AVAudioConvert *acvt);
> void av_audio_convert(AVAudioContext *avct,
>                       void *out[6], int out_stride[6],
>                        void *in[6], int in_stride[6], int len);

the in should be an array of const pointers maybe
also the stride arrays might be made const to makeit clear that the function
does not modify them

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The misfortune of the wise is better than the prosperity of the fool.
-- Epicurus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080726/ab743008/attachment.pgp>



More information about the ffmpeg-devel mailing list