Re: [FFmpeg-devel] [PATCH] avfilter: add hrtfm filter

2018-03-23 Thread Lou Logan
On Tue, Mar 20, 2018, at 1:20 AM, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol 
> ---
>  doc/filters.texi |  66 ++
>  libavfilter/Makefile |   1 +
>  libavfilter/af_hrtfm.c   | 557 
> +++
>  libavfilter/allfilters.c |   1 +
>  4 files changed, 625 insertions(+)
>  create mode 100644 libavfilter/af_hrtfm.c
> 
> diff --git a/doc/filters.texi b/doc/filters.texi
> index bd43a7ac6e..95950f7666 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
[...]
> +@item amin
> +Set minimum alfa. Default value is @code{0.05}.

"alfa" typo again (libavfilter/af_anequalizer.c also has this odd spelling).

I didn't see any replies regarding the alternative option names that I 
mentioned twice so I'll assume that means "no".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter: add hrtfm filter

2018-03-23 Thread Michael Niedermayer
On Fri, Mar 23, 2018 at 02:45:06PM +0100, Aurelien Jacobs wrote:
> On Fri, Mar 23, 2018 at 10:18:47AM +0100, Paul B Mahol wrote:
> > On 3/22/18, Aurelien Jacobs  wrote:
> > > On Mon, Mar 19, 2018 at 10:49:28PM -0800, Lou Logan wrote:
> > >> On Fri, Mar 16, 2018, at 11:44 AM, Paul B Mahol wrote:
> > >> > Signed-off-by: Paul B Mahol 
> > >> > ---
> > >> >  doc/filters.texi |  60 ++
> > >> >  libavfilter/Makefile |   1 +
> > >> >  libavfilter/af_hrtfm.c   | 486
> > >> >  +++>
> > >> > libavfilter/allfilters.c |   1 +
> > >> >  4 files changed, 548 insertions(+)
> > >> >  create mode 100644 libavfilter/af_hrtfm.c
> > >> >
> > >> > diff --git a/doc/filters.texi b/doc/filters.texi
> > >> > index bd43a7ac6e..c298054325 100644
> > >> > --- a/doc/filters.texi
> > >> > +++ b/doc/filters.texi
> > >> > @@ -3218,6 +3218,66 @@ Change highpass width.
> > >> >  Syntax for the command is : "@var{width}"
> > >> >  @end table
> > >> >
> > >> > +@section hrtfm
> > >> > +
> > >> > +Apply simple Head Related Transfer Function Model to audio stream.
> > >> > +
> > >> > +hrtfm filter creates virtual loudspeakers around the user for
> > >> > binaural> +listening via headphones (audio formats up to 9 channels
> > >> > supported).> +
> > >> > +This is very simple implementation which does not use any HRIRs.
> > >> > +
> > >> > +It accepts the following parameters:
> > >> > +
> > >> > +@table @option
> > >> > +@item hradius
> > >>
> > >> You didn't like the head_radius option name suggestion?
> > >>
> > >> > +Set head radius of listener. In meters. Default value is
> > >> > @code{0.0891}.
> > >> Why meters instead of cm?
> > >
> > > Because if you want to specify centimeters, you can use the option
> > > like this: -hradius 8.91c
> > 
> > Shouldn't it be 8.91cm?
> 
> Ideally it should yes.
> But currently the option system does not support units. It would be
> great to specify that this option is representing a length so that the
> parser could validate the unit and take it into account.

> But for now, options are unit-less numbers.
> You can't use "-bitrate 128kb/s", but you are instead limited to
> "-bitrate 128k" without specifying unit. Same for hradius for which
> you can use 8.91c but not 8.91cm.

AVOption does have a unit field.
Its currently used for named constants only. But i guess this could be
extended

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

During times of universal deceit, telling the truth becomes a
revolutionary act. -- George Orwell


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter: add hrtfm filter

2018-03-23 Thread Aurelien Jacobs
On Fri, Mar 23, 2018 at 10:18:47AM +0100, Paul B Mahol wrote:
> On 3/22/18, Aurelien Jacobs  wrote:
> > On Mon, Mar 19, 2018 at 10:49:28PM -0800, Lou Logan wrote:
> >> On Fri, Mar 16, 2018, at 11:44 AM, Paul B Mahol wrote:
> >> > Signed-off-by: Paul B Mahol 
> >> > ---
> >> >  doc/filters.texi |  60 ++
> >> >  libavfilter/Makefile |   1 +
> >> >  libavfilter/af_hrtfm.c   | 486
> >> >  +++>
> >> > libavfilter/allfilters.c |   1 +
> >> >  4 files changed, 548 insertions(+)
> >> >  create mode 100644 libavfilter/af_hrtfm.c
> >> >
> >> > diff --git a/doc/filters.texi b/doc/filters.texi
> >> > index bd43a7ac6e..c298054325 100644
> >> > --- a/doc/filters.texi
> >> > +++ b/doc/filters.texi
> >> > @@ -3218,6 +3218,66 @@ Change highpass width.
> >> >  Syntax for the command is : "@var{width}"
> >> >  @end table
> >> >
> >> > +@section hrtfm
> >> > +
> >> > +Apply simple Head Related Transfer Function Model to audio stream.
> >> > +
> >> > +hrtfm filter creates virtual loudspeakers around the user for
> >> > binaural> +listening via headphones (audio formats up to 9 channels
> >> > supported).> +
> >> > +This is very simple implementation which does not use any HRIRs.
> >> > +
> >> > +It accepts the following parameters:
> >> > +
> >> > +@table @option
> >> > +@item hradius
> >>
> >> You didn't like the head_radius option name suggestion?
> >>
> >> > +Set head radius of listener. In meters. Default value is
> >> > @code{0.0891}.
> >> Why meters instead of cm?
> >
> > Because if you want to specify centimeters, you can use the option
> > like this: -hradius 8.91c
> 
> Shouldn't it be 8.91cm?

Ideally it should yes.
But currently the option system does not support units. It would be
great to specify that this option is representing a length so that the
parser could validate the unit and take it into account.
But for now, options are unit-less numbers.
You can't use "-bitrate 128kb/s", but you are instead limited to
"-bitrate 128k" without specifying unit. Same for hradius for which
you can use 8.91c but not 8.91cm.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter: add hrtfm filter

2018-03-23 Thread Paul B Mahol
On 3/22/18, Aurelien Jacobs  wrote:
> On Mon, Mar 19, 2018 at 10:49:28PM -0800, Lou Logan wrote:
>> On Fri, Mar 16, 2018, at 11:44 AM, Paul B Mahol wrote:
>> > Signed-off-by: Paul B Mahol 
>> > ---
>> >  doc/filters.texi |  60 ++
>> >  libavfilter/Makefile |   1 +
>> >  libavfilter/af_hrtfm.c   | 486
>> >  +++>
>> > libavfilter/allfilters.c |   1 +
>> >  4 files changed, 548 insertions(+)
>> >  create mode 100644 libavfilter/af_hrtfm.c
>> >
>> > diff --git a/doc/filters.texi b/doc/filters.texi
>> > index bd43a7ac6e..c298054325 100644
>> > --- a/doc/filters.texi
>> > +++ b/doc/filters.texi
>> > @@ -3218,6 +3218,66 @@ Change highpass width.
>> >  Syntax for the command is : "@var{width}"
>> >  @end table
>> >
>> > +@section hrtfm
>> > +
>> > +Apply simple Head Related Transfer Function Model to audio stream.
>> > +
>> > +hrtfm filter creates virtual loudspeakers around the user for
>> > binaural> +listening via headphones (audio formats up to 9 channels
>> > supported).> +
>> > +This is very simple implementation which does not use any HRIRs.
>> > +
>> > +It accepts the following parameters:
>> > +
>> > +@table @option
>> > +@item hradius
>>
>> You didn't like the head_radius option name suggestion?
>>
>> > +Set head radius of listener. In meters. Default value is
>> > @code{0.0891}.
>> Why meters instead of cm?
>
> Because if you want to specify centimeters, you can use the option
> like this: -hradius 8.91c

Shouldn't it be 8.91cm?

> The only way for SI prefix to make sense is to have the options
> expressed in the base unit.
> So I think hradius should be expressed in meters and every new options
> should always be expressed in their base unit.
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter: add hrtfm filter

2018-03-22 Thread Aurelien Jacobs
On Mon, Mar 19, 2018 at 10:49:28PM -0800, Lou Logan wrote:
> On Fri, Mar 16, 2018, at 11:44 AM, Paul B Mahol wrote:
> > Signed-off-by: Paul B Mahol 
> > ---
> >  doc/filters.texi |  60 ++
> >  libavfilter/Makefile |   1 +
> >  libavfilter/af_hrtfm.c   | 486
> >  +++>  libavfilter/allfilters.c 
> > |   1 +
> >  4 files changed, 548 insertions(+)
> >  create mode 100644 libavfilter/af_hrtfm.c
> >
> > diff --git a/doc/filters.texi b/doc/filters.texi
> > index bd43a7ac6e..c298054325 100644
> > --- a/doc/filters.texi
> > +++ b/doc/filters.texi
> > @@ -3218,6 +3218,66 @@ Change highpass width.
> >  Syntax for the command is : "@var{width}"
> >  @end table
> > 
> > +@section hrtfm
> > +
> > +Apply simple Head Related Transfer Function Model to audio stream.
> > +
> > +hrtfm filter creates virtual loudspeakers around the user for
> > binaural> +listening via headphones (audio formats up to 9 channels 
> > supported).> +
> > +This is very simple implementation which does not use any HRIRs.
> > +
> > +It accepts the following parameters:
> > +
> > +@table @option
> > +@item hradius
> 
> You didn’t like the head_radius option name suggestion?
> 
> > +Set head radius of listener. In meters. Default value is
> > @code{0.0891}.
> Why meters instead of cm? 

Because if you want to specify centimeters, you can use the option
like this: -hradius 8.91c
The only way for SI prefix to make sense is to have the options
expressed in the base unit.
So I think hradius should be expressed in meters and every new options
should always be expressed in their base unit.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter: add hrtfm filter

2018-03-20 Thread Nicolas George
Paul B Mahol (2018-03-19):
> I'm not aware of such policy.

Patches should be reviewed on the mailing list, that is the general
policy and I am pretty sure you know about it. The only exception is
normally very simple and urgent patches by the maintainer themselves. If
the patch you push is not the same as the one you posted on the
mailing-list, then it has not been reviewed.

Thanks for posting the updated version.

Regards,

-- 
  Nicolas George


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] avfilter: add hrtfm filter

2018-03-20 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 doc/filters.texi |  66 ++
 libavfilter/Makefile |   1 +
 libavfilter/af_hrtfm.c   | 557 +++
 libavfilter/allfilters.c |   1 +
 4 files changed, 625 insertions(+)
 create mode 100644 libavfilter/af_hrtfm.c

diff --git a/doc/filters.texi b/doc/filters.texi
index bd43a7ac6e..95950f7666 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -3218,6 +3218,72 @@ Change highpass width.
 Syntax for the command is : "@var{width}"
 @end table
 
+@section hrtfm
+
+Apply simple Head Related Transfer Function Model to audio stream.
+
+hrtfm filter creates virtual loudspeakers around the user for binaural
+listening via headphones (audio formats up to 9 channels supported).
+
+This is very simple implementation which does not use any HRIRs.
+
+It accepts the following parameters:
+
+@table @option
+@item hradius
+Set head radius of listener. In centimeters. Default value is @code{8.91}.
+
+@item sspeed
+Set sound speed in meters per second. Default value is @code{334}.
+Allowed range is from @code{300} to @code{400}.
+
+@item amin
+Set minimum alfa. Default value is @code{0.05}.
+Allowed range is from @code{0.001} to @code{1}.
+
+@item gain
+Set output gain in dB. Default value is @code{0}.
+Allowed range is from @code{-40} to @code{40}.
+
+@item rotation
+Set rotation of virtual loudspeakers in degrees. Default is @code{0}.
+Allowed range is from @code{-180} to @code{180}.
+
+@item elevation
+Set elevation of virtual speakers in degrees. Default is @code{0}.
+Allowed range is from @code{-90} to @code{90}.
+
+@item speakers
+Set custom positions of virtual loudspeakers. Syntax for this option is:
+  [|  |...].
+Each virtual loudspeaker is described with short channel name following with
+azimuth and elevation in degrees.
+Each virtual loudspeaker description is separated by '|'.
+For example to override front left and front right channel positions use:
+'speakers=FL 45 15|FR 345 15'.
+Descriptions with unrecognised channel names are ignored.
+
+@item lfegain
+Set LFE gain in dB. Default value is @code{0}.
+Allowed range is from @code{-40} to @code{40}.
+@end table
+
+@subsection Examples
+
+@itemize
+@item
+Apply filter with custom head radius, speed of sound and minimum alpha:
+@example
+hrtfm=hradius=0.09:sspeed=334:amin=0.001
+@end example
+
+@item
+Similar as above but also with custom speaker positions:
+@example
+"hrtfm=0.1:334:0.001:speakers=FL -15|FR 15|BL -160|BR 160|SL -80|SR 80"
+@end example
+@end itemize
+
 @section join
 
 Join multiple input streams into one multi-channel stream.
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index fc16512e2c..65783a8443 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -99,6 +99,7 @@ OBJS-$(CONFIG_HAAS_FILTER)   += af_haas.o
 OBJS-$(CONFIG_HDCD_FILTER)   += af_hdcd.o
 OBJS-$(CONFIG_HEADPHONE_FILTER)  += af_headphone.o
 OBJS-$(CONFIG_HIGHPASS_FILTER)   += af_biquads.o
+OBJS-$(CONFIG_HRTFM_FILTER)  += af_hrtfm.o
 OBJS-$(CONFIG_JOIN_FILTER)   += af_join.o
 OBJS-$(CONFIG_LADSPA_FILTER) += af_ladspa.o
 OBJS-$(CONFIG_LOUDNORM_FILTER)   += af_loudnorm.o ebur128.o
diff --git a/libavfilter/af_hrtfm.c b/libavfilter/af_hrtfm.c
new file mode 100644
index 00..9f35b1cb9b
--- /dev/null
+++ b/libavfilter/af_hrtfm.c
@@ -0,0 +1,557 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/avstring.h"
+#include "libavutil/ffmath.h"
+#include "libavutil/opt.h"
+
+#include "audio.h"
+#include "avfilter.h"
+#include "internal.h"
+
+#define CHPARAMS(name, type)   \
+typedef struct ChParams_## name {  \
+type azim; \
+type elev; \
+   \
+type Al[2], Bl[2], al[2], bl[2];   \
+type Ar[2], Br[2], ar[2], br[2];   \
+   \
+type gain[2];  \
+   \
+type *delayed_samples[2];  \
+int delayed_index[2];  \
+   \
+type cache1_in[2];  

Re: [FFmpeg-devel] [PATCH] avfilter: add hrtfm filter

2018-03-20 Thread Lou Logan
On Fri, Mar 16, 2018, at 11:44 AM, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol 
> ---
>  doc/filters.texi |  60 ++
>  libavfilter/Makefile |   1 +
>  libavfilter/af_hrtfm.c   | 486
>  +++>  libavfilter/allfilters.c | 
>   1 +
>  4 files changed, 548 insertions(+)
>  create mode 100644 libavfilter/af_hrtfm.c
>
> diff --git a/doc/filters.texi b/doc/filters.texi
> index bd43a7ac6e..c298054325 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -3218,6 +3218,66 @@ Change highpass width.
>  Syntax for the command is : "@var{width}"
>  @end table
> 
> +@section hrtfm
> +
> +Apply simple Head Related Transfer Function Model to audio stream.
> +
> +hrtfm filter creates virtual loudspeakers around the user for
> binaural> +listening via headphones (audio formats up to 9 channels 
> supported).> +
> +This is very simple implementation which does not use any HRIRs.
> +
> +It accepts the following parameters:
> +
> +@table @option
> +@item hradius

You didn’t like the head_radius option name suggestion?

> +Set head radius of listener. In meters. Default value is
> @code{0.0891}.
Why meters instead of cm? 

> +@item sspeed

No sound_speed option name?

> +Set sound speed in meters per second. Default value is @code{334}.
> +Allowed range is from @code{300} to @code{400}.
> +
> +@item amin
> +Set minimum alfa. Default value is @code{0.05}.

s/alfa/alpha

> +Allowed range is from @code{0.01} to @code{1}.
> +
> +@item gain
> +Set output gain in dB. Default value is @code{0}.
> +Allowed range is from @code{-20} to @code{40}.
> +
> +@item rotation
> +Set rotation of virtual loudspeakers in deg. Default is @code{0}.

s/deg/degrees

> +Allowed range is from @code{-360} to @code{360}.
> +
> +@item elevation
> +Set elevation of virtual speakers in deg. Default is @code{0}.

s/deg/degrees

> +Allowed range is from @code{-90} to @code{90}.
> +
> +@item speakers
> +Set custom positions of virtual loudspeakers. Syntax for this
> option is:> +  [|  |...].

Could use some sort of texinfo formatting. 

> +Each virtual loudspeaker is described with short channel name
> following with> +azimuth and elevation in degrees.
> +Each virtual loudspeaker description is separated by '|'.
> +For example to override front left and front right channel
> positions use:> +'speakers=FL 45 15|FR 345 15'.

Same as above. 

> +Descriptions with unrecognised channel names are ignored.
> +
> +@item lfegain
> +Set LFE gain in dB. Default value is @code{0}.
> +Allowed range is from @code{-11} to @code{11}.
> +@end table
> +
> +@subsection Examples
> +
> +@itemize
> +@item
> +Apply filter with custom head radius, speed of sound and
> minimum alpha:> +@example
> +hrtfm=hradius=0.09:sspeed=334:amin=0.01
> +@end example
> +@end itemize
> +

Thanks for the example. No other comments from me. 
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter: add hrtfm filter

2018-03-19 Thread Paul B Mahol
On 3/19/18, Nicolas George  wrote:
> Paul B Mahol (2018-03-19):
>> No I will not!
>
> Changes are to be sent to the mailing-list, that is the policy. You are
> not allowed to change it unilaterally.

I'm not aware of such policy.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter: add hrtfm filter

2018-03-19 Thread Nicolas George
Paul B Mahol (2018-03-19):
> No I will not!

Changes are to be sent to the mailing-list, that is the policy. You are
not allowed to change it unilaterally.

Regards,

-- 
  Nicolas George


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter: add hrtfm filter

2018-03-19 Thread Paul B Mahol
On 3/19/18, Nicolas George  wrote:
> Paul B Mahol (2018-03-19):
>> If there are no more comments, I would like to push
>> an improved version of this.
>
> If it is changed compared to what was sent to the mailing-list, re-send
> it to the mailing-list.

No I will not! And what can you do to me?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter: add hrtfm filter

2018-03-19 Thread Nicolas George
Paul B Mahol (2018-03-19):
> If there are no more comments, I would like to push
> an improved version of this.

If it is changed compared to what was sent to the mailing-list, re-send
it to the mailing-list.

Regards,

-- 
  Nicolas George


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter: add hrtfm filter

2018-03-19 Thread Paul B Mahol
On 3/16/18, Paul B Mahol  wrote:
> Signed-off-by: Paul B Mahol 
> ---
>  doc/filters.texi |  60 ++
>  libavfilter/Makefile |   1 +
>  libavfilter/af_hrtfm.c   | 486
> +++
>  libavfilter/allfilters.c |   1 +
>  4 files changed, 548 insertions(+)
>  create mode 100644 libavfilter/af_hrtfm.c
>

If there are no more comments, I would like to push
an improved version of this.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] avfilter: add hrtfm filter

2018-03-16 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 doc/filters.texi |  60 ++
 libavfilter/Makefile |   1 +
 libavfilter/af_hrtfm.c   | 486 +++
 libavfilter/allfilters.c |   1 +
 4 files changed, 548 insertions(+)
 create mode 100644 libavfilter/af_hrtfm.c

diff --git a/doc/filters.texi b/doc/filters.texi
index bd43a7ac6e..c298054325 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -3218,6 +3218,66 @@ Change highpass width.
 Syntax for the command is : "@var{width}"
 @end table
 
+@section hrtfm
+
+Apply simple Head Related Transfer Function Model to audio stream.
+
+hrtfm filter creates virtual loudspeakers around the user for binaural
+listening via headphones (audio formats up to 9 channels supported).
+
+This is very simple implementation which does not use any HRIRs.
+
+It accepts the following parameters:
+
+@table @option
+@item hradius
+Set head radius of listener. In meters. Default value is @code{0.0891}.
+
+@item sspeed
+Set sound speed in meters per second. Default value is @code{334}.
+Allowed range is from @code{300} to @code{400}.
+
+@item amin
+Set minimum alfa. Default value is @code{0.05}.
+Allowed range is from @code{0.01} to @code{1}.
+
+@item gain
+Set output gain in dB. Default value is @code{0}.
+Allowed range is from @code{-20} to @code{40}.
+
+@item rotation
+Set rotation of virtual loudspeakers in deg. Default is @code{0}.
+Allowed range is from @code{-360} to @code{360}.
+
+@item elevation
+Set elevation of virtual speakers in deg. Default is @code{0}.
+Allowed range is from @code{-90} to @code{90}.
+
+@item speakers
+Set custom positions of virtual loudspeakers. Syntax for this option is:
+  [|  |...].
+Each virtual loudspeaker is described with short channel name following with
+azimuth and elevation in degrees.
+Each virtual loudspeaker description is separated by '|'.
+For example to override front left and front right channel positions use:
+'speakers=FL 45 15|FR 345 15'.
+Descriptions with unrecognised channel names are ignored.
+
+@item lfegain
+Set LFE gain in dB. Default value is @code{0}.
+Allowed range is from @code{-11} to @code{11}.
+@end table
+
+@subsection Examples
+
+@itemize
+@item
+Apply filter with custom head radius, speed of sound and minimum alpha:
+@example
+hrtfm=hradius=0.09:sspeed=334:amin=0.01
+@end example
+@end itemize
+
 @section join
 
 Join multiple input streams into one multi-channel stream.
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index fc16512e2c..65783a8443 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -99,6 +99,7 @@ OBJS-$(CONFIG_HAAS_FILTER)   += af_haas.o
 OBJS-$(CONFIG_HDCD_FILTER)   += af_hdcd.o
 OBJS-$(CONFIG_HEADPHONE_FILTER)  += af_headphone.o
 OBJS-$(CONFIG_HIGHPASS_FILTER)   += af_biquads.o
+OBJS-$(CONFIG_HRTFM_FILTER)  += af_hrtfm.o
 OBJS-$(CONFIG_JOIN_FILTER)   += af_join.o
 OBJS-$(CONFIG_LADSPA_FILTER) += af_ladspa.o
 OBJS-$(CONFIG_LOUDNORM_FILTER)   += af_loudnorm.o ebur128.o
diff --git a/libavfilter/af_hrtfm.c b/libavfilter/af_hrtfm.c
new file mode 100644
index 00..a9ac95f9a5
--- /dev/null
+++ b/libavfilter/af_hrtfm.c
@@ -0,0 +1,486 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/avstring.h"
+#include "libavutil/ffmath.h"
+#include "libavutil/opt.h"
+
+#include "audio.h"
+#include "avfilter.h"
+#include "internal.h"
+
+typedef struct ChParams {
+float azim; /* azimuth of the virtual loudspeakers */
+float elev; /* elevation of the virtual loudspeakers */
+int lfe;
+
+float Al[2], Bl[2], al[2], bl[2];
+float Ar[2], Br[2], ar[2], br[2];
+
+float gain[2];
+int M[2];
+
+float *delayed_samples[2];
+int delayed_index[2];
+
+float cache1_in[2];
+float cache1_out[2];
+
+float cache2_in[2];
+float cache2_out[2];
+} ChParams;
+
+typedef struct VirtualSpeaker {
+uint8_t set;
+float azim;
+float elev;
+} VirtualSpeaker;
+
+typedef struct HRTFMContext {
+const AVClass *class;
+
+float sspeed;
+float hradius;
+float alfa_min;
+float gain;  /* filter gain (in dB) */
+float lfe_gain;

Re: [FFmpeg-devel] [PATCH] avfilter: add hrtfm filter

2018-03-16 Thread Lou Logan
On Thu, 15 Mar 2018 18:54:00 +0100
Paul B Mahol  wrote:

[...]
> diff --git a/libavfilter/af_hrtfm.c b/libavfilter/af_hrtfm.c
> new file mode 100644
> index 00..48536edd4b
> --- /dev/null
> +++ b/libavfilter/af_hrtfm.c
[...]
> +static const AVOption hrtfm_options[] = {
> +{ "hradius",   "set head radius", OFFSET(hradius),   AV_OPT_TYPE_FLOAT,  
> {.dbl=0.0891},0.01,0.2, .flags = FLAGS },

I'd like to see more descriptive option names with the shorter name left as
an alias if desired.

{ "head_radius",   "set head radius", OFFSET(head_radius),   AV_OPT_TYPE_FLOAT, 
 {.dbl=0.0891},0.01,0.2, .flags = FLAGS },
{ "hradius",   "set head radius", OFFSET(head_radius),   AV_OPT_TYPE_FLOAT,  
{.dbl=0.0891},0.01,0.2, .flags = FLAGS },

> +{ "sspeed","set sound speed", OFFSET(sspeed),AV_OPT_TYPE_FLOAT,  
> {.dbl=334},   300, 400, .flags = FLAGS },

Same here. sound_speed

Missing docs, and also please provide an example in the docs. Many of
our filters are missing examples.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter: add hrtfm filter

2018-03-16 Thread Paul B Mahol
On 3/16/18, Derek Buitenhuis  wrote:
> On 3/15/2018 5:54 PM, Paul B Mahol wrote:
>> Signed-off-by: Paul B Mahol 
>> ---
>>  libavfilter/Makefile |   1 +
>>  libavfilter/af_hrtfm.c   | 477
>> +++
>>  libavfilter/allfilters.c |   1 +
>>  3 files changed, 479 insertions(+)
>>  create mode 100644 libavfilter/af_hrtfm.c
>
> Because we all know what HRTFM means immediately, so we don't need
> any doc.

Google is always your friend.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter: add hrtfm filter

2018-03-16 Thread Derek Buitenhuis
On 3/15/2018 5:54 PM, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol 
> ---
>  libavfilter/Makefile |   1 +
>  libavfilter/af_hrtfm.c   | 477 
> +++
>  libavfilter/allfilters.c |   1 +
>  3 files changed, 479 insertions(+)
>  create mode 100644 libavfilter/af_hrtfm.c

Because we all know what HRTFM means immediately, so we don't need
any doc.

- Derek
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] avfilter: add hrtfm filter

2018-03-15 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavfilter/Makefile |   1 +
 libavfilter/af_hrtfm.c   | 477 +++
 libavfilter/allfilters.c |   1 +
 3 files changed, 479 insertions(+)
 create mode 100644 libavfilter/af_hrtfm.c

diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index fc16512e2c..65783a8443 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -99,6 +99,7 @@ OBJS-$(CONFIG_HAAS_FILTER)   += af_haas.o
 OBJS-$(CONFIG_HDCD_FILTER)   += af_hdcd.o
 OBJS-$(CONFIG_HEADPHONE_FILTER)  += af_headphone.o
 OBJS-$(CONFIG_HIGHPASS_FILTER)   += af_biquads.o
+OBJS-$(CONFIG_HRTFM_FILTER)  += af_hrtfm.o
 OBJS-$(CONFIG_JOIN_FILTER)   += af_join.o
 OBJS-$(CONFIG_LADSPA_FILTER) += af_ladspa.o
 OBJS-$(CONFIG_LOUDNORM_FILTER)   += af_loudnorm.o ebur128.o
diff --git a/libavfilter/af_hrtfm.c b/libavfilter/af_hrtfm.c
new file mode 100644
index 00..48536edd4b
--- /dev/null
+++ b/libavfilter/af_hrtfm.c
@@ -0,0 +1,477 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/avstring.h"
+#include "libavutil/ffmath.h"
+#include "libavutil/opt.h"
+
+#include "audio.h"
+#include "avfilter.h"
+#include "internal.h"
+
+typedef struct ChParams {
+float azim; /* azimuth of the virtual loudspeakers */
+float elev; /* elevation of the virtual loudspeakers */
+int lfe;
+
+float Al[2], Bl[2], al[2], bl[2];
+float Ar[2], Br[2], ar[2], br[2];
+
+float gain[2];
+int M[2];
+
+float *delayed_samples[2];
+int delayed_index[2];
+
+float cache1_in[2];
+float cache1_out[2];
+
+float cache2_in[2];
+float cache2_out[2];
+} ChParams;
+
+typedef struct VirtualSpeaker {
+uint8_t set;
+float azim;
+float elev;
+} VirtualSpeaker;
+
+typedef struct HRTFMContext {
+const AVClass *class;
+
+float sspeed;
+float hradius;
+float gain;  /* filter gain (in dB) */
+float lfe_gain;
+float gain_lfe;
+float rotation;  /* rotation of virtual loudspeakers (in degrees)  */
+float elevation; /* elevation of virtual loudspeakers (in deg.) */
+char *speakers_pos;  /* custom positions of the virtual loudspeakers */
+
+ChParams *params;
+
+int lfe_channel;
+int n_conv;
+
+VirtualSpeaker vspkrpos[64];
+} HRTFMContext;
+
+static int query_formats(AVFilterContext *ctx)
+{
+AVFilterFormats *formats = NULL;
+AVFilterChannelLayouts *layouts = NULL;
+int ret;
+
+ret = ff_add_format(, AV_SAMPLE_FMT_FLT);
+if (ret)
+return ret;
+ret = ff_set_common_formats(ctx, formats);
+if (ret)
+return ret;
+
+layouts = ff_all_channel_layouts();
+if (!layouts)
+return AVERROR(ENOMEM);
+
+ret = ff_channel_layouts_ref(layouts, 
>inputs[0]->out_channel_layouts);
+if (ret)
+return ret;
+
+layouts = NULL;
+ret = ff_add_channel_layout(, AV_CH_LAYOUT_STEREO);
+if (ret)
+return ret;
+
+ret = ff_channel_layouts_ref(layouts, 
>outputs[0]->in_channel_layouts);
+if (ret)
+return ret;
+
+formats = ff_all_samplerates();
+if (!formats)
+return AVERROR(ENOMEM);
+return ff_set_common_samplerates(ctx, formats);
+}
+
+static int parse_channel_name(char **arg, int *rchannel, char *buf)
+{
+int len, i, channel_id = 0;
+int64_t layout, layout0;
+
+/* try to parse a channel name, e.g. "FL" */
+if (sscanf(*arg, "%7[A-Z]%n", buf, )) {
+layout0 = layout = av_get_channel_layout(buf);
+/* channel_id <- first set bit in layout */
+for (i = 32; i > 0; i >>= 1) {
+if (layout >= 1LL << i) {
+channel_id += i;
+layout >>= i;
+}
+}
+/* reject layouts that are not a single channel */
+if (channel_id >= 64 || layout0 != 1LL << channel_id)
+return AVERROR(EINVAL);
+*rchannel = channel_id;
+*arg += len;
+return 0;
+}
+return AVERROR(EINVAL);
+}
+
+static void parse_speaker_pos(AVFilterContext *ctx, int64_t in_channel_layout)
+{
+HRTFMContext *s = ctx->priv;
+char *arg,