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.
This commit is contained in:
Sebastian Dröge 2008-10-30 14:46:31 +00:00
parent a915c3ec73
commit 275751f509
5 changed files with 139 additions and 15 deletions

View file

@ -1,3 +1,16 @@
2008-10-30 Sebastian Dröge <slomo@circular-chaos.org>
* 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.
2008-10-30 Sebastian Dröge <slomo@circular-chaos.org>
* gst/speexresample/gstspeexresample.c: (gst_speex_resample_stop),

2
common

@ -1 +1 @@
Subproject commit 2802bb17517a6cfbbb1be6da61ec19151be0750b
Subproject commit edfb4b44ea433b0b83b8a2f27a6e0bcbccdc3f2f

View file

@ -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)) {

View file

@ -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__ */

View file

@ -579,7 +579,116 @@ GST_START_TEST (test_live_switch)
gst_caps_unref (caps);
}
GST_END_TEST static Suite *
GST_END_TEST;
#ifndef GST_DISABLE_PARSE
static GMainLoop *loop;
static gint messages = 0;
static void
element_message_cb (GstBus * bus, GstMessage * message, gpointer user_data)
{
gchar *s;
s = gst_structure_to_string (gst_message_get_structure (message));
GST_DEBUG ("Received message: %s", s);
g_free (s);
messages++;
}
static void
eos_message_cb (GstBus * bus, GstMessage * message, gpointer user_data)
{
GST_DEBUG ("Received eos");
g_main_loop_quit (loop);
}
static void
test_pipeline (gint width, gboolean fp, gint inrate, gint outrate, gint quality)
{
GstElement *pipeline;
GstBus *bus;
GError *error = NULL;
gchar *pipe_str;
pipe_str =
g_strdup_printf
("audiotestsrc num-buffers=100 ! audioconvert ! audio/x-raw-%s,rate=%d,width=%d,channels=2 ! speexresample quality=%d ! audio/x-raw-%s,rate=%d,width=%d ! identity check-imperfect-timestamp=TRUE ! fakesink",
(fp) ? "float" : "int", inrate, width, quality, (fp) ? "float" : "int",
outrate, width);
pipeline = gst_parse_launch (pipe_str, &error);
fail_unless (pipeline != NULL, "Error parsing pipeline: %s",
error ? error->message : "(invalid error)");
g_free (pipe_str);
bus = gst_element_get_bus (pipeline);
fail_if (bus == NULL);
gst_bus_add_signal_watch (bus);
g_signal_connect (bus, "message::element", (GCallback) element_message_cb,
NULL);
g_signal_connect (bus, "message::eos", (GCallback) eos_message_cb, NULL);
gst_element_set_state (pipeline, GST_STATE_PLAYING);
/* run until we receive EOS */
loop = g_main_loop_new (NULL, FALSE);
g_main_loop_run (loop);
g_main_loop_unref (loop);
loop = NULL;
gst_element_set_state (pipeline, GST_STATE_NULL);
fail_if (messages > 0, "Received imperfect timestamp messages");
gst_object_unref (pipeline);
}
GST_START_TEST (test_pipelines)
{
gint quality;
/* Test qualities 0, 5 and 10 */
for (quality = 0; quality < 11; quality += 5) {
test_pipeline (8, FALSE, 44100, 48000, quality);
test_pipeline (8, FALSE, 48000, 44100, quality);
test_pipeline (8, FALSE, 40000, 80000, quality);
test_pipeline (8, FALSE, 80000, 40000, quality);
test_pipeline (16, FALSE, 44100, 48000, quality);
test_pipeline (16, FALSE, 48000, 44100, quality);
test_pipeline (16, FALSE, 40000, 80000, quality);
test_pipeline (16, FALSE, 80000, 40000, quality);
test_pipeline (24, FALSE, 44100, 48000, quality);
test_pipeline (24, FALSE, 48000, 44100, quality);
test_pipeline (24, FALSE, 40000, 80000, quality);
test_pipeline (24, FALSE, 80000, 40000, quality);
test_pipeline (32, FALSE, 44100, 48000, quality);
test_pipeline (32, FALSE, 48000, 44100, quality);
test_pipeline (32, FALSE, 40000, 80000, quality);
test_pipeline (32, FALSE, 80000, 40000, quality);
test_pipeline (32, TRUE, 44100, 48000, quality);
test_pipeline (32, TRUE, 48000, 44100, quality);
test_pipeline (32, TRUE, 40000, 80000, quality);
test_pipeline (32, TRUE, 80000, 40000, quality);
test_pipeline (64, TRUE, 44100, 48000, quality);
test_pipeline (64, TRUE, 48000, 44100, quality);
test_pipeline (64, TRUE, 40000, 80000, quality);
test_pipeline (64, TRUE, 80000, 40000, quality);
}
}
GST_END_TEST;
#endif
static Suite *
speexresample_suite (void)
{
Suite *s = suite_create ("speexresample");
@ -592,6 +701,11 @@ speexresample_suite (void)
tcase_add_test (tc_chain, test_shutdown);
tcase_add_test (tc_chain, test_live_switch);
#ifndef GST_DISABLE_PARSE
tcase_set_timeout (tc_chain, 360);
tcase_add_test (tc_chain, test_pipelines);
#endif
return s;
}