[FFmpeg-devel] [PATCH] Add af_aconvert - sample fmt and channel layout conversion filter

Stefano Sabatini stefano.sabatini-lala
Sat Jan 15 19:55:20 CET 2011


On date Saturday 2011-01-15 02:37:50 +0100, Michael Niedermayer encoded:
> On Fri, Jan 14, 2011 at 10:08:53PM +0100, Stefano Sabatini wrote:
[...]
> > From 9b59d916568a885c5b2bceb4c61438a9ae1e7210 Mon Sep 17 00:00:00 2001
> > From: Stefano Sabatini <stefano.sabatini-lala at poste.it>
> > Date: Fri, 1 Oct 2010 14:58:22 +0200
> > Subject: [PATCH] Add af_aconvert - sample fmt and channel layout conversion filter.
> > 
> > Based on a patch by "S.N. Hemanth Meenakshisundaram" 5m33nak5 at uc5d.3du.
> > ---
> >  libavfilter/Makefile      |    1 +
> >  libavfilter/af_aconvert.c |  465 +++++++++++++++++++++++++++++++++++++++++++++
> >  libavfilter/allfilters.c  |    1 +
> >  3 files changed, 467 insertions(+), 0 deletions(-)
> >  create mode 100644 libavfilter/af_aconvert.c
[...]
> > +/**
> > + * All of the routines below are for packed audio data. SDL accepts packed data
> > + * only and current ffplay also assumes packed data only at all times.
> > + */
> > +
> > +/* Optimized stereo to mono and mono to stereo routines - common case */
> > +static void stereo_to_mono(uint8_t *out[], uint8_t *in[], int nb_samples, int in_channels)
> > +{
> > +    uint16_t *input  = (uint16_t *) in[0];
> > +    uint16_t *output = (uint16_t *) out[0];
> 
> most of these should probably be int16_t not uint16_t

Fixed.

> > +/**
> > + * This is for when we have more than 2 input channels, need to downmix to mono
> > + * and do not have a conversion formula available.  We just use first two input
> > + * channels - left and right. This is a placeholder until more conversion
> > + * functions are written.
> > + */
> > +static void mono_downmix(uint8_t *out[], uint8_t *in[], int nb_samples, int in_channels)
> > +{
> > +    int i;
> 
> > +    uint16_t *input  = (short *) in[0];
> 
> this is definitly wrong

short -> int16_t

> > +    uint16_t *output = (uint16_t *) out[0];
> 
> > +    uint16_t left, right;
> 
> int

Fixed.

> > +
> > +    for (i = 0; i < nb_samples; i++) {
> > +        left = *input++;
> > +        right = *input++;
> > +        *output++ = (left+right)>>1;
> > +        input += in_channels-2;
> > +    }
> > +}
> > +
> > +/* Stereo to 5.1 output */
> > +static void ac3_5p1_mux(uint8_t *out[], uint8_t *in[], int nb_samples, int in_channels)
> > +{
> > +    int i;
> > +    uint16_t *output = (uint16_t *) out[0];
> > +    uint16_t *input = (uint16_t *) in[0];
> 
> > +    uint16_t left, right;
> 
> int

Fixed.

[...]

Updated with more simplifications (one functions for sample format
conversion rather than two) now the patch is 40 lines shorter, other
cosmetics and fixed query_formats().

Regards.
-- 
FFmpeg = Fantastic and Frenzy Minimalistic Proud Entertaining God



More information about the ffmpeg-devel mailing list