[FFmpeg-devel] [RFC] libavfilter audio API and related issues

Michael Niedermayer michaelni
Mon Jun 7 01:00:45 CEST 2010


On Sat, Jun 05, 2010 at 01:24:35PM -0700, S.N. Hemanth Meenakshisundaram wrote:
> Michael Niedermayer <michaelni <at> gmx.at> writes:
> 
> >
> > On Wed, Jun 02, 2010 at 06:29:48AM +0000, S.N. Hemanth Meenakshisundaram
> wrote:
> > > Michael Niedermayer <michaelni <at> gmx.at> writes:
> > >
> > > >
> > > > On Sat, May 22, 2010 at 10:37:18PM -0700, S.N. Hemanth
> Meenakshisundaram wrote:
> > > > > On 05/02/2010 12:08 PM, Stefano Sabatini wrote:
> > > > >> On date Wednesday 2010-04-28 07:07:54 +0000, S.N. Hemanth
> > > > >> Meenakshisundaram encoded:
> > > > >>
> > > > >>> Stefano Sabatini<stefano.sabatini-lala<at>  poste.it>  writes:
> > > > >>>
> > > > >>>> Follow some notes about a possible design for the audio support in
> > > > >>>> libavfilter.
> > > > >>>>
> > > > >>>> AVFilterSamples struct
> > > > >>>> ======================
> > > > >>>>
> > > > >>>> (Already defined in afilters, but renamed AVFilterBuffer at some
> > > > >>>> point.)
> > > > >>>>
> > > > >>>> Follows a possible definition (with some differences whit
> respect to
> > > > >>>> that currently implemented in afilters):
> > > > >>>>
> > > > >>>>
> > > > >>> [...]
> > > > [...]
> > > >
> > >
> > > Hi All,
> > >
> > > I am working on the audio structures and functions. Keeping parameters
> like # of
> > > channels at the buffer level as Michael recommended above. [...]
> >
> 
> Hi All,
> 
> Attached is a rough draft of the audio API. I am now writing a simple
> volume scaling filter using this API. Please review and comment. Some
> observations:
> 
> 1. I am temporarily retaining the AVFilterPic struct as a separate struct
> for video and have introduced the AVFilterBuffer struct. The plan is to
> merge these two. AVFilterSamplesRef will reference this structure for
> audio.
> 
> 2. AVFilterSamplesRef has a lot of redundancy. E.g. 'size' is same as
> samples_nb*bytes_per_sample*num_channels and sampstep is the distance to
> next sample of same channel (for both planar and packed cases). This is to
> avoid recomputing sizes. Please let me know if its too redundant.
> 

> 3. data[8] will have the start addresses of the data for that buffer for
> up to 8 channels in case of planar. If packed, the entire buffer ptr is at
> data[0] and the rest are NULL.

it would be more usefull if the others pointed to the respective first sample
in packed too


[...]
>  /**
> + * A reference to an AVFilterBuffer for audio. Since filters can manipulate the
> + * origin of an audio buffer to, for example, reduce precision without any memcpy,
> + * sample format and channel_layout are per-reference properties. Sample step is
> + * also useful when reducing no. of channels, etc, and so is also per-reference.
> + */
> +typedef struct AVFilterSamplesRef
> +{
> +    AVFilterBuffer *buffer;       ///< the audio buffer that this is a reference to
> +    uint8_t *data[8];             ///< audio data for each channel
> +    int sampstep[8];              ///< number of bytes to next sample
> +
> +    int64_t channel_layout;       ///< channel layout of current buffer (see avcodec.h)
> +    int64_t sample_rate;          ///< samples per second
> +    enum SampleFormat sample_fmt; ///< sample format (see avcodec.h)
> +
> +    int samples_nb;               ///< number of samples in this buffer
> +    /* Should this go here or in the AVFilterBuffer struct? */
> +    int size;                     ///< size of buffer
> +
> +    int perms;                    ///< permissions
> +
> +    int planar;                   ///< is buffer planar or packed
> +} AVFilterSamplesRef;

pts & pos are missing
also common variables should be placed first so they can be used by common
code without requireing seperate audio & video paths


> +
> +/**
>   * Adds a new reference to a picture.
>   * @param ref   an existing reference to the picture
>   * @param pmask a bitmask containing the allowable permissions in the new
> @@ -138,6 +192,23 @@
>  void avfilter_unref_pic(AVFilterPicRef *ref);
>  
>  /**
> + * Adds a new reference to an audio samples buffer.
> + * @param ref   an existing reference to the buffer
> + * @param pmask a bitmask containing the allowable permissions in the new
> + *              reference
> + * @return      a new reference to the buffer with the same properties as the
> + *              old, excluding any permissions denied by pmask
> + */
> +AVFilterSamplesRef *avfilter_ref_samples(AVFilterSamplesRef *ref, int pmask);
> +
> +/**
> + * Removes a reference to a buffer of audio samples. If this is the last reference
> + * to the buffer, the buffer itself is also automatically freed.
> + * @param ref reference to the buffer
> + */
> +void avfilter_unref_samples(AVFilterSamplesRef *ref);
> +
> +/**
>   * A list of supported formats for one end of a filter link. This is used
>   * during the format negotiation process to try to pick the best format to
>   * use to minimize the number of necessary conversions. Each filter gives a

> @@ -180,16 +251,18 @@
>  typedef struct AVFilterFormats AVFilterFormats;
>  struct AVFilterFormats
>  {
> -    unsigned format_count;      ///< number of formats
> +    unsigned format_count;        ///< number of formats
> -    enum PixelFormat *formats;  ///< list of pixel formats
> +    enum PixelFormat *formats;    ///< list of pixel formats for video

ehm

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

It is not what we do, but why we do it that matters.
-------------- 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/20100607/33e5f2be/attachment.pgp>



More information about the ffmpeg-devel mailing list