audio-resampler: optimize no resampling

Switch to the faster nearest resample method when are doing no rate
conversion.
This commit is contained in:
Wim Taymans 2016-02-25 15:38:46 +01:00
parent f692d5e459
commit e209c0d565

View file

@ -32,13 +32,12 @@
#include "audio-resampler.h"
/* Contains a collection of all things found in other resamplers:
* speex (optimizations), ffmpeg (fixed phase filter, blackman filter),
* speex (filter construction, optimizations), ffmpeg (fixed phase filter, blackman filter),
* SRC (linear interpolation, fixed precomputed tables),...
*
* Supports:
* - S16, S32, F32 and F64 formats
* - linear interpolation
* - cubic interpolation
* - nearest, linear and cubic interpolation
* - sinc based interpolation with kaiser or blackman-nutall windows
* - fully configurable kaiser parameters
* - dynamic linear or cubic interpolation of filter table, this can
@ -46,9 +45,9 @@
* - full filter table, generated from optionally linear or cubic
* interpolation of filter table
* - fixed filter table size with nearest neighbour phase, optionally
* using a precomputed table
* using a precomputed tables
* - dynamic samplerate changes
* - x86 optimizations
* - x86 and neon optimizations
*/
typedef void (*ConvertTapsFunc) (gdouble * tmp_taps, gpointer taps,
gdouble weight, gint n_taps);
@ -603,6 +602,11 @@ GET_TAPS_NEAREST_FUNC (gint32);
GET_TAPS_NEAREST_FUNC (gfloat);
GET_TAPS_NEAREST_FUNC (gdouble);
#define get_taps_gint16_nearest get_taps_gint16_nearest
#define get_taps_gint32_nearest get_taps_gint32_nearest
#define get_taps_gfloat_nearest get_taps_gfloat_nearest
#define get_taps_gdouble_nearest get_taps_gdouble_nearest
#define GET_TAPS_FULL_FUNC(type) \
static inline gpointer \
get_taps_##type##_full (GstAudioResampler * resampler, \
@ -1148,6 +1152,9 @@ setup_functions (GstAudioResampler * resampler)
index = resampler->format_index;
if (resampler->in_rate == resampler->out_rate)
resampler->resample = resample_funcs[index];
else {
switch (resampler->filter_interpolation) {
default:
case GST_AUDIO_RESAMPLER_FILTER_INTERPOLATION_LINEAR:
@ -1180,6 +1187,7 @@ setup_functions (GstAudioResampler * resampler)
}
resampler->resample = resample_funcs[index];
}
}
static void
resampler_calculate_taps (GstAudioResampler * resampler)
@ -1325,7 +1333,6 @@ resampler_calculate_taps (GstAudioResampler * resampler)
resampler->convert_taps (tmp_taps, taps, weight, n_taps);
}
}
setup_functions (resampler);
}
#define PRINT_TAPS(type,print) \
@ -1728,6 +1735,8 @@ gst_audio_resampler_update (GstAudioResampler * resampler,
alloc_cache_mem (resampler, resampler->bps, resampler->n_taps,
resampler->n_phases);
}
setup_functions (resampler);
return TRUE;
}