]> git.alsa-project.org Git - alsa-plugins.git/commitdiff
Move rate-lavc to rate-lav subdirectory and update to use libavresample
authorJaroslav Kysela <perex@perex.cz>
Mon, 16 Apr 2018 14:24:29 +0000 (16:24 +0200)
committerJaroslav Kysela <perex@perex.cz>
Mon, 16 Apr 2018 14:37:11 +0000 (16:37 +0200)
- --disable-avcodec renamed to --disable-libav
- --avcodec-includedir renamed to --libav-includedir
- --avcodec-libdir renamed to --libav-libdir
- --disable-lavcrate renamed to --disable-lavrate

The .c changes are from Anton Khirnov. The rest is from Jaroslav Kysela.

From: Anton Khirnov
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
12 files changed:
Makefile.am
a52/Makefile.am
a52/pcm_a52.c
configure.ac
doc/Makefile.am
doc/lavrate.txt [moved from doc/lavcrate.txt with 76% similarity]
rate-lav/10-rate-lav.conf [moved from rate-lavc/10-rate-lavc.conf with 73% similarity]
rate-lav/Makefile.am [new file with mode: 0644]
rate-lav/gcd.h [moved from rate-lavc/gcd.h with 100% similarity]
rate-lav/rate_lavrate.c [new file with mode: 0644]
rate-lavc/Makefile.am [deleted file]
rate-lavc/rate_lavcrate.c [deleted file]

index 303bc83dff1cade183030a66b1b92aac5ba5e667..27f61a4c24e878befa6267960f29a99056a3706d 100644 (file)
@@ -17,8 +17,8 @@ endif
 if HAVE_A52
 SUBDIRS += a52
 endif
-if HAVE_AVCRATE
-SUBDIRS += rate-lavc
+if HAVE_LAVRATE
+SUBDIRS += rate-lav
 endif
 if HAVE_USBSTREAM
 SUBDIRS += usb_stream
index cbc149738903d62270f855d1b3179b3f6152ca6b..4ac8edd779489c59956f0da7f58afe2ad3d39e1a 100644 (file)
@@ -6,9 +6,8 @@ asound_module_addon_DATA = 60-a52-encoder.conf
 asound_module_pcm_a52dir = @ALSA_PLUGIN_DIR@
 asound_module_addondir = @ALSA_ADDON_DIR@
 
-AM_CFLAGS = -Wall -g @ALSA_CFLAGS@ @AVCODEC_CFLAGS@ \
-       -DAVCODEC_HEADER="@AVCODEC_HEADER@"
+AM_CFLAGS = -Wall -g @ALSA_CFLAGS@ @LIBAV_CFLAGS@
 AM_LDFLAGS = -module -avoid-version -export-dynamic -no-undefined $(LDFLAGS_NOUNDEFINED)
 
 libasound_module_pcm_a52_la_SOURCES = pcm_a52.c
-libasound_module_pcm_a52_la_LIBADD = @ALSA_LIBS@ @AVCODEC_LIBS@
+libasound_module_pcm_a52_la_LIBADD = @ALSA_LIBS@ @LIBAV_LIBS@ @LIBAV_CODEC_LIBS@
index 155da3696a7a8225985bf6bd5e3e6606a19b3fdc..29ce45f6502026bbb35a50337fca707251e26077 100644 (file)
@@ -25,7 +25,7 @@
 #include <alsa/asoundlib.h>
 #include <alsa/pcm_external.h>
 #include <alsa/pcm_plugin.h>
-#include AVCODEC_HEADER
+#include <libavcodec/avcodec.h>
 #include <libavutil/avutil.h>
 
 /* some compatibility wrappers */
index 2d7e6aa12de3a95a85fc3d8c9390e39ba46503e2..cb1ae2d76f42f3ec694d3bb52b43360751325193 100644 (file)
@@ -89,67 +89,55 @@ if test "$use_maemo_rm" = "yes"; then
         fi
 fi
 
-AC_ARG_ENABLE([avcodec],
-      AS_HELP_STRING([--disable-avcodec], [Don't build plugins depending on avcodec (a52)]))
+AC_ARG_ENABLE([libav],
+      AS_HELP_STRING([--disable-avlib], [Do not build plugins depending on libav/ffmpeg (a52,lavrate...)]))
 
-if test "x$enable_avcodec" != "xno"; then
-  PKG_CHECK_MODULES(AVCODEC, [libavcodec libavutil], [HAVE_AVCODEC=yes], [HAVE_AVCODEC=no])
+if test "x$enable_libav" != "xno"; then
+  PKG_CHECK_MODULES(LIBAV, [libavcodec libavutil libavresample], [HAVE_LIBAV=yes], [HAVE_LIBAV=no])
 fi
 
-if test "x$HAVE_AVCODEC" = "xno"; then
-  AC_ARG_WITH([avcodec-includedir],
-       AS_HELP_STRING([--with-avcodec-includedir=dir],
-               [AVcodec include directory]),
-       [AVCODEC_CFLAGS="-I$withval"], [AVCODEC_CFLAGS=""])
-  AC_ARG_WITH([avcodec-libdir],
-       AS_HELP_STRING([--with-avcodec-libdir=dir],
-               [AVcodec library directory]),
-       [AVCODEC_LIBS="-L$withval"], [AVCODEC_LIBS=""])
+if test "x$HAVE_LIBAV" = "xno"; then
+  AC_ARG_WITH([libav-includedir],
+       AS_HELP_STRING([--with-libav-includedir=dir],
+               [Libav/ffmpeg include directory]),
+               [LIBAV_CFLAGS="-I$(withval)"], [LIBAV_CFLAGS=""])
+  AC_ARG_WITH([libav-libdir],
+       AS_HELP_STRING([--with-libav-libdir=dir],
+               [Libav/ffmpeg library directory]),
+               [LIBAV_LIBS="-L$withval"], [LIBAV_LIBS=""])
 
   CFLAGS_saved="$CFLAGS"
   LDFLAGS_saved="$LDFLAGS"
-  CFLAGS="$CFLAGS $AVCODEC_CFLAGS"
-  LDFLAGS="$LDFLAGS $AVCODEC_LIBS"
-  AVCODEC_LIBS="$AVCODEC_LIBS -lavcodec"
-  AC_CHECK_LIB([avcodec], [avcodec_open], [HAVE_AVCODEC=yes], [HAVE_AVCODEC=no])
+  CFLAGS="$CFLAGS $LIBAV_CFLAGS"
+  LDFLAGS="$LDFLAGS $LIBAV_LIBS"
+  AC_CHECK_LIB([avcodec], [avcodec_open], [HAVE_LIBAV=yes], [HAVE_LIBAV=no])
   CFLAGS="$CFLAGS_saved"
   LDFLAGS="$LDFLAGS_saved"
+  LIBAV_CODEC_LIBS="-lavcodec"
+  LIBAV_RESAMPLE_LIBS="-lavresample -lavutil"
 fi
 
-if test $HAVE_AVCODEC = yes; then
-  AVCODEC_HEADER=""
-  CFLAGS_saved="$CFLAGS"
-  CFLAGS="$CFLAGS $AVCODEC_CFLAGS"
-  AC_CHECK_HEADER([ffmpeg/avcodec.h], [AVCODEC_HEADER='<ffmpeg/avcodec.h>'])
-  if test -z "$AVCODEC_HEADER"; then
-    AC_CHECK_HEADER([libavcodec/avcodec.h], [AVCODEC_HEADER='<libavcodec/avcodec.h>'])
-  fi
-  if test -z "$AVCODEC_HEADER"; then
-    HAVE_AVCODEC=no
-  fi
-  CFLAGS="$CFLAGS_saved"
-fi
-
-AM_CONDITIONAL(HAVE_AVCODEC, test x$HAVE_AVCODEC = xyes)
-AC_SUBST(AVCODEC_CFLAGS)
-AC_SUBST(AVCODEC_LIBS)
-AC_SUBST(AVCODEC_HEADER)
+AM_CONDITIONAL(HAVE_LIBAV, test x$HAVE_LIBAV = xyes)
+AC_SUBST(LIBAV_CFLAGS)
+AC_SUBST(LIBAV_LIBS)
+AC_SUBST(LIBAV_CODEC_LIBS)
+AC_SUBST(LIBAV_RESAMPLE_LIBS)
 
 AC_ARG_ENABLE([a52],
       AS_HELP_STRING([--disable-a52], [Disable building of A52 encoder plugin]))
 
-if test "x$enable_a52" != "xno" -a "$HAVE_AVCODEC" = "yes"; then
+if test "x$enable_a52" != "xno" -a "$HAVE_LIBAV" = "yes"; then
   HAVE_A52=yes
 fi
 AM_CONDITIONAL(HAVE_A52, test x$HAVE_A52 = xyes)
 
-AC_ARG_ENABLE([avcrate],
-      AS_HELP_STRING([--disable-avcrate], [Disable building of AVC rate plugin]))
+AC_ARG_ENABLE([lavrate],
+      AS_HELP_STRING([--disable-lavrate], [Disable building of libav/ffmpeg rate plugin]))
 
-if test "x$enable_avcrate" != "xno" -a "$HAVE_AVCODEC" = "yes"; then
-  HAVE_AVCRATE=yes
+if test "x$enable_lavrate" != "xno" -a "$HAVE_LIBAV" = "yes"; then
+  HAVE_LAVRATE=yes
 fi
-AM_CONDITIONAL(HAVE_AVCRATE, test x$HAVE_AVCRATE = xyes)
+AM_CONDITIONAL(HAVE_LAVRATE, test x$HAVE_LAVRATE = xyes)
 
 AC_ARG_ENABLE([speexdsp],
       AS_HELP_STRING([--disable-speexdsp], [Disable building of speexdsp plugin]))
@@ -245,7 +233,7 @@ AC_OUTPUT([
        mix/Makefile
        rate/Makefile
        a52/Makefile
-       rate-lavc/Makefile
+       rate-lav/Makefile
        maemo/Makefile
        doc/Makefile
        usb_stream/Makefile
@@ -276,14 +264,13 @@ if test "$HAVE_SAMPLERATE" = "yes"; then
 fi
 echo "Maemo plugin:       $HAVE_MAEMO_PLUGIN"
 echo "  Using Osso resource manager: $use_maemo_rm"
-if test "$HAVE_AVCODEC" = "yes"; then
-  echo "AVCodec config:"
-  echo "  AVCODEC_CFLAGS: $AVCODEC_CFLAGS"
-  echo "  AVCODEC_LIBS: $AVCODEC_LIBS"
-  echo "  AVCODEC_HEADER: $AVCODEC_HEADER"
+if test "$HAVE_LIBAV" = "yes"; then
+  echo "Libav/ffmpeg config:"
+  echo "  LIBAV_CFLAGS:   $LIBAV_CFLAGS"
+  echo "  LIBAV_LIBS:     $LIBAV_LIBS / $LIBAV_CODEC_LIBS / $LIBAV_RESAMPLE_LIBS"
 fi
-echo "A52 plugin:         $HAVE_A52"
-echo "AVC rate plugin:    $HAVE_AVCRATE"
+echo "Libav A52 plugin:   $HAVE_A52"
+echo "Libav rate plugin:  $HAVE_LAVRATE"
 echo "Speex rate plugin:  $PPH"
 echo "Speex preprocess plugin:  $HAVE_SPEEXDSP"
 if test "$HAVE_SPEEX" = "yes"; then
index 0d6f6e5efdfbaa95985c465f4933735f6d6479d3..7c004e5365ab2cd744fc80bbe27fa566319d946c 100644 (file)
@@ -21,8 +21,8 @@ endif
 if HAVE_A52
 EXTRA_DIST += a52.txt
 endif
-if HAVE_AVCRATE
-EXTRA_DIST += lavcrate.txt
+if HAVE_LAVRATE
+EXTRA_DIST += lavrate.txt
 endif
 if HAVE_PPH
 EXTRA_DIST += speexrate.txt
similarity index 76%
rename from doc/lavcrate.txt
rename to doc/lavrate.txt
index faf3e253f38a185b9a45f3561b4d9060d3262b57..6575183251996cee33a3322d879adce5af9afd6b 100644 (file)
@@ -1,14 +1,14 @@
-Rate Converter Plugin Using libavcodec
-======================================
+Rate Converter Plugin Using libavresample
+=========================================0
 
-The plugin in rate-lavc subdirectory is an external rate converter using
-libavcodec's resampler.  You can use this rate converter plugin by defining a
+The plugin in rate-lavr subdirectory is an external rate converter using
+libavresample library. You can use this rate converter plugin by defining a
 rate PCM with "converter" parameter, such as:
 
        pcm.my_rate {
                type rate
                slave.pcm "hw"
-               converter "lavcrate"
+               converter "lavrate"
        }
 
 The plug plugin has also a similar field, "rate_converter".
similarity index 73%
rename from rate-lavc/10-rate-lavc.conf
rename to rate-lav/10-rate-lav.conf
index bab16940afd809c3f5250527cfaacc8a46373cfd..48ede62f89495a9369d8901b3f9b9caf7a126231 100644 (file)
@@ -1,4 +1,4 @@
-pcm.lavcrate {
+pcm.lavrate {
        @args [ SLAVE RATE CONVERTER ]
        @args.SLAVE {
                type string
@@ -10,7 +10,7 @@ pcm.lavcrate {
        }
        @args.CONVERTER {
                type string
-               default "lavcrate"
+               default "lavrate"
        }
        type rate
        converter $CONVERTER
@@ -23,6 +23,6 @@ pcm.lavcrate {
                        @func refer
                        name defaults.namehint.basic
                }
-                description "Rate Converter Plugin Using AVC Library"
+                description "Rate Converter Plugin Using Libav/FFmpeg Library"
        }
 }
diff --git a/rate-lav/Makefile.am b/rate-lav/Makefile.am
new file mode 100644 (file)
index 0000000..0f6ecb6
--- /dev/null
@@ -0,0 +1,25 @@
+EXTRA_DIST = 10-rate-lav.conf
+
+asound_module_rate_lavrate_LTLIBRARIES = libasound_module_rate_lavrate.la
+asound_module_addon_DATA = 10-rate-lav.conf
+
+asound_module_rate_lavratedir = @ALSA_PLUGIN_DIR@
+asound_module_addondir = @ALSA_ADDON_DIR@
+
+AM_CFLAGS = -Wall -g @ALSA_CFLAGS@ @LIBAV_CFLAGS@
+AM_LDFLAGS = -module -avoid-version -export-dynamic -no-undefined $(LDFLAGS_NOUNDEFINED)
+
+libasound_module_rate_lavrate_la_SOURCES = rate_lavrate.c
+libasound_module_rate_lavrate_la_LIBADD = @ALSA_LIBS@ @LIBAV_LIBS@ @LIBAV_RESAMPLE_LIBS@
+
+noinst_HEADERS = gcd.h
+
+install-exec-hook:
+       rm -f $(DESTDIR)@ALSA_PLUGIN_DIR@/libasound_module_rate_lavrate_*.so
+       $(LN_S) libasound_module_rate_lavrate.so $(DESTDIR)@ALSA_PLUGIN_DIR@/libasound_module_rate_lavrate_higher.so
+       $(LN_S) libasound_module_rate_lavrate.so $(DESTDIR)@ALSA_PLUGIN_DIR@/libasound_module_rate_lavrate_high.so
+       $(LN_S) libasound_module_rate_lavrate.so $(DESTDIR)@ALSA_PLUGIN_DIR@/libasound_module_rate_lavrate_fast.so
+       $(LN_S) libasound_module_rate_lavrate.so $(DESTDIR)@ALSA_PLUGIN_DIR@/libasound_module_rate_lavrate_faster.so
+
+uninstall-hook:
+       rm -f $(DESTDIR)@ALSA_PLUGIN_DIR@/libasound_module_rate_lavrate_*.so
similarity index 100%
rename from rate-lavc/gcd.h
rename to rate-lav/gcd.h
diff --git a/rate-lav/rate_lavrate.c b/rate-lav/rate_lavrate.c
new file mode 100644 (file)
index 0000000..2b992c5
--- /dev/null
@@ -0,0 +1,235 @@
+/*
+ * Rate converter plugin using libavresample
+ * Copyright (c) 2014 by Anton Khirnov
+ *
+ * This library 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 library 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.
+ */
+
+#include <stdio.h>
+#include <alsa/asoundlib.h>
+#include <alsa/pcm_rate.h>
+
+#include <libavresample/avresample.h>
+#include <libavutil/channel_layout.h>
+#include <libavutil/opt.h>
+#include <libavutil/mathematics.h>
+#include <libavutil/samplefmt.h>
+
+
+static unsigned int filter_size = 16;
+static unsigned int phase_shift = 10; /* auto-adjusts */
+static double cutoff = 0; /* auto-adjusts */
+
+struct rate_src {
+       AVAudioResampleContext *avr;
+
+       unsigned int in_rate;
+       unsigned int out_rate;
+       unsigned int channels;
+};
+
+static snd_pcm_uframes_t input_frames(void *obj ATTRIBUTE_UNUSED,
+                                     snd_pcm_uframes_t frames)
+{
+       return frames;
+}
+
+static snd_pcm_uframes_t output_frames(void *obj ATTRIBUTE_UNUSED,
+                                      snd_pcm_uframes_t frames)
+{
+       return frames;
+}
+
+static void pcm_src_free(void *obj)
+{
+       struct rate_src *rate = obj;
+       avresample_free(&rate->avr);
+}
+
+static int pcm_src_init(void *obj, snd_pcm_rate_info_t *info)
+{
+       struct rate_src *rate = obj;
+       int i, ir, or;
+
+       if (!rate->avr || rate->channels != info->channels) {
+               int ret;
+
+               pcm_src_free(rate);
+               rate->channels = info->channels;
+               ir = rate->in_rate = info->in.rate;
+               or = rate->out_rate = info->out.rate;
+               i = av_gcd(or, ir);
+               if (or > ir) {
+                       phase_shift = or/i;
+               } else {
+                       phase_shift = ir/i;
+               }
+               if (cutoff <= 0.0) {
+                       cutoff = 1.0 - 1.0/filter_size;
+                       if (cutoff < 0.80)
+                               cutoff = 0.80;
+               }
+
+               rate->avr = avresample_alloc_context();
+               if (!rate->avr)
+                       return -ENOMEM;
+
+               av_opt_set_int(rate->avr, "in_sample_rate",     info->in.rate,  0);
+               av_opt_set_int(rate->avr, "out_sample_rate",    info->out.rate, 0);
+               av_opt_set_int(rate->avr, "in_sample_format",   AV_SAMPLE_FMT_S16, 0);
+               av_opt_set_int(rate->avr, "out_sample_format",  AV_SAMPLE_FMT_S16, 0);
+               av_opt_set_int(rate->avr, "in_channel_layout",  av_get_default_channel_layout(rate->channels), 0);
+               av_opt_set_int(rate->avr, "out_channel_layout", av_get_default_channel_layout(rate->channels), 0);
+
+               av_opt_set_int(rate->avr, "filter_size",        filter_size, 0);
+               av_opt_set_int(rate->avr, "phase_shift",        phase_shift, 0);
+               av_opt_set_double(rate->avr, "cutoff",          cutoff,      0);
+
+               ret = avresample_open(rate->avr);
+               if (ret < 0) {
+                       avresample_free(&rate->avr);
+                       return -EINVAL;
+               }
+       }
+
+       return 0;
+}
+
+static int pcm_src_adjust_pitch(void *obj, snd_pcm_rate_info_t *info)
+{
+       struct rate_src *rate = obj;
+
+       if (info->out.rate != rate->out_rate || info->in.rate != rate->in_rate)
+               pcm_src_init(obj, info);
+       return 0;
+}
+
+static void pcm_src_reset(void *obj)
+{
+       struct rate_src *rate = obj;
+
+       if (rate->avr) {
+#if 0
+               avresample_close(rate->avr);
+               avresample_open(rate->avr);
+#endif
+       }
+}
+
+static void pcm_src_convert_s16(void *obj, int16_t *dst,
+                               unsigned int dst_frames,
+                               const int16_t *src,
+                               unsigned int src_frames)
+{
+       struct rate_src *rate = obj;
+       int chans = rate->channels;
+       unsigned int total_in = avresample_get_delay(rate->avr) + src_frames;
+
+       avresample_convert(rate->avr, (uint8_t **)&dst, dst_frames * chans * 2, dst_frames,
+                          (uint8_t **)&src, src_frames * chans * 2, src_frames);
+
+       avresample_set_compensation(rate->avr,
+                                    total_in - src_frames > filter_size ? 0 : 1, src_frames);
+}
+
+static void pcm_src_close(void *obj)
+{
+       pcm_src_free(obj);
+}
+
+#if SND_PCM_RATE_PLUGIN_VERSION >= 0x010002
+static int get_supported_rates(void *obj ATTRIBUTE_UNUSED,
+                              unsigned int *rate_min,
+                              unsigned int *rate_max)
+{
+       *rate_min = *rate_max = 0; /* both unlimited */
+       return 0;
+}
+
+static void dump(void *obj ATTRIBUTE_UNUSED, snd_output_t *out)
+{
+       snd_output_printf(out, "Converter: libavr\n");
+}
+#endif
+
+static snd_pcm_rate_ops_t pcm_src_ops = {
+       .close = pcm_src_close,
+       .init = pcm_src_init,
+       .free = pcm_src_free,
+       .reset = pcm_src_reset,
+       .adjust_pitch = pcm_src_adjust_pitch,
+       .convert_s16 = pcm_src_convert_s16,
+       .input_frames = input_frames,
+       .output_frames = output_frames,
+#if SND_PCM_RATE_PLUGIN_VERSION >= 0x010002
+       .version = SND_PCM_RATE_PLUGIN_VERSION,
+       .get_supported_rates = get_supported_rates,
+       .dump = dump,
+#endif
+};
+
+int pcm_src_open(unsigned int version, void **objp, snd_pcm_rate_ops_t *ops)
+
+{
+       struct rate_src *rate;
+
+#if SND_PCM_RATE_PLUGIN_VERSION < 0x010002
+       if (version != SND_PCM_RATE_PLUGIN_VERSION) {
+               fprintf(stderr, "Invalid rate plugin version %x\n", version);
+               return -EINVAL;
+       }
+#endif
+       rate = calloc(1, sizeof(*rate));
+       if (!rate)
+               return -ENOMEM;
+
+       *objp = rate;
+       rate->avr = NULL;
+#if SND_PCM_RATE_PLUGIN_VERSION >= 0x010002
+       if (version == 0x010001)
+               memcpy(ops, &pcm_src_ops, sizeof(snd_pcm_rate_old_ops_t));
+       else
+#endif
+               *ops = pcm_src_ops;
+       return 0;
+}
+
+int SND_PCM_RATE_PLUGIN_ENTRY(lavrate)(unsigned int version, void **objp,
+                       snd_pcm_rate_ops_t *ops)
+{
+       return pcm_src_open(version, objp, ops);
+}
+int SND_PCM_RATE_PLUGIN_ENTRY(lavrate_higher)(unsigned int version,
+                       void **objp, snd_pcm_rate_ops_t *ops)
+{
+       filter_size = 64;
+       return pcm_src_open(version, objp, ops);
+}
+int SND_PCM_RATE_PLUGIN_ENTRY(lavrate_high)(unsigned int version,
+                       void **objp, snd_pcm_rate_ops_t *ops)
+{
+       filter_size = 32;
+       return pcm_src_open(version, objp, ops);
+}
+int SND_PCM_RATE_PLUGIN_ENTRY(lavrate_fast)(unsigned int version,
+                       void **objp, snd_pcm_rate_ops_t *ops)
+{
+       filter_size = 8;
+       return pcm_src_open(version, objp, ops);
+}
+int SND_PCM_RATE_PLUGIN_ENTRY(lavrate_faster)(unsigned int version,
+                       void **objp, snd_pcm_rate_ops_t *ops)
+{
+       filter_size = 4;
+       return pcm_src_open(version, objp, ops);
+}
+
+
diff --git a/rate-lavc/Makefile.am b/rate-lavc/Makefile.am
deleted file mode 100644 (file)
index 5f66472..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-EXTRA_DIST = 10-rate-lavc.conf
-
-asound_module_rate_lavcrate_LTLIBRARIES = libasound_module_rate_lavcrate.la
-asound_module_addon_DATA = 10-rate-lavc.conf
-
-asound_module_rate_lavcratedir = @ALSA_PLUGIN_DIR@
-asound_module_addondir = @ALSA_ADDON_DIR@
-
-AM_CFLAGS = -Wall -g @ALSA_CFLAGS@ @AVCODEC_CFLAGS@ \
-       -DAVCODEC_HEADER="@AVCODEC_HEADER@"
-AM_LDFLAGS = -module -avoid-version -export-dynamic -no-undefined $(LDFLAGS_NOUNDEFINED)
-
-libasound_module_rate_lavcrate_la_SOURCES = rate_lavcrate.c
-libasound_module_rate_lavcrate_la_LIBADD = @ALSA_LIBS@ @AVCODEC_LIBS@
-
-noinst_HEADERS = gcd.h
-
-install-exec-hook:
-       rm -f $(DESTDIR)@ALSA_PLUGIN_DIR@/libasound_module_rate_lavcrate_*.so
-       $(LN_S) libasound_module_rate_lavcrate.so $(DESTDIR)@ALSA_PLUGIN_DIR@/libasound_module_rate_lavcrate_higher.so
-       $(LN_S) libasound_module_rate_lavcrate.so $(DESTDIR)@ALSA_PLUGIN_DIR@/libasound_module_rate_lavcrate_high.so
-       $(LN_S) libasound_module_rate_lavcrate.so $(DESTDIR)@ALSA_PLUGIN_DIR@/libasound_module_rate_lavcrate_fast.so
-       $(LN_S) libasound_module_rate_lavcrate.so $(DESTDIR)@ALSA_PLUGIN_DIR@/libasound_module_rate_lavcrate_faster.so
-
-uninstall-hook:
-       rm -f $(DESTDIR)@ALSA_PLUGIN_DIR@/libasound_module_rate_lavcrate_*.so
diff --git a/rate-lavc/rate_lavcrate.c b/rate-lavc/rate_lavcrate.c
deleted file mode 100644 (file)
index 14a2198..0000000
+++ /dev/null
@@ -1,291 +0,0 @@
-/*
- * Rate converter plugin using libavcodec's resampler
- * Copyright (c) 2007 by Nicholas Kain <njkain@gmail.com>
- *
- * based on rate converter that uses libsamplerate
- * Copyright (c) 2006 by Takashi Iwai <tiwai@suse.de>
- *
- * This library 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 library 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.
- */
-
-#include <stdio.h>
-#include <alsa/asoundlib.h>
-#include <alsa/pcm_rate.h>
-#include AVCODEC_HEADER
-#include "gcd.h"
-
-static int filter_size = 16;
-static int phase_shift = 10; /* auto-adjusts */
-static double cutoff = 0; /* auto-adjusts */
-
-struct rate_src {
-       struct AVResampleContext *context;
-       int in_rate;
-       int out_rate;
-       int stored;
-       int point;
-       int16_t **out;
-       int16_t **in;
-       unsigned int channels;
-};
-
-static snd_pcm_uframes_t input_frames(void *obj, snd_pcm_uframes_t frames)
-{
-       return frames;
-}
-
-static snd_pcm_uframes_t output_frames(void *obj, snd_pcm_uframes_t frames)
-{
-       return frames;
-}
-
-static void pcm_src_free(void *obj)
-{
-       struct rate_src *rate = obj;
-       int i;
-
-       if (rate->out) {
-               for (i=0; i<rate->channels; i++) {
-                       free(rate->out[i]);
-               }
-               free(rate->out);
-       }
-       if (rate->in) {
-               for (i=0; i<rate->channels; i++) {
-                       free(rate->in[i]);
-               }
-               free(rate->in);
-       }
-       rate->out = rate->in = NULL;
-
-       if (rate->context) {
-               av_resample_close(rate->context);
-               rate->context = NULL;
-       }
-}
-
-static int pcm_src_init(void *obj, snd_pcm_rate_info_t *info)
-{
-       struct rate_src *rate = obj;
-       int i, ir, or;
-
-       if (! rate->context || rate->channels != info->channels) {
-               pcm_src_free(rate);
-               rate->channels = info->channels;
-               ir = rate->in_rate = info->in.rate;
-               or = rate->out_rate = info->out.rate;
-               i = gcd(or, ir);
-               if (or > ir) {
-                       phase_shift = or/i;
-               } else {
-                       phase_shift = ir/i;
-               }
-               if (cutoff <= 0.0) {
-                       cutoff = 1.0 - 1.0/filter_size;
-                       if (cutoff < 0.80)
-                               cutoff = 0.80;
-               }
-               rate->context = av_resample_init(info->out.rate, info->in.rate,
-                       filter_size, phase_shift,
-                       (info->out.rate >= info->in.rate ? 0 : 1), cutoff);
-               if (!rate->context)
-                       return -EINVAL;
-       }
-
-       rate->out = malloc(rate->channels * sizeof(int16_t *));
-       rate->in = malloc(rate->channels * sizeof(int16_t *));
-       for (i=0; i<rate->channels; i++) {
-               rate->out[i] = calloc(info->out.period_size * 2, 
-                       sizeof(int16_t));
-               rate->in[i] = calloc(info->in.period_size * 2,
-                       sizeof(int16_t));
-       }
-       rate->point = info->in.period_size / 2;
-       if (!rate->out || !rate->in) {
-               pcm_src_free(rate);
-               return -ENOMEM;
-       }
-
-       return 0;
-}
-
-static int pcm_src_adjust_pitch(void *obj, snd_pcm_rate_info_t *info)
-{
-       struct rate_src *rate = obj;
-
-       if (info->out.rate != rate->out_rate || info->in.rate != rate->in_rate)
-               pcm_src_init(obj, info);
-       return 0;
-}
-
-static void pcm_src_reset(void *obj)
-{
-       struct rate_src *rate = obj;
-       rate->stored = 0;
-}
-
-static void deinterleave(const int16_t *src, int16_t **dst, unsigned int frames,
-       unsigned int chans, int overflow)
-{
-       int i, j;
-
-       if (chans == 1) {
-               memcpy(dst + overflow, src, frames*sizeof(int16_t));
-       } else if (chans == 2) {
-               for (j=overflow; j<(frames + overflow); j++) {
-                       dst[0][j] = *(src++);
-                       dst[1][j] = *(src++);
-               }
-       } else {
-               for (j=overflow; j<(frames + overflow); j++) {
-                       for (i=0; i<chans; i++) {
-                               dst[i][j] = *(src++);
-                       }
-               }
-       }
-}
-
-static void reinterleave(int16_t **src, int16_t *dst, unsigned int frames,
-       unsigned int chans)
-{
-       int i, j;
-
-       if (chans == 1) {
-               memcpy(dst, src, frames*sizeof(int16_t));
-       } else if (chans == 2) {
-               for (j=0; j<frames; j++) {
-                       *(dst++) = src[0][j];
-                       *(dst++) = src[1][j];
-               }
-       } else {
-               for (j=0; j<frames; j++) {
-                       for (i=0; i<chans; i++) {
-                               *(dst++) = src[i][j];
-                       }
-               }
-       }
-}
-
-static void pcm_src_convert_s16(void *obj, int16_t *dst, unsigned int
-       dst_frames, const int16_t *src, unsigned int src_frames)
-{
-       struct rate_src *rate = obj;
-       int consumed = 0, chans=rate->channels, ret=0, i;
-       int total_in = rate->stored + src_frames, new_stored;
-
-       deinterleave(src, rate->in, src_frames, chans, rate->point);
-       for (i=0; i<chans; ++i) {       
-               ret = av_resample(rate->context, rate->out[i],
-                               rate->in[i]+rate->point-rate->stored, &consumed,
-                               total_in, dst_frames, i == (chans - 1));
-               new_stored = total_in-consumed;
-               memmove(rate->in[i]+rate->point-new_stored,
-                               rate->in[i]+rate->point-rate->stored+consumed,
-                               new_stored*sizeof(int16_t));
-       }
-       av_resample_compensate(rate->context,
-                       total_in-src_frames>filter_size?0:1, src_frames);
-       reinterleave(rate->out, dst, ret, chans);
-       rate->stored = total_in-consumed;
-}
-
-static void pcm_src_close(void *obj)
-{
-       pcm_src_free(obj);
-}
-
-#if SND_PCM_RATE_PLUGIN_VERSION >= 0x010002
-static int get_supported_rates(void *obj, unsigned int *rate_min,
-                              unsigned int *rate_max)
-{
-       *rate_min = *rate_max = 0; /* both unlimited */
-       return 0;
-}
-
-static void dump(void *obj, snd_output_t *out)
-{
-       snd_output_printf(out, "Converter: liblavc\n");
-}
-#endif
-
-static snd_pcm_rate_ops_t pcm_src_ops = {
-       .close = pcm_src_close,
-       .init = pcm_src_init,
-       .free = pcm_src_free,
-       .reset = pcm_src_reset,
-       .adjust_pitch = pcm_src_adjust_pitch,
-       .convert_s16 = pcm_src_convert_s16,
-       .input_frames = input_frames,
-       .output_frames = output_frames,
-#if SND_PCM_RATE_PLUGIN_VERSION >= 0x010002
-       .version = SND_PCM_RATE_PLUGIN_VERSION,
-       .get_supported_rates = get_supported_rates,
-       .dump = dump,
-#endif
-};
-
-int pcm_src_open(unsigned int version, void **objp, snd_pcm_rate_ops_t *ops)
-
-{
-       struct rate_src *rate;
-
-#if SND_PCM_RATE_PLUGIN_VERSION < 0x010002
-       if (version != SND_PCM_RATE_PLUGIN_VERSION) {
-               fprintf(stderr, "Invalid rate plugin version %x\n", version);
-               return -EINVAL;
-       }
-#endif
-       rate = calloc(1, sizeof(*rate));
-       if (!rate)
-               return -ENOMEM;
-
-       *objp = rate;
-       rate->context = NULL;
-#if SND_PCM_RATE_PLUGIN_VERSION >= 0x010002
-       if (version == 0x010001)
-               memcpy(ops, &pcm_src_ops, sizeof(snd_pcm_rate_old_ops_t));
-       else
-#endif
-               *ops = pcm_src_ops;
-       return 0;
-}
-
-int SND_PCM_RATE_PLUGIN_ENTRY(lavcrate)(unsigned int version, void **objp,
-                       snd_pcm_rate_ops_t *ops)
-{
-       return pcm_src_open(version, objp, ops);
-}
-int SND_PCM_RATE_PLUGIN_ENTRY(lavcrate_higher)(unsigned int version,
-                       void **objp, snd_pcm_rate_ops_t *ops)
-{
-       filter_size = 64;
-       return pcm_src_open(version, objp, ops);
-}
-int SND_PCM_RATE_PLUGIN_ENTRY(lavcrate_high)(unsigned int version,
-                       void **objp, snd_pcm_rate_ops_t *ops)
-{
-       filter_size = 32;
-       return pcm_src_open(version, objp, ops);
-}
-int SND_PCM_RATE_PLUGIN_ENTRY(lavcrate_fast)(unsigned int version,
-                       void **objp, snd_pcm_rate_ops_t *ops)
-{
-       filter_size = 8;
-       return pcm_src_open(version, objp, ops);
-}
-int SND_PCM_RATE_PLUGIN_ENTRY(lavcrate_faster)(unsigned int version,
-                       void **objp, snd_pcm_rate_ops_t *ops)
-{
-       filter_size = 4;
-       return pcm_src_open(version, objp, ops);
-}
-
-