Allow to configure the resampler function for integer to skip the benchmarking. Fix...
authorStefan Kost <ensonic@users.sf.net>
Mon, 2 Feb 2009 13:43:03 +0000 (15:43 +0200)
committerStefan Kost <ensonic@users.sf.net>
Mon, 2 Feb 2009 13:45:44 +0000 (15:45 +0200)
configure.ac
gst/audioresample/gstaudioresample.c

index 970ad8949f318ea8d83ef6a2c5a9f05b9d1a5b5a..058256a5e714549d5c62ca8788d07d2c8a98ea11 100644 (file)
@@ -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
index 5677bb30c95294c33b4239e9fee563ea20fd088b..049b253c97f030c5566ed15d7817bd5b550beef2 100644 (file)
@@ -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)) {