summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac20
-rw-r--r--gst/audioresample/gstaudioresample.c19
2 files changed, 35 insertions, 4 deletions
diff --git a/configure.ac b/configure.ac
index 970ad894..058256a5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -294,6 +294,26 @@ AG_GST_SET_LEVEL_DEFAULT($GST_CVS)
dnl used in examples
AG_GST_DEFAULT_ELEMENTS
+dnl behaviour of speex based audio resampler
+AC_MSG_CHECKING(which audio resample format to use for integer)
+AC_ARG_WITH([audioresample_format],
+ AS_HELP_STRING([--with-audioresample-format],[Which implementation should be used for integer audio resampling, int/float/auto, (default is auto)]),
+ [ac_cv_audioresample_format=$withval], [ac_cv_audioresample_format=auto])dnl
+AC_MSG_RESULT($ac_cv_audioresample_format)
+case $ac_cv_audioresample_format in
+ int)
+ AC_DEFINE(AUDIORESAMPLE_FORMAT_INT,1,[The int implementation should be used for integer audio resampling])
+ AC_SUBST(AUDIORESAMPLE_FORMAT_INT)
+ ;;
+ float)
+ AC_DEFINE(AUDIORESAMPLE_FORMAT_FLOAT,1,[The float implementation should be used for integer audio resampling])
+ AC_SUBST(AUDIORESAMPLE_FORMAT_FLOAT)
+ ;;
+ auto)
+ AC_DEFINE(AUDIORESAMPLE_FORMAT_AUTO,1,[The implementation that should be used for integer audio resampling witll be benchmarked at runtime])
+ AC_SUBST(AUDIORESAMPLE_FORMAT_AUTO)
+esac
+
dnl *** plug-ins to include ***
dnl these are all the gst plug-ins, compilable without additional libs
diff --git a/gst/audioresample/gstaudioresample.c b/gst/audioresample/gstaudioresample.c
index 5677bb30..049b253c 100644
--- a/gst/audioresample/gstaudioresample.c
+++ b/gst/audioresample/gstaudioresample.c
@@ -101,7 +101,13 @@ GST_STATIC_CAPS ( \
)
/* If TRUE integer arithmetic resampling is faster and will be used if appropiate */
+#if defined AUDIORESAMPLE_FORMAT_INT
+static gboolean gst_audio_resample_use_int = TRUE;
+#elif defined AUDIORESAMPLE_FORMAT_FLOAT
static gboolean gst_audio_resample_use_int = FALSE;
+#else
+static gboolean gst_audio_resample_use_int = FALSE;
+#endif
static GstStaticPadTemplate gst_audio_resample_sink_template =
GST_STATIC_PAD_TEMPLATE ("sink",
@@ -1261,6 +1267,7 @@ gst_audio_resample_get_property (GObject * object, guint prop_id,
}
}
+#if defined AUDIORESAMPLE_FORMAT_AUTO
#define BENCHMARK_SIZE 512
static gboolean
@@ -1360,23 +1367,25 @@ _benchmark_integer_resampling (void)
oil_profile_get_ave_std (&a, &av, NULL);
oil_profile_get_ave_std (&b, &bv, NULL);
+ /* Remember benchmark result in global variable */
gst_audio_resample_use_int = (av > bv);
resample_float_resampler_destroy (sta);
- resample_float_resampler_destroy (stb);
+ resample_int_resampler_destroy (stb);
if (av > bv)
- GST_DEBUG ("Using integer resampler if appropiate: %lf < %lf", bv, av);
+ GST_INFO ("Using integer resampler if appropiate: %lf < %lf", bv, av);
else
- GST_DEBUG ("Using float resampler for everything: %lf <= %lf", av, bv);
+ GST_INFO ("Using float resampler for everything: %lf <= %lf", av, bv);
return TRUE;
error:
resample_float_resampler_destroy (sta);
- resample_float_resampler_destroy (stb);
+ resample_int_resampler_destroy (stb);
return FALSE;
}
+#endif
static gboolean
plugin_init (GstPlugin * plugin)
@@ -1386,8 +1395,10 @@ plugin_init (GstPlugin * plugin)
oil_init ();
+#if defined AUDIORESAMPLE_FORMAT_AUTO
if (!_benchmark_integer_resampling ())
return FALSE;
+#endif
if (!gst_element_register (plugin, "audioresample", GST_RANK_PRIMARY,
GST_TYPE_AUDIO_RESAMPLE)) {