diff options
author | Sebastian Dröge <slomo@circular-chaos.org> | 2008-10-30 14:46:31 +0000 |
---|---|---|
committer | Sebastian Dröge <slomo@circular-chaos.org> | 2008-10-30 14:46:31 +0000 |
commit | 275751f50934d40708298b76056e96a1698aa87b (patch) | |
tree | 4d51b8cd9cd2fdfa49a84c547c745cec441f7f5f /gst | |
parent | a915c3ec730776b020efdc757a7de13fbbdc7c67 (diff) | |
download | gst-plugins-bad-275751f50934d40708298b76056e96a1698aa87b.tar.gz gst-plugins-bad-275751f50934d40708298b76056e96a1698aa87b.tar.bz2 gst-plugins-bad-275751f50934d40708298b76056e96a1698aa87b.zip |
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.
Diffstat (limited to 'gst')
-rw-r--r-- | gst/speexresample/gstspeexresample.c | 19 | ||||
-rw-r--r-- | gst/speexresample/speex_resampler_wrapper.h | 4 |
2 files changed, 10 insertions, 13 deletions
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__ */ |