Commit 140ca2a5 authored by Rémi Denis-Courmont's avatar 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.)
parent ee86514d
/*****************************************************************************
* 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;
......
/*****************************************************************************
* 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");
......
/*****************************************************************************
* 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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment