]> git.tue.mpg.de Git - paraslash.git/commitdiff
resample filter: Infrastructure.
authorAndre Noll <maan@systemlinux.org>
Mon, 8 Oct 2012 21:29:08 +0000 (23:29 +0200)
committerAndre Noll <maan@systemlinux.org>
Sun, 25 Nov 2012 13:08:55 +0000 (14:08 +0100)
This adds configure command line options and tests for libsamplerate,
and provides a dummy implementation of the resample filter. A simple
m4 file for the configuration options is included as well.

configure.ac
error.h
m4/gengetopt/resample_filter.m4 [new file with mode: 0644]
resample_filter.c [new file with mode: 0644]

index b724696a7b9a83ca11a9cd21555fe1a08e7b4c50..aacecee823aecc296f7988f5f2d04741b6194b99 100644 (file)
@@ -1039,6 +1039,44 @@ fi
 CPPFLAGS="$OLD_CPPFLAGS"
 LDFLAGS="$OLD_LDFLAGS"
 LIBS="$OLD_LIBS"
+############################################################# libsamplerate
+OLD_CPPFLAGS="$CPPFLAGS"
+OLD_LD_FLAGS="$LDFLAGS"
+OLD_LIBS="$LIBS"
+
+have_samplerate="yes"
+AC_ARG_WITH(samplerate_headers, [AS_HELP_STRING(--with-samplerate-headers=dir,
+       [look for samplerate headers also in dir])])
+if test -n "$with_samplerate_headers"; then
+       samplerate_cppflags="-I$with_samplerate_headers"
+       CPPFLAGS="$CPPFLAGS $samplerate_cppflags"
+fi
+AC_ARG_WITH(samplerate_libs, [AS_HELP_STRING(--with-samplerate-libs=dir,
+       [look for samplerate libs also in dir])])
+if test -n "$with_samplerate_libs"; then
+       samplerate_libs="-L$with_samplerate_libs"
+       LDFLAGS="$LDFLAGS $samplerate_libs"
+fi
+
+AC_CHECK_HEADER(samplerate.h, [], have_samplerate=no)
+AC_CHECK_LIB([samplerate], [src_process], [], have_samplerate=no, [])
+
+if test "$have_samplerate" = "yes"; then
+       all_errlist_objs="$all_errlist_objs resample_filter"
+       filter_errlist_objs="$filter_errlist_objs resample_filter check_wav"
+       filter_cmdline_objs="$filter_cmdline_objs add_cmdline(resample_filter)"
+       audiod_errlist_objs="$audiod_errlist_objs resample_filter check_wav"
+       audiod_cmdline_objs="$audiod_cmdline_objs add_cmdline(resample_filter)"
+       filter_ldflags="$filter_ldflags $samplerate_libs -lsamplerate"
+       audiod_ldflags="$audiod_ldflags $samplerate_libs -lsamplerate"
+       filters="$filters resample"
+       AC_SUBST(samplerate_cppflags)
+else
+       AC_MSG_WARN([no resample support in para_audiod/para_filter])
+fi
+CPPFLAGS="$OLD_CPPFLAGS"
+LDFLAGS="$OLD_LDFLAGS"
+LIBS="$OLD_LIBS"
 ############################################################# error2.h
 AC_MSG_NOTICE(creating error2.h)
 for i in $executables; do
diff --git a/error.h b/error.h
index 5308eb91af9b53a0214287ac966e94fed6945bce..4570e19442115540b6187f7ae2b2f648e4437f37 100644 (file)
--- a/error.h
+++ b/error.h
@@ -34,6 +34,7 @@ DEFINE_ERRLIST_OBJECT_ENUM;
 #define STDIN_ERRORS
 #define WRITE_ERRORS
 #define CHECK_WAV_ERRORS
+#define RESAMPLE_FILTER_ERRORS
 
 extern const char **para_errlist[];
 
diff --git a/m4/gengetopt/resample_filter.m4 b/m4/gengetopt/resample_filter.m4
new file mode 100644 (file)
index 0000000..0250a5e
--- /dev/null
@@ -0,0 +1,28 @@
+option "converter" c
+#~~~~~~~~~~~~~~~~~~~
+"choose converter type"
+enum typestr = "type"
+values = "best", "medium", "fastest", "zero_order_hold", "linear"
+default = "medium"
+optional
+
+details = "
+       best: This is a bandlimited interpolator derived from the
+       mathematical sinc function and this is the highest quality
+       sinc based converter, providing a worst case Signal-to-Noise
+       Ratio (SNR) of 97 decibels (dB) at a bandwidth of 97%.
+
+       medium: This is another bandlimited interpolator much like the
+       previous one. It has an SNR of 97dB and a bandwidth of 90%. The
+       speed of the conversion is much faster than the previous one.
+
+       fastest: This is the fastest bandlimited interpolator and
+       has an SNR of 97dB and a bandwidth of 80%.
+
+       zero_order_hold: A Zero Order Hold converter (interpolated
+       value is equal to the last value). The quality is poor but
+       the conversion speed is blindlingly fast.
+
+       linear: A linear converter. Again the quality is poor, but
+       the conversion speed is blindingly fast.
+"
diff --git a/resample_filter.c b/resample_filter.c
new file mode 100644 (file)
index 0000000..5bdfe03
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2012 Andre Noll <maan@systemlinux.org>
+ *
+ * Licensed under the GPL v2. For licencing details see COPYING.
+ */
+
+/** \file resample_filter.c A sample rate converter based on libsamplerate. */
+
+#include <regex.h>
+
+#include "resample_filter.cmdline.h"
+#include "para.h"
+#include "error.h"
+#include "list.h"
+#include "sched.h"
+#include "ggo.h"
+#include "buffer_tree.h"
+#include "filter.h"
+#include "string.h"
+
+static void resample_close(struct filter_node *fn)
+{
+       free(fn->private_data);
+       fn->private_data = NULL;
+}
+
+static void resample_open(struct filter_node *fn)
+{
+}
+
+static void resample_pre_select(struct sched *s, struct task *t)
+{
+       struct filter_node *fn = container_of(t, struct filter_node, task);
+}
+
+static void resample_post_select(__a_unused struct sched *s, struct task *t)
+{
+       struct filter_node *fn = container_of(t, struct filter_node, task);
+}
+
+static int resample_parse_config(int argc, char **argv, void **config)
+{
+       return 0;
+}
+
+static void resample_free_config(void *conf)
+{
+       resample_filter_cmdline_parser_free(conf);
+}
+
+/**
+ * The init function of the resample filter.
+ *
+ * \param f Structure to initialize.
+ */
+void resample_filter_init(struct filter *f)
+{
+       struct resample_filter_args_info dummy;
+
+       resample_filter_cmdline_parser_init(&dummy);
+       f->close = resample_close;
+       f->open = resample_open;
+       f->pre_select = resample_pre_select;
+       f->post_select = resample_post_select;
+       f->parse_config = resample_parse_config;
+       f->free_config = resample_free_config;
+       f->help = (struct ggo_help) {
+               .short_help = resample_filter_args_info_help,
+               .detailed_help = resample_filter_args_info_detailed_help
+       };
+}