[FFmpeg-devel] [PATCH] lavfi: reimplement MPlayer's af_pan filter for libavfilter.

Clément Bœsch ubitux at gmail.com
Thu Nov 17 12:12:30 CET 2011


On Thu, Nov 17, 2011 at 11:51:14AM +0100, Nicolas George wrote:
> From: Clément Bœsch <ubitux at gmail.com>
> 
> Original code by Clément Bœsch.
> Parameters parsing and misc enhancements by Nicolas George.
> 

I think you can just say "ported from MPlayer by Clément, and rewritten
from scratch by Nicolas" ;)

You did much more work on this than I do :)

> Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
> ---
>  Changelog                |    1 +
>  doc/filters.texi         |   48 +++++++
>  libavfilter/Makefile     |    1 +
>  libavfilter/af_pan.c     |  306 ++++++++++++++++++++++++++++++++++++++++++++++
>  libavfilter/allfilters.c |    1 +
>  5 files changed, 357 insertions(+), 0 deletions(-)
>  create mode 100644 libavfilter/af_pan.c
> 
> diff --git a/Changelog b/Changelog
> index a3d713e..b1d532b 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -122,6 +122,7 @@ easier to use. The changes are:
>  - VBLE Decoder
>  - OS X Video Decoder Acceleration (VDA) support
>  - compact and csv output in ffprobe
> +- pan audio filter
>  
>  
>  version 0.8:
> diff --git a/doc/filters.texi b/doc/filters.texi
> index 9fa9c04..d5c05b2 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -235,6 +235,54 @@ the listener (standard for speakers).
>  
>  Ported from SoX.
>  
> + at section pan
> +
> +Mix channels with specific gain levels. The filter accepts the output
> +channel layout followed by a set of channels definitions.
> +
> +The filter accepts parameters of the form:
> +"@var{l}:@var{outdef}:@var{outdef}:..."
> +
> + at table @option
> + at item l
> +output channel layout or number of channels
> +
> + at item outdef
> +output channel specification, of the form:
> +"@var{out_name}=[@var{gain}*]@var{in_name}[+[@var{gain}*]@var{in_name}...]"
> +
> + at item out_name
> +output channel to define, either a channel name (FL, FR, etc.) or a channel
> +number (c0, c1, etc.)
> +
> + at item gain
> +multiplicative coefficient for the channel, 1 leaving the volume unchanged
> +
> + at item in_name
> +input channel to use, see out_name for details; it is not possible to mix
> +named and numbered input channels
> + at end table
> +
> +If the `=' in a channel specification is replaced by `<', then the gains for
> +that specification will be renormalized so that the total is 1, thus
> +avoiding clipping noise.
> +
> +For example, if you want to down-mix from stereo to mono, but with a bigger
> +factor for the left channel:
> + at example
> +af pan=1:c0=0.9*c0+0.1*c1
> + at end example
> +
> +A customized down-mix to stereo that works automatically for 3-, 4-, 5- and
> +7-channels surround:
> + at example
> +pan=stereo:FL<FL+0.5*FC+0.6*BL+0.6*SL:FR<FR+0.5*FC+0.6*BR+0.6*SR
> + at end example
> +

Does the syntax allow some spacing? for instance between the ':'?

[...]
> +
> +/**
> + * @file
> + * Audio panning filter (channels mixing)
> + * Original code written by Anders Johansson for MPlayer,
> + * reimplemented for FFmpeg.
> + */
> +
> +#include <stdio.h>
> +#include "libavutil/audioconvert.h"
> +#include "libavutil/avstring.h"
> +#include "avfilter.h"
> +#include "internal.h"
> +
> +#define MAX_CHANNELS 63
> +

Any reason to go up to 63 ATM? I wonder if it wouldn't be wise to actually
increase the libswresample limit instead.

> +typedef struct {
> +    int64_t out_channel_layout;
> +    union {
> +        double d[MAX_CHANNELS][MAX_CHANNELS];
> +        // i is 1:7:8 fixed-point, i.e. in [-128*256; +128*256[

Thank you for keeping and improving such comment, it is useful for people
like me not familiar with these methods; I was afraid you'd remove it
after Stefano suggestion :)

Anyway, not much comment from me, it's a nice work overall, thank you :)

-- 
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20111117/b1a32577/attachment.asc>


More information about the ffmpeg-devel mailing list