return resampler->sbuf;
}
+/**
+ * gst_audio_resampler_reset:
+ * @resampler: a #GstAudioResampler
+ *
+ * Reset @resampler to the state it was when it was first created, discarding
+ * all sample history.
+ */
+void
+gst_audio_resampler_reset (GstAudioResampler * resampler)
+{
+ g_return_if_fail (resampler != NULL);
+
+ if (resampler->samples) {
+ gsize bytes;
+ gint c, blocks, bpf;
+
+ bpf = resampler->bps * resampler->inc;
+ bytes = (resampler->n_taps / 2) * bpf;
+ blocks = resampler->blocks;
+
+ for (c = 0; c < blocks; c++)
+ memset (resampler->sbuf[c], 0, bytes);
+ }
+ /* half of the filter is filled with 0 */
+ resampler->samp_index = 0;
+ resampler->samples_avail = resampler->n_taps / 2 - 1;
+}
+
/**
* gst_audio_resampler_update:
* @resampler: a #GstAudioResampler
static void
gst_audio_resample_reset_state (GstAudioResample * resample)
{
+ if (resample->converter)
+ gst_audio_converter_reset (resample->converter);
}
static gboolean
static void
gst_audio_resample_dump_drain (GstAudioResample * resample, guint history_len)
{
-#if 0
- gint outsize;
- guint in_len G_GNUC_UNUSED, in_processed;
- guint out_len, out_processed;
- guint num, den;
- gpointer buf;
-
- g_assert (resample->converter != NULL);
-
- resample->funcs->get_ratio (resample->state, &num, &den);
-
- in_len = in_processed = history_len;
- out_processed = out_len =
- gst_util_uint64_scale_int_ceil (history_len, den, num);
- outsize = out_len * resample->channels * (resample->funcs->width / 8);
+ gsize out_len, outsize;
+ gpointer out[1];
+ out_len =
+ gst_audio_converter_get_out_frames (resample->converter, history_len);
if (out_len == 0)
return;
- buf = g_malloc (outsize);
- resample->funcs->process (resample->state, NULL, &in_processed, buf,
- &out_processed);
- g_free (buf);
+ outsize = out_len * resample->out.bpf;
- g_assert (in_len == in_processed);
-#endif
+ out[0] = g_malloc (outsize);
+ gst_audio_converter_samples (resample->converter, 0, NULL, history_len,
+ out, out_len);
+ g_free (out[0]);
}
static void
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_FLUSH_STOP:
gst_audio_resample_reset_state (resample);
-#if 0
- if (resample->converter)
- resample->funcs->skip_zeros (resample->converter);
-#endif
resample->num_gap_samples = 0;
resample->num_nongap_samples = 0;
resample->t0 = GST_CLOCK_TIME_NONE;
resample->need_discont = TRUE;
break;
case GST_EVENT_SEGMENT:
-#if 0
if (resample->converter) {
- guint latency =
- resample->funcs->get_input_latency (resample->converter);
+ gsize latency =
+ gst_audio_converter_get_max_latency (resample->converter);
gst_audio_resample_push_drain (resample, latency);
}
-#endif
gst_audio_resample_reset_state (resample);
-#if 0
- if (resample->converter)
- resample->funcs->skip_zeros (resample->converter);
-#endif
resample->num_gap_samples = 0;
resample->num_nongap_samples = 0;
resample->t0 = GST_CLOCK_TIME_NONE;
resample->need_discont = TRUE;
break;
case GST_EVENT_EOS:
-#if 0
if (resample->converter) {
- guint latency =
- resample->funcs->get_input_latency (resample->converter);
+ gsize latency =
+ gst_audio_converter_get_max_latency (resample->converter);
gst_audio_resample_push_drain (resample, latency);
}
-#endif
gst_audio_resample_reset_state (resample);
break;
default:
/* handle discontinuity */
if (G_UNLIKELY (resample->need_discont)) {
-#if 0
- resample->funcs->skip_zeros (resample->state);
-#endif
resample->num_gap_samples = 0;
resample->num_nongap_samples = 0;
/* reset */
gint rate = resample->in.rate;
gint resampler_latency;
-#if 0
- if (resample->state)
+ if (resample->converter)
resampler_latency =
- resample->funcs->get_input_latency (resample->state);
+ gst_audio_converter_get_max_latency (resample->converter);
else
-#endif
resampler_latency = 0;
if (gst_base_transform_is_passthrough (trans))