diff options
author | Wim Taymans <wtaymans@redhat.com> | 2016-02-16 09:18:13 +0100 |
---|---|---|
committer | Wim Taymans <wtaymans@redhat.com> | 2016-03-28 11:40:28 +0200 |
commit | 1f56e593471dec161769305d770e20c9d3f02e1e (patch) | |
tree | d7ac1b0d6cf383c82d750733dd9fde9796c72278 | |
parent | 16fef08eca32837e9b7bc0f94cb34753062ef8fa (diff) |
audio-resampler: Use n_phases when calculating taps offset
Tweak linear interpolation oversampling.
Clear filter cache on rate changes when using a full filter.
-rw-r--r-- | gst-libs/gst/audio/audio-resampler.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/gst-libs/gst/audio/audio-resampler.c b/gst-libs/gst/audio/audio-resampler.c index 51f8dfc4f..8f951698d 100644 --- a/gst-libs/gst/audio/audio-resampler.c +++ b/gst-libs/gst/audio/audio-resampler.c @@ -509,25 +509,24 @@ fill_taps (GstAudioResampler * resampler, gdouble x = 1.0 - n_taps / 2 - (gdouble) phase / n_phases; res = make_taps (resampler, tmp_taps, x, n_taps, 1); } else { - gint out_rate = resampler->out_rate; gint offset, pos, frac; gint oversample = resampler->oversample; gint taps_stride = resampler->taps_stride; gdouble ic[4], *taps; pos = phase * oversample; - offset = (oversample - 1) - (pos / out_rate); - frac = pos % out_rate; + offset = (oversample - 1) - (pos / n_phases); + frac = pos % n_phases; taps = (gdouble *) ((gint8 *) resampler->taps + offset * taps_stride); switch (resampler->filter_interpolation) { case GST_AUDIO_RESAMPLER_FILTER_INTERPOLATION_LINEAR: - make_coeff_gdouble_linear (frac, out_rate, ic); + make_coeff_gdouble_linear (frac, n_phases, ic); interpolate_gdouble_linear (tmp_taps, taps, n_taps, ic); break; case GST_AUDIO_RESAMPLER_FILTER_INTERPOLATION_CUBIC: - make_coeff_gdouble_cubic (frac, out_rate, ic); + make_coeff_gdouble_cubic (frac, n_phases, ic); interpolate_gdouble_cubic (tmp_taps, taps, n_taps, ic); break; default: @@ -1172,7 +1171,7 @@ resampler_calculate_taps (GstAudioResampler * resampler) switch (filter_interpolation) { case GST_AUDIO_RESAMPLER_FILTER_INTERPOLATION_LINEAR: - oversample <<= 5; + oversample *= 11; break; default: break; @@ -1218,9 +1217,11 @@ resampler_calculate_taps (GstAudioResampler * resampler) switch (resampler->filter_interpolation) { default: case GST_AUDIO_RESAMPLER_FILTER_INTERPOLATION_LINEAR: + GST_DEBUG ("using linear interpolation to build filter"); isize = 2; break; case GST_AUDIO_RESAMPLER_FILTER_INTERPOLATION_CUBIC: + GST_DEBUG ("using cubic interpolation to build filter"); isize = 4; break; } @@ -1621,6 +1622,11 @@ gst_audio_resampler_update (GstAudioResampler * resampler, resampler->samples_avail += diff; } + } else if (resampler->filter_mode == GST_AUDIO_RESAMPLER_FILTER_MODE_FULL) { + GST_DEBUG ("setting up filter cache"); + resampler->n_phases = resampler->out_rate; + alloc_cache_mem (resampler, resampler->bps, resampler->n_taps, + resampler->n_phases); } return TRUE; } |