From 275751f50934d40708298b76056e96a1698aa87b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 30 Oct 2008 14:46:31 +0000 Subject: tests/check/elements/speexresample.c: Add pipeline unit tests for testing all supported formats with up/downsampling ... Original commit message from CVS: * tests/check/elements/speexresample.c: (element_message_cb), (eos_message_cb), (test_pipeline), (GST_START_TEST), (speexresample_suite): Add pipeline unit tests for testing all supported formats with up/downsampling and different in/outrates. * gst/speexresample/gstspeexresample.c: (gst_speex_resample_push_drain), (gst_speex_resample_process): * gst/speexresample/speex_resampler_wrapper.h: Fix bugs identified by the testsuite. --- gst/speexresample/gstspeexresample.c | 19 ++++++++----------- gst/speexresample/speex_resampler_wrapper.h | 4 ++-- 2 files changed, 10 insertions(+), 13 deletions(-) (limited to 'gst/speexresample') diff --git a/gst/speexresample/gstspeexresample.c b/gst/speexresample/gstspeexresample.c index 186400ca..798e0c6f 100644 --- a/gst/speexresample/gstspeexresample.c +++ b/gst/speexresample/gstspeexresample.c @@ -718,6 +718,10 @@ gst_speex_resample_push_drain (GstSpeexResample * resample) return; } + /* If we wrote more than allocated something is really wrong now + * and we should better abort immediately */ + g_assert (out_len >= out_processed); + if (need_convert) gst_speex_resample_convert_buffer (resample, outtmp, GST_BUFFER_DATA (buf), out_processed, TRUE); @@ -816,7 +820,7 @@ gst_speex_resample_process (GstSpeexResample * resample, GstBuffer * inbuf, guint32 in_len, in_processed; guint32 out_len, out_processed; gint err = RESAMPLER_ERR_SUCCESS; - guint8 *in_tmp, *out_tmp; + guint8 *in_tmp = NULL, *out_tmp = NULL; gboolean need_convert = (resample->funcs->width != resample->width); in_len = GST_BUFFER_SIZE (inbuf) / resample->channels; @@ -866,22 +870,15 @@ gst_speex_resample_process (GstSpeexResample * resample, GstBuffer * inbuf, in_processed, in_len); if (out_len != out_processed) { - /* One sample difference is allowed as this will happen - * because of rounding errors */ if (out_processed == 0) { GST_DEBUG_OBJECT (resample, "Converted to 0 samples, buffer dropped"); return GST_BASE_TRANSFORM_FLOW_DROPPED; - } else if (out_len - out_processed != 1) { - GST_WARNING_OBJECT (resample, - "Converted to %d instead of %d output samples", out_processed, - out_len); } - if (G_UNLIKELY (out_len < out_processed)) { - GST_ERROR_OBJECT (resample, "Wrote more output than allocated!"); - return GST_FLOW_ERROR; - } + /* If we wrote more than allocated something is really wrong now + * and we should better abort immediately */ + g_assert (out_len >= out_processed); } if (G_UNLIKELY (err != RESAMPLER_ERR_SUCCESS)) { diff --git a/gst/speexresample/speex_resampler_wrapper.h b/gst/speexresample/speex_resampler_wrapper.h index c5a214de..2cf79b0e 100644 --- a/gst/speexresample/speex_resampler_wrapper.h +++ b/gst/speexresample/speex_resampler_wrapper.h @@ -89,7 +89,7 @@ static const SpeexResampleFuncs float_funcs = resample_float_resampler_reset_mem, resample_float_resampler_skip_zeros, resample_float_resampler_strerror, - 16 + 32 }; SpeexResamplerState *resample_double_resampler_init (guint32 nb_channels, @@ -155,7 +155,7 @@ static const SpeexResampleFuncs int_funcs = resample_int_resampler_reset_mem, resample_int_resampler_skip_zeros, resample_int_resampler_strerror, - 32 + 16 }; #endif /* __SPEEX_RESAMPLER_WRAPPER_H__ */ -- cgit v1.2.1