summaryrefslogtreecommitdiffstats
path: root/tests/check/elements
diff options
context:
space:
mode:
authorSebastian Dröge <slomo@circular-chaos.org>2007-08-16 19:22:48 +0000
committerSebastian Dröge <slomo@circular-chaos.org>2007-08-16 19:22:48 +0000
commite221638fdd642bdf8b4a86365d8a873e89ca9e46 (patch)
treea9a8aeaf955e416d5b38c032db00d0b3ef0ee2d4 /tests/check/elements
parent1df9f40304a2b03667dd88fe3b41d75204986335 (diff)
downloadgst-plugins-bad-e221638fdd642bdf8b4a86365d8a873e89ca9e46.tar.gz
gst-plugins-bad-e221638fdd642bdf8b4a86365d8a873e89ca9e46.tar.bz2
gst-plugins-bad-e221638fdd642bdf8b4a86365d8a873e89ca9e46.zip
gst/filter/gstbpwsinc.*: Implement latency query and only forward those samples downstream that actually contain the ...
Original commit message from CVS: * gst/filter/gstbpwsinc.c: (gst_bpwsinc_class_init), (gst_bpwsinc_init), (process_32), (process_64), (bpwsinc_build_kernel), (bpwsinc_push_residue), (bpwsinc_transform), (bpwsinc_start), (bpwsinc_query), (bpwsinc_query_type), (bpwsinc_event), (bpwsinc_set_property): * gst/filter/gstbpwsinc.h: Implement latency query and only forward those samples downstream that actually contain the data we want, i.e. drop kernel_length/2 in the beginning and append kernel_length/2 (created by convolving the filter kernel with zeroes) to the end. * tests/check/elements/bpwsinc.c: (GST_START_TEST): Adjust the unit test for this slightly changed behaviour. * gst/filter/gstlpwsinc.c: (lpwsinc_build_kernel): Reset residue length only when actually creating a residue.
Diffstat (limited to 'tests/check/elements')
-rw-r--r--tests/check/elements/bpwsinc.c160
1 files changed, 92 insertions, 68 deletions
diff --git a/tests/check/elements/bpwsinc.c b/tests/check/elements/bpwsinc.c
index 1295fac4..a649b8e9 100644
--- a/tests/check/elements/bpwsinc.c
+++ b/tests/check/elements/bpwsinc.c
@@ -96,6 +96,7 @@ GST_START_TEST (test_bp_0hz)
GstCaps *caps;
gdouble *in, *res, rms;
gint i;
+ GList *node;
bpwsinc = setup_bpwsinc ();
/* Set to bandpass */
@@ -122,21 +123,23 @@ GST_START_TEST (test_bp_0hz)
/* pushing gives away my reference ... */
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_eos ()));
/* ... and puts a new buffer on the global list */
- fail_unless_equals_int (g_list_length (buffers), 1);
- fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+ fail_unless (g_list_length (buffers) >= 1);
- res = (gdouble *) GST_BUFFER_DATA (outbuffer);
- for (i = 31; i < 1024; i++) {
- fail_unless (res[i] <= 0.01
- && res[i] >= -0.01, "res[%d] = %lf\n", i, res[i]);
- }
+ for (node = buffers; node; node = node->next) {
+ gint buffer_length;
- rms = 0.0;
- for (i = 0; i < 1024; i++)
- rms += res[i] * res[i];
- rms = sqrt (rms / 1024.0);
- fail_unless (rms <= 0.1);
+ fail_if ((outbuffer = (GstBuffer *) node->data) == NULL);
+
+ res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+ buffer_length = GST_BUFFER_SIZE (outbuffer) / sizeof (gdouble);
+ rms = 0.0;
+ for (i = 0; i < buffer_length; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / buffer_length);
+ fail_unless (rms <= 0.1);
+ }
/* cleanup */
cleanup_bpwsinc (bpwsinc);
@@ -154,6 +157,7 @@ GST_START_TEST (test_bp_11025hz)
GstCaps *caps;
gdouble *in, *res, rms;
gint i;
+ GList *node;
bpwsinc = setup_bpwsinc ();
/* Set to bandpass */
@@ -184,17 +188,23 @@ GST_START_TEST (test_bp_11025hz)
/* pushing gives away my reference ... */
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_eos ()));
/* ... and puts a new buffer on the global list */
- fail_unless_equals_int (g_list_length (buffers), 1);
- fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+ fail_unless (g_list_length (buffers) >= 1);
- res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+ for (node = buffers; node; node = node->next) {
+ gint buffer_length;
- rms = 0.0;
- for (i = 0; i < 1024; i++)
- rms += res[i] * res[i];
- rms = sqrt (rms / 1024.0);
- fail_unless (rms >= 0.4);
+ fail_if ((outbuffer = (GstBuffer *) node->data) == NULL);
+
+ res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+ buffer_length = GST_BUFFER_SIZE (outbuffer) / sizeof (gdouble);
+ rms = 0.0;
+ for (i = 0; i < buffer_length; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / buffer_length);
+ fail_unless (rms >= 0.4);
+ }
/* cleanup */
cleanup_bpwsinc (bpwsinc);
@@ -213,6 +223,7 @@ GST_START_TEST (test_bp_22050hz)
GstCaps *caps;
gdouble *in, *res, rms;
gint i;
+ GList *node;
bpwsinc = setup_bpwsinc ();
/* Set to bandpass */
@@ -241,20 +252,23 @@ GST_START_TEST (test_bp_22050hz)
/* pushing gives away my reference ... */
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_eos ()));
/* ... and puts a new buffer on the global list */
- fail_unless_equals_int (g_list_length (buffers), 1);
- fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+ fail_unless (g_list_length (buffers) >= 1);
- res = (gdouble *) GST_BUFFER_DATA (outbuffer);
- for (i = 31; i < 1024; i++) {
- fail_unless (abs (res[i]) <= 0.01, "res[%d] = %lf\n", i, res[i]);
- }
+ for (node = buffers; node; node = node->next) {
+ gint buffer_length;
- rms = 0.0;
- for (i = 0; i < 1024; i++)
- rms += res[i] * res[i];
- rms = sqrt (rms / 1024.0);
- fail_unless (rms <= 0.1);
+ fail_if ((outbuffer = (GstBuffer *) node->data) == NULL);
+
+ res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+ buffer_length = GST_BUFFER_SIZE (outbuffer) / sizeof (gdouble);
+ rms = 0.0;
+ for (i = 0; i < buffer_length; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / buffer_length);
+ fail_unless (rms <= 0.3);
+ }
/* cleanup */
cleanup_bpwsinc (bpwsinc);
@@ -272,6 +286,7 @@ GST_START_TEST (test_br_0hz)
GstCaps *caps;
gdouble *in, *res, rms;
gint i;
+ GList *node;
bpwsinc = setup_bpwsinc ();
/* Set to bandreject */
@@ -298,21 +313,23 @@ GST_START_TEST (test_br_0hz)
/* pushing gives away my reference ... */
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_eos ()));
/* ... and puts a new buffer on the global list */
- fail_unless_equals_int (g_list_length (buffers), 1);
- fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+ fail_unless (g_list_length (buffers) >= 1);
- res = (gdouble *) GST_BUFFER_DATA (outbuffer);
- for (i = 31; i < 1024; i++) {
- fail_unless (res[i] <= 1.01
- && res[i] >= 0.99, "res[%d] = %lf\n", i, res[i]);
- }
+ for (node = buffers; node; node = node->next) {
+ gint buffer_length;
- rms = 0.0;
- for (i = 0; i < 1024; i++)
- rms += res[i] * res[i];
- rms = sqrt (rms / 1024.0);
- fail_unless (rms >= 0.9);
+ fail_if ((outbuffer = (GstBuffer *) node->data) == NULL);
+
+ res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+ buffer_length = GST_BUFFER_SIZE (outbuffer) / sizeof (gdouble);
+ rms = 0.0;
+ for (i = 0; i < buffer_length; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / buffer_length);
+ fail_unless (rms >= 0.9);
+ }
/* cleanup */
cleanup_bpwsinc (bpwsinc);
@@ -330,6 +347,7 @@ GST_START_TEST (test_br_11025hz)
GstCaps *caps;
gdouble *in, *res, rms;
gint i;
+ GList *node;
bpwsinc = setup_bpwsinc ();
/* Set to bandreject */
@@ -361,20 +379,23 @@ GST_START_TEST (test_br_11025hz)
/* pushing gives away my reference ... */
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_eos ()));
/* ... and puts a new buffer on the global list */
- fail_unless_equals_int (g_list_length (buffers), 1);
- fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+ fail_unless (g_list_length (buffers) >= 1);
- res = (gdouble *) GST_BUFFER_DATA (outbuffer);
- for (i = 31; i < 1024; i++) {
- fail_unless (abs (res[i]) <= 0.01, "res[%d] = %lf\n", i, res[i]);
- }
+ for (node = buffers; node; node = node->next) {
+ gint buffer_length;
- rms = 0.0;
- for (i = 0; i < 1024; i++)
- rms += res[i] * res[i];
- rms = sqrt (rms / 1024.0);
- fail_unless (rms <= 0.3);
+ fail_if ((outbuffer = (GstBuffer *) node->data) == NULL);
+
+ res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+ buffer_length = GST_BUFFER_SIZE (outbuffer) / sizeof (gdouble);
+ rms = 0.0;
+ for (i = 0; i < buffer_length; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / buffer_length);
+ fail_unless (rms <= 0.35);
+ }
/* cleanup */
cleanup_bpwsinc (bpwsinc);
@@ -393,6 +414,7 @@ GST_START_TEST (test_br_22050hz)
GstCaps *caps;
gdouble *in, *res, rms;
gint i;
+ GList *node;
bpwsinc = setup_bpwsinc ();
/* Set to bandreject */
@@ -421,21 +443,23 @@ GST_START_TEST (test_br_22050hz)
/* pushing gives away my reference ... */
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_eos ()));
/* ... and puts a new buffer on the global list */
- fail_unless_equals_int (g_list_length (buffers), 1);
- fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+ fail_unless (g_list_length (buffers) >= 1);
- res = (gdouble *) GST_BUFFER_DATA (outbuffer);
- for (i = 31; i < 1024; i++) {
- fail_unless (abs (res[i]) <= 1.01
- && abs (res[i]) >= 0.99, "res[%d] = %lf\n", i, res[i]);
- }
+ for (node = buffers; node; node = node->next) {
+ gint buffer_length;
- rms = 0.0;
- for (i = 0; i < 1024; i++)
- rms += res[i] * res[i];
- rms = sqrt (rms / 1024.0);
- fail_unless (rms >= 0.9);
+ fail_if ((outbuffer = (GstBuffer *) node->data) == NULL);
+
+ res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+ buffer_length = GST_BUFFER_SIZE (outbuffer) / sizeof (gdouble);
+ rms = 0.0;
+ for (i = 0; i < buffer_length; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / buffer_length);
+ fail_unless (rms >= 0.9);
+ }
/* cleanup */
cleanup_bpwsinc (bpwsinc);
@@ -479,9 +503,9 @@ GST_START_TEST (test_small_buffer)
/* pushing gives away my reference ... */
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_eos ()));
/* ... and puts a new buffer on the global list */
- fail_unless_equals_int (g_list_length (buffers), 1);
- fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+ fail_unless (g_list_length (buffers) >= 1);
/* cleanup */
cleanup_bpwsinc (bpwsinc);