[vlc-commits] resamplers: no need to check that rates are different
Rémi Denis-Courmont
git at videolan.org
Sat Nov 17 21:34:20 CET 2012
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Nov 17 22:23:26 2012 +0200| [140ca2a521a8c14e1a62fe7de9a33cff830a5725] | committer: Rémi Denis-Courmont
resamplers: no need to check that rates are different
In fact, the rates may be identical. Resampling might be used only to
compensate accidental drift. (We could also remove channel and format
checks.)
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=140ca2a521a8c14e1a62fe7de9a33cff830a5725
---
modules/audio_filter/resampler/speex.c | 21 +++++++++++++++------
modules/audio_filter/resampler/src.c | 19 ++++++++++++++-----
modules/audio_filter/resampler/ugly.c | 19 ++++++++++++++-----
3 files changed, 43 insertions(+), 16 deletions(-)
diff --git a/modules/audio_filter/resampler/speex.c b/modules/audio_filter/resampler/speex.c
index c847f5b..774fc8f 100644
--- a/modules/audio_filter/resampler/speex.c
+++ b/modules/audio_filter/resampler/speex.c
@@ -1,7 +1,7 @@
/*****************************************************************************
* speex.c : libspeex DSP resampler
*****************************************************************************
- * Copyright © 2011 Rémi Denis-Courmont
+ * Copyright © 2011-2012 Rémi Denis-Courmont
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
@@ -34,6 +34,7 @@
"Resampling quality (0 = worst and fastest, 10 = best and slowest).")
static int Open (vlc_object_t *);
+static int OpenResampler (vlc_object_t *);
static void Close (vlc_object_t *);
vlc_module_begin ()
@@ -49,19 +50,17 @@ vlc_module_begin ()
add_submodule ()
set_capability ("audio resampler", 0)
- set_callbacks (Open, Close)
+ set_callbacks (OpenResampler, Close)
vlc_module_end ()
static block_t *Resample (filter_t *, block_t *);
-static int Open (vlc_object_t *obj)
+static int OpenResampler (vlc_object_t *obj)
{
filter_t *filter = (filter_t *)obj;
- /* Will change rate */
- if (filter->fmt_in.audio.i_rate == filter->fmt_out.audio.i_rate
/* Cannot convert format */
- || filter->fmt_in.audio.i_format != filter->fmt_out.audio.i_format
+ if (filter->fmt_in.audio.i_format != filter->fmt_out.audio.i_format
/* Cannot remix */
|| filter->fmt_in.audio.i_physical_channels
!= filter->fmt_out.audio.i_physical_channels
@@ -98,6 +97,16 @@ static int Open (vlc_object_t *obj)
return VLC_SUCCESS;
}
+static int Open (vlc_object_t *obj)
+{
+ filter_t *filter = (filter_t *)obj;
+
+ /* Will change rate */
+ if (filter->fmt_in.audio.i_rate == filter->fmt_out.audio.i_rate)
+ return VLC_EGENERIC;
+ return OpenResampler (obj);
+}
+
static void Close (vlc_object_t *obj)
{
filter_t *filter = (filter_t *)obj;
diff --git a/modules/audio_filter/resampler/src.c b/modules/audio_filter/resampler/src.c
index 9af5b29..b67be0e 100644
--- a/modules/audio_filter/resampler/src.c
+++ b/modules/audio_filter/resampler/src.c
@@ -1,7 +1,7 @@
/*****************************************************************************
* src.c : Secret Rabbit Code (a.k.a. libsamplerate) resampler
*****************************************************************************
- * Copyright (C) 2011 Rémi Denis-Courmont
+ * Copyright (C) 2011-2012 Rémi Denis-Courmont
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
@@ -51,6 +51,7 @@ static const char *const conv_type_texts[] = {
};
static int Open (vlc_object_t *);
+static int OpenResampler (vlc_object_t *);
static void Close (vlc_object_t *);
vlc_module_begin ()
@@ -66,7 +67,7 @@ vlc_module_begin ()
add_submodule ()
set_capability ("audio resampler", 50)
- set_callbacks (Open, Close)
+ set_callbacks (OpenResampler, Close)
vlc_module_end ()
static block_t *Resample (filter_t *, block_t *);
@@ -75,6 +76,16 @@ static int Open (vlc_object_t *obj)
{
filter_t *filter = (filter_t *)obj;
+ /* Will change rate */
+ if (filter->fmt_in.audio.i_rate == filter->fmt_out.audio.i_rate)
+ return VLC_EGENERIC;
+ return OpenResampler (obj);
+}
+
+static int OpenResampler (vlc_object_t *obj)
+{
+ filter_t *filter = (filter_t *)obj;
+
/* Only float->float */
if (filter->fmt_in.audio.i_format != VLC_CODEC_FL32
|| filter->fmt_out.audio.i_format != VLC_CODEC_FL32
@@ -82,9 +93,7 @@ static int Open (vlc_object_t *obj)
|| filter->fmt_in.audio.i_physical_channels
!= filter->fmt_out.audio.i_physical_channels
|| filter->fmt_in.audio.i_original_channels
- != filter->fmt_out.audio.i_original_channels
- /* Different sample rate */
- || filter->fmt_in.audio.i_rate == filter->fmt_out.audio.i_rate)
+ != filter->fmt_out.audio.i_original_channels)
return VLC_EGENERIC;
int type = var_InheritInteger (obj, "src-converter-type");
diff --git a/modules/audio_filter/resampler/ugly.c b/modules/audio_filter/resampler/ugly.c
index 1e4041c..796c499 100644
--- a/modules/audio_filter/resampler/ugly.c
+++ b/modules/audio_filter/resampler/ugly.c
@@ -1,5 +1,5 @@
/*****************************************************************************
- * ugly.c : ugly resampler (changes pitch)
+ * ugly.c : zero-order hold "ugly" resampler
*****************************************************************************
* Copyright (C) 2002, 2006 VLC authors and VideoLAN
* $Id$
@@ -37,7 +37,8 @@
/*****************************************************************************
* Local prototypes
*****************************************************************************/
-static int Create ( vlc_object_t * );
+static int Create (vlc_object_t *);
+static int CreateResampler (vlc_object_t *);
static block_t *DoWork( filter_t *, block_t * );
@@ -53,7 +54,7 @@ vlc_module_begin ()
add_submodule()
set_capability( "audio resampler", 2 )
- set_callbacks( Create, NULL )
+ set_callbacks( CreateResampler, NULL )
vlc_module_end ()
/*****************************************************************************
@@ -63,8 +64,16 @@ static int Create( vlc_object_t *p_this )
{
filter_t * p_filter = (filter_t *)p_this;
- if( p_filter->fmt_in.audio.i_rate == p_filter->fmt_out.audio.i_rate
- || p_filter->fmt_in.audio.i_format != p_filter->fmt_out.audio.i_format
+ if( p_filter->fmt_in.audio.i_rate == p_filter->fmt_out.audio.i_rate )
+ return VLC_EGENERIC;
+ return CreateResampler( p_this );
+}
+
+static int CreateResampler( vlc_object_t *p_this )
+{
+ filter_t * p_filter = (filter_t *)p_this;
+
+ if( p_filter->fmt_in.audio.i_format != p_filter->fmt_out.audio.i_format
|| p_filter->fmt_in.audio.i_physical_channels
!= p_filter->fmt_out.audio.i_physical_channels
|| p_filter->fmt_in.audio.i_original_channels
More information about the vlc-commits
mailing list