[vlc-commits] Make resampler configurable with --audio-resampler

Rémi Denis-Courmont git at videolan.org
Thu May 3 22:01:20 CEST 2012


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Apr 24 18:36:59 2012 +0300| [860f1ae109351a0fd231eca760e08dadeaaed1e3] | committer: Rémi Denis-Courmont

Make resampler configurable with --audio-resampler

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=860f1ae109351a0fd231eca760e08dadeaaed1e3
---

 src/audio_output/filters.c |   26 +++++++++++++++++---------
 src/libvlc-module.c        |    7 +++++++
 2 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/src/audio_output/filters.c b/src/audio_output/filters.c
index 8a96d8c..1112a87 100644
--- a/src/audio_output/filters.c
+++ b/src/audio_output/filters.c
@@ -44,25 +44,33 @@
  * FindFilter: find an audio filter for a specific transformation
  *****************************************************************************/
 static filter_t * FindFilter( vlc_object_t *obj,
-                              const audio_sample_format_t * p_input_format,
-                              const audio_sample_format_t * p_output_format )
+                              const audio_sample_format_t *infmt,
+                              const audio_sample_format_t *outfmt )
 {
     static const char typename[] = "audio filter";
+    const char *type = "audio filter", *name = NULL;
     filter_t * p_filter;
 
     p_filter = vlc_custom_create( obj, sizeof(*p_filter), typename );
 
     if ( p_filter == NULL ) return NULL;
 
-    memcpy( &p_filter->fmt_in.audio, p_input_format,
-            sizeof(audio_sample_format_t) );
-    p_filter->fmt_in.i_codec = p_input_format->i_format;
-    memcpy( &p_filter->fmt_out.audio, p_output_format,
-            sizeof(audio_sample_format_t) );
-    p_filter->fmt_out.i_codec = p_output_format->i_format;
+    p_filter->fmt_in.audio = *infmt;
+    p_filter->fmt_in.i_codec = infmt->i_format;
+    p_filter->fmt_out.audio = *outfmt;
+    p_filter->fmt_out.i_codec = outfmt->i_format;
     p_filter->p_owner = NULL;
 
-    p_filter->p_module = module_need( p_filter, "audio filter", NULL, false );
+    if( infmt->i_format == outfmt->i_format
+     && infmt->i_physical_channels == outfmt->i_physical_channels
+     && infmt->i_original_channels == outfmt->i_original_channels )
+    {
+        assert( infmt->i_rate != outfmt->i_rate );
+        type = "audio resampler";
+        name = "$audio-resampler";
+    }
+
+    p_filter->p_module = module_need( p_filter, type, name, false );
     if ( p_filter->p_module == NULL )
     {
         vlc_object_release( p_filter );
diff --git a/src/libvlc-module.c b/src/libvlc-module.c
index b066718..934d41d 100644
--- a/src/libvlc-module.c
+++ b/src/libvlc-module.c
@@ -295,6 +295,10 @@ static const char *const ppsz_snap_formats[] =
     "This delays the audio output. The delay must be given in milliseconds. " \
     "This can be handy if you notice a lag between the video and the audio.")
 
+#define AUDIO_RESAMPLER_TEXT N_("Audio resampler")
+#define AUDIO_RESAMPLER_LONGTEXT N_( \
+    "This selects which plugin to use for audio resampling." )
+
 #define MULTICHA_TEXT N_("Audio output channels mode")
 #define MULTICHA_LONGTEXT N_( \
     "This sets the audio output channels mode that will " \
@@ -1605,6 +1609,9 @@ vlc_module_begin ()
                  DESYNC_LONGTEXT, true )
         change_safe ()
 
+    add_module( "audio-resampler", "audio resampler", NULL,
+                AUDIO_RESAMPLER_TEXT, AUDIO_RESAMPLER_LONGTEXT, true )
+
     /* FIXME TODO create a subcat replay gain ? */
     add_string( "audio-replay-gain-mode", ppsz_replay_gain_mode[0], AUDIO_REPLAY_GAIN_MODE_TEXT,
                 AUDIO_REPLAY_GAIN_MODE_LONGTEXT, false )



More information about the vlc-commits mailing list