Re: [FFmpeg-devel] [RFC][WIP][PATCH] avfilter: add SOFAlizer audio filter

2015-12-10 Thread Michael Niedermayer
On Thu, Dec 10, 2015 at 12:43:58AM +0100, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol 
> ---
>  libavfilter/Makefile   |   1 +
>  libavfilter/af_sofalizer.c | 816 
> +
>  libavfilter/allfilters.c   |   1 +
>  3 files changed, 818 insertions(+)
>  create mode 100644 libavfilter/af_sofalizer.c
> 
> diff --git a/libavfilter/Makefile b/libavfilter/Makefile
> index 8884d1d..d7a3f61 100644
> --- a/libavfilter/Makefile
> +++ b/libavfilter/Makefile
> @@ -87,6 +87,7 @@ OBJS-$(CONFIG_SIDECHAINCOMPRESS_FILTER)  += 
> af_sidechaincompress.o
>  OBJS-$(CONFIG_SIDECHAINGATE_FILTER)  += af_agate.o
>  OBJS-$(CONFIG_SILENCEDETECT_FILTER)  += af_silencedetect.o
>  OBJS-$(CONFIG_SILENCEREMOVE_FILTER)  += af_silenceremove.o
> +OBJS-$(CONFIG_SOFALIZER_FILTER)  += af_sofalizer.o
>  OBJS-$(CONFIG_STEREOTOOLS_FILTER)+= af_stereotools.o
>  OBJS-$(CONFIG_STEREOWIDEN_FILTER)+= af_stereowiden.o
>  OBJS-$(CONFIG_TREBLE_FILTER) += af_biquads.o
> diff --git a/libavfilter/af_sofalizer.c b/libavfilter/af_sofalizer.c
> new file mode 100644
> index 000..8e4da74
> --- /dev/null
> +++ b/libavfilter/af_sofalizer.c
> @@ -0,0 +1,816 @@
> +/*
> + * sofalizer.c : SOFAlizer filter for virtual binaural acoustics
> + 
> *
> + * Copyright (C) 2013-2015 Andreas Fuchs, Wolfgang Hrauda,
> + * Acoustics Research Institute (ARI), Vienna, 
> Austria
> + *
> + * Authors: Andreas Fuchs 
> + *  Wolfgang Hrauda 
> + *
> + * SOFAlizer project coordinator at ARI, main developer of SOFA:
> + *  Piotr Majdak 
> + *
> + * This program 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.
> + *
> + * This program 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 this program; if not, write to the Free Software Foundation,
> + * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
> + 
> */
> +
> +#include 

make distclean ; ./configure && make -j12

libavfilter/af_sofalizer.c:28:20: fatal error: netcdf.h: No such file or 
directory
compilation terminated.

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

Dictatorship naturally arises out of democracy, and the most aggravated
form of tyranny and slavery out of the most extreme liberty. -- Plato


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


[FFmpeg-devel] [RFC][WIP][PATCH] avfilter: add SOFAlizer audio filter

2015-12-09 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavfilter/Makefile   |   1 +
 libavfilter/af_sofalizer.c | 816 +
 libavfilter/allfilters.c   |   1 +
 3 files changed, 818 insertions(+)
 create mode 100644 libavfilter/af_sofalizer.c

diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 8884d1d..d7a3f61 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -87,6 +87,7 @@ OBJS-$(CONFIG_SIDECHAINCOMPRESS_FILTER)  += 
af_sidechaincompress.o
 OBJS-$(CONFIG_SIDECHAINGATE_FILTER)  += af_agate.o
 OBJS-$(CONFIG_SILENCEDETECT_FILTER)  += af_silencedetect.o
 OBJS-$(CONFIG_SILENCEREMOVE_FILTER)  += af_silenceremove.o
+OBJS-$(CONFIG_SOFALIZER_FILTER)  += af_sofalizer.o
 OBJS-$(CONFIG_STEREOTOOLS_FILTER)+= af_stereotools.o
 OBJS-$(CONFIG_STEREOWIDEN_FILTER)+= af_stereowiden.o
 OBJS-$(CONFIG_TREBLE_FILTER) += af_biquads.o
diff --git a/libavfilter/af_sofalizer.c b/libavfilter/af_sofalizer.c
new file mode 100644
index 000..8e4da74
--- /dev/null
+++ b/libavfilter/af_sofalizer.c
@@ -0,0 +1,816 @@
+/*
+ * sofalizer.c : SOFAlizer filter for virtual binaural acoustics
+ *
+ * Copyright (C) 2013-2015 Andreas Fuchs, Wolfgang Hrauda,
+ * Acoustics Research Institute (ARI), Vienna, Austria
+ *
+ * Authors: Andreas Fuchs 
+ *  Wolfgang Hrauda 
+ *
+ * SOFAlizer project coordinator at ARI, main developer of SOFA:
+ *  Piotr Majdak 
+ *
+ * This program 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.
+ *
+ * This program 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 this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ */
+
+#include 
+
+#include "libavutil/opt.h"
+#include "avfilter.h"
+#include "internal.h"
+#include "audio.h"
+
+#define N_SOFA 3 /* no. SOFA files loaded (for instant comparison) */
+#define N_POSITIONS 4 /* no. virtual source positions (advanced settings) */
+
+typedef struct NCSofa { /* contains data of one SOFA file */
+   int i_ncid;  /* netCDF ID of the opened SOFA file */
+   int i_n_samples; /* length of one impulse response (IR) */
+   int i_m_dim; /* number of measurement positions */
+   int *pi_data_delay;  /* broadband delay of each IR */
+/* all measurement positions for each receiver (i.e. 
ear): */
+   float *pf_sp_a;  /* azimuth angles */
+   float *pf_sp_e;  /* elevation angles */
+   float *pf_sp_r;  /* radii */
+/* dataat at each measurement position for each 
receiver: */
+   float *pf_data_ir;   /* IRs (time-domain) */
+} NCSofa;
+
+typedef struct SOFAlizerContext {
+const AVClass *class;
+
+char *filename[N_SOFA];
+struct NCSofa sofa[N_SOFA]; /* contains data of the SOFA files */
+
+float *pf_speaker_pos; /* positions of the virtual loudspekaers */
+float f_gain_lfe;
+
+int i_n_conv; /* number of channels to convolute */
+int i_n_clippings_l;
+int i_n_clippings_r;
+
+/* buffer variables (for convolution) */
+float *pf_ringbuffer_l; /* buffers input samples, length of one buffer: */
+float *pf_ringbuffer_r; /* no. input ch. (incl. LFE) x i_buffer_length */
+int i_write_l; /* current write position to ringbuffer */
+int i_write_r; /* current write position to ringbuffer */
+int i_buffer_length; /* is: longest IR plus max. delay in all SOFA files */
+ /* then choose next power of 2 */
+int i_n_longest_filter; /* longest IR + max. delay in all SOFA files */
+int i_output_buffer_length; /* remember no. samples in output buffer */
+
+/* netCDF variables */
+int i_sofa_id;  /* selected SOFA file */
+int *pi_delay_l; /* broadband delay for each channel/IR to be convolved */
+int *pi_delay_r;
+float *pf_data_ir_l; /* IRs for all channels to be convolved */
+float *pf_data_ir_r; /* (this excludes the LFE) */
+
+/* control variables */
+float f_gain; /* filter gain (in dB) */
+float f_rotation; /* rotation of virtual loudspeakers (in degrees)  */
+float