<div dir="ltr">Hi,<div><br></div><div>Apparently this wrapper uses older, less useful variant of library where model is not possible to change,and is hardcoded.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jul 26, 2019 at 7:20 AM Tristan Matthews <<a href="mailto:tmatth@videolan.org">tmatth@videolan.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">---<br>
NEWS | 3 +<br>
<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a> | 15 +++++<br>
modules/audio_filter/Makefile.am | 7 ++<br>
modules/audio_filter/rnnoise.c | 109 +++++++++++++++++++++++++++++++<br>
po/POTFILES.in | 1 +<br>
5 files changed, 135 insertions(+)<br>
create mode 100644 modules/audio_filter/rnnoise.c<br>
<br>
diff --git a/NEWS b/NEWS<br>
index 0f4f6d74c0..e364df7abe 100644<br>
--- a/NEWS<br>
+++ b/NEWS<br>
@@ -71,6 +71,9 @@ Video output:<br>
* Remove RealRTSP plugin<br>
* Remove Real demuxer plugin<br>
<br>
+Audio filter:<br>
+ * Add RNNoise recurrent neural network denoiser<br>
+<br>
Video filter:<br>
* Update yadif<br>
* Remove remote OSD plugin<br>
diff --git a/<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a> b/<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a><br>
index ac818d8b83..c0f1f09dcb 100644<br>
--- a/<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a><br>
+++ b/<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a><br>
@@ -2901,6 +2901,21 @@ AS_IF([test "${enable_speex}" != "no"], [<br>
])<br>
AM_CONDITIONAL([HAVE_SPEEXDSP], [test "$have_speexdsp" = "yes"])<br>
<br>
+AC_ARG_ENABLE([rnnoise],<br>
+ AS_HELP_STRING([--enable-rnnoise],<br>
+ [RNNoise denoiser filter (default auto)]))<br>
+have_rnnoise="no"<br>
+AS_IF([test "${enable_rnnoise}" != "no"], [<br>
+ PKG_CHECK_MODULES([RNNOISE], [rnnoise], [<br>
+ have_rnnoise="yes"<br>
+ ], [<br>
+ AS_IF([test "x${enable_rnnoise}" != "x"], [<br>
+ AC_MSG_ERROR([$RNNOISE_PKG_ERRORS.])<br>
+ ])<br>
+ ])<br>
+])<br>
+AM_CONDITIONAL([HAVE_RNNOISE], [test "${have_rnnoise}" = "yes"])<br>
+<br>
dnl<br>
dnl Opus plugin<br>
dnl<br>
diff --git a/modules/audio_filter/Makefile.am b/modules/audio_filter/Makefile.am<br>
index 309074c75b..a73ec822d1 100644<br>
--- a/modules/audio_filter/Makefile.am<br>
+++ b/modules/audio_filter/Makefile.am<br>
@@ -137,3 +137,10 @@ libspeex_resampler_plugin_la_LIBADD = $(SPEEXDSP_LIBS)<br>
if HAVE_SPEEXDSP<br>
audio_filter_LTLIBRARIES += <a href="http://libspeex_resampler_plugin.la" rel="noreferrer" target="_blank">libspeex_resampler_plugin.la</a><br>
endif<br>
+<br>
+librnnoise_plugin_la_SOURCES = audio_filter/rnnoise.c<br>
+librnnoise_plugin_la_CFLAGS = $(AM_CFLAGS) $(RNNOISE_CFLAGS)<br>
+librnnoise_plugin_la_LIBADD = $(RNNOISE_LIBS) $(LIBM)<br>
+if HAVE_RNNOISE<br>
+audio_filter_LTLIBRARIES += <a href="http://librnnoise_plugin.la" rel="noreferrer" target="_blank">librnnoise_plugin.la</a><br>
+endif<br>
diff --git a/modules/audio_filter/rnnoise.c b/modules/audio_filter/rnnoise.c<br>
new file mode 100644<br>
index 0000000000..ddf18870e7<br>
--- /dev/null<br>
+++ b/modules/audio_filter/rnnoise.c<br>
@@ -0,0 +1,109 @@<br>
+/*****************************************************************************<br>
+ * rnnoise.c : Recurrent neural network for audio noise reduction<br>
+ *****************************************************************************<br>
+ * Copyright © 2019 Tristan Matthews<br>
+ *<br>
+ * This program is free software; you can redistribute it and/or modify it<br>
+ * under the terms of the GNU Lesser General Public License as published by<br>
+ * the Free Software Foundation; either version 2.1 of the License, or<br>
+ * (at your option) any later version.<br>
+ *<br>
+ * This program is distributed in the hope that it will be useful,<br>
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of<br>
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the<br>
+ * GNU Lesser General Public License for more details.<br>
+ *<br>
+ * You should have received a copy of the GNU Lesser General Public License<br>
+ * along with this program; if not, write to the Free Software Foundation,<br>
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.<br>
+ *****************************************************************************/<br>
+<br>
+#ifdef HAVE_CONFIG_H<br>
+# include "config.h"<br>
+#endif<br>
+<br>
+#include <vlc_common.h><br>
+#include <vlc_aout.h><br>
+#include <vlc_filter.h><br>
+#include <vlc_plugin.h><br>
+<br>
+#include <rnnoise.h><br>
+<br>
+static int Open (vlc_object_t *);<br>
+static void Close (vlc_object_t *);<br>
+<br>
+typedef struct<br>
+{<br>
+ DenoiseState *p_st;<br>
+ bool b_first;<br>
+} filter_sys_t;<br>
+<br>
+vlc_module_begin ()<br>
+ set_shortname (N_("RNNoise"))<br>
+ set_description (N_("RNNoise filter"))<br>
+ set_category (CAT_AUDIO)<br>
+ set_subcategory (SUBCAT_AUDIO_AFILTER)<br>
+ set_capability ("audio filter", 0)<br>
+ set_callbacks( Open, Close )<br>
+vlc_module_end ()<br>
+<br>
+static block_t *Process (filter_t *, block_t *);<br>
+<br>
+static int Open (vlc_object_t *obj)<br>
+{<br>
+ filter_t *p_filter = (filter_t *)obj;<br>
+<br>
+ filter_sys_t *p_sys = p_filter->p_sys = malloc( sizeof(filter_sys_t) );<br>
+ if( unlikely(!p_sys) )<br>
+ return VLC_ENOMEM;<br>
+<br>
+ p_sys->b_first = true;<br>
+<br>
+ p_sys->p_st = rnnoise_create(NULL);<br>
+ if( unlikely(!p_sys->p_st) ) {<br>
+ free( p_sys );<br>
+ return VLC_ENOMEM;<br>
+ }<br>
+<br>
+ p_filter->fmt_in.audio.i_format = VLC_CODEC_FL32;<br>
+ aout_FormatPrepare(&p_filter->fmt_in.audio);<br>
+ p_filter->fmt_out.audio = p_filter->fmt_in.audio;<br>
+ p_filter->pf_audio_filter = Process;<br>
+ return VLC_SUCCESS;<br>
+}<br>
+<br>
+static void Close( vlc_object_t *obj )<br>
+{<br>
+ filter_t *p_filter = (filter_t *)obj;<br>
+ filter_sys_t *p_sys = p_filter->p_sys;<br>
+ if( p_sys->p_st )<br>
+ rnnoise_destroy( p_sys->p_st );<br>
+ free( p_sys );<br>
+}<br>
+<br>
+#define FRAME_SIZE 480<br>
+<br>
+static block_t *Process (filter_t *p_filter, block_t *p_block)<br>
+{<br>
+ filter_sys_t *p_sys = p_filter->p_sys;<br>
+ float tmp[FRAME_SIZE];<br>
+ float *p_buffer = (float *)p_block->p_buffer;<br>
+ for ( int i_nb_samples = p_block->i_nb_samples; i_nb_samples > 0; i_nb_samples -= FRAME_SIZE )<br>
+ {<br>
+ /* rnnoise process blocks of 480 samples, and expects input to be in the 32768 scale. */<br>
+ for (unsigned i = 0; i < FRAME_SIZE; i++) tmp[i] = p_buffer[i] * 32768;<br>
+<br>
+ rnnoise_process_frame(p_sys->p_st, tmp, tmp);<br>
+<br>
+ if( !p_sys->b_first )<br>
+ {<br>
+ for (unsigned i = 0; i < FRAME_SIZE; i++) p_buffer[i] = tmp[i] / 32768.;<br>
+ }<br>
+ else<br>
+ {<br>
+ p_sys->b_first = false;<br>
+ }<br>
+ p_buffer += FRAME_SIZE;<br>
+ }<br>
+ return p_block;<br>
+}<br>
diff --git a/po/POTFILES.in b/po/POTFILES.in<br>
index 1c2a5298a8..49b89067f4 100644<br>
--- a/po/POTFILES.in<br>
+++ b/po/POTFILES.in<br>
@@ -245,6 +245,7 @@ modules/audio_filter/resampler/soxr.c<br>
modules/audio_filter/resampler/speex.c<br>
modules/audio_filter/resampler/src.c<br>
modules/audio_filter/resampler/ugly.c<br>
+modules/audio_filter/rnnoise.c<br>
modules/audio_filter/scaletempo.c<br>
modules/audio_filter/spatializer/spatializer.cpp<br>
modules/audio_filter/stereo_widen.c<br>
-- <br>
2.20.1<br>
<br>
_______________________________________________<br>
vlc-devel mailing list<br>
To unsubscribe or modify your subscription options:<br>
<a href="https://mailman.videolan.org/listinfo/vlc-devel" rel="noreferrer" target="_blank">https://mailman.videolan.org/listinfo/vlc-devel</a></blockquote></div>