diff --git a/gst-libs/gst/audio/audio-resampler.c b/gst-libs/gst/audio/audio-resampler.c index e84cb7b4ec..901469ee28 100644 --- a/gst-libs/gst/audio/audio-resampler.c +++ b/gst-libs/gst/audio/audio-resampler.c @@ -911,6 +911,22 @@ static DeinterleaveFunc deinterleave_funcs[] = { deinterleave_gdouble }; +static void +copy_func (GstAudioResampler * resampler, gpointer sbuf[], + gpointer in[], gsize in_frames) +{ + gint c, channels = resampler->channels; + gsize samples_avail = resampler->samples_avail; + for (c = 0; c < channels; c++) { + guint8 *s = ((guint8 *) sbuf[c]) + (samples_avail * resampler->bps); + if (G_UNLIKELY (in == NULL)) { + memset (s, 0, in_frames * resampler->bps); + } else { + memcpy (s, in[c], in_frames * resampler->bps); + } + } +} + static void calculate_kaiser_params (GstAudioResampler * resampler) { @@ -1335,7 +1351,7 @@ gst_audio_resampler_new (GstAudioResamplerMethod method, GstAudioFormat format, gint channels, gint in_rate, gint out_rate, GstStructure * options) { - gboolean non_interleaved; + gboolean non_interleaved_in, non_interleaved_out; GstAudioResampler *resampler; const GstAudioFormatInfo *info; GstStructure *def_options = NULL; @@ -1379,14 +1395,17 @@ gst_audio_resampler_new (GstAudioResamplerMethod method, resampler->bps = GST_AUDIO_FORMAT_INFO_WIDTH (info) / 8; resampler->sbuf = g_malloc0 (sizeof (gpointer) * channels); - non_interleaved = + non_interleaved_in = + (resampler->flags & GST_AUDIO_RESAMPLER_FLAG_NON_INTERLEAVED_IN); + non_interleaved_out = (resampler->flags & GST_AUDIO_RESAMPLER_FLAG_NON_INTERLEAVED_OUT); /* we resample each channel separately */ resampler->blocks = resampler->channels; resampler->inc = 1; - resampler->ostride = non_interleaved ? 1 : resampler->channels; - resampler->deinterleave = deinterleave_funcs[resampler->format_index]; + resampler->ostride = non_interleaved_out ? 1 : resampler->channels; + resampler->deinterleave = non_interleaved_in ? + copy_func : deinterleave_funcs[resampler->format_index]; resampler->convert_taps = convert_taps_funcs[resampler->format_index]; GST_DEBUG ("method %d, bps %d, channels %d", method, resampler->bps,