From: Andre Noll Date: Mon, 8 Oct 2012 21:29:08 +0000 (+0200) Subject: resample filter: Infrastructure. X-Git-Tag: v0.4.12~4^2~1 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=cad2842e228ab3e42702a05af759ad292b89bed9;ds=sidebyside resample filter: Infrastructure. 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. --- diff --git a/configure.ac b/configure.ac index b724696a..aacecee8 100644 --- a/configure.ac +++ b/configure.ac @@ -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 5308eb91..4570e194 100644 --- 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 index 00000000..0250a5e9 --- /dev/null +++ b/m4/gengetopt/resample_filter.m4 @@ -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 index 00000000..5bdfe037 --- /dev/null +++ b/resample_filter.c @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2012 Andre Noll + * + * Licensed under the GPL v2. For licencing details see COPYING. + */ + +/** \file resample_filter.c A sample rate converter based on libsamplerate. */ + +#include + +#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 + }; +}