From fe1f183340452ee6d65e667ce1c8b3ee58aaec32 Mon Sep 17 00:00:00 2001 From: Rene Stadler Date: Mon, 24 Mar 2008 12:32:59 +0000 Subject: Make rganalysis and rglimiter elements GAP-flag aware. Original commit message from CVS: * gst/replaygain/gstrganalysis.c (gst_rg_analysis_init), (gst_rg_analysis_transform_ip): * gst/replaygain/gstrglimiter.c (gst_rg_limiter_init), (gst_rg_limiter_transform_ip): Make rganalysis and rglimiter elements GAP-flag aware. * tests/check/elements/rganalysis.c: (test_gap_buffers), (rganalysis_suite): * tests/check/elements/rglimiter.c (test_gap), (rglimiter_suite): Add tests to verify gap-awareness. --- tests/check/elements/rganalysis.c | 41 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'tests/check/elements/rganalysis.c') diff --git a/tests/check/elements/rganalysis.c b/tests/check/elements/rganalysis.c index 96ea6dad..1a44bd4e 100644 --- a/tests/check/elements/rganalysis.c +++ b/tests/check/elements/rganalysis.c @@ -741,6 +741,46 @@ GST_START_TEST (test_empty_buffers) GST_END_TEST; +GST_START_TEST (test_gap_buffers) +{ + GstElement *element = setup_rganalysis (); + GstTagList *tag_list; + GstBuffer *buf; + gint accumulator = 0; + gint i; + + set_playing_state (element); + + for (i = 0; i < 60; i++) { + if (i % 3 == 0) { + /* We are cheating here; the element cannot know that these GAP buffers + * actually contain non-silence so it must skip them. */ + buf = test_buffer_square_float_mono (&accumulator, 44100, 512, 0.25); + GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_GAP); + push_buffer (buf); + + /* Verify that the base class does not lift the GAP flag: */ + fail_if (g_list_length (buffers) == 0); + if (GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_GAP)) + fail_unless (GST_BUFFER_FLAG_IS_SET (buffers->data, + GST_BUFFER_FLAG_GAP)); + } else { + push_buffer (test_buffer_const_float_mono (44100, 512, 0.0)); + } + } + + send_eos_event (element); + tag_list = poll_tags (element); + /* We pushed faked GAP buffers with non-silence and non-GAP buffers with + * silence, so the correct result is that the analysis only got silence: */ + fail_unless_track_peak (tag_list, 0.0); + fail_unless_track_gain (tag_list, SILENCE_GAIN); + + cleanup_rganalysis (element); +} + +GST_END_TEST; + /* Tests for correctness of the peak values. */ /* Float peak test. For stereo, one channel has the constant value of -1.369, @@ -1778,6 +1818,7 @@ rganalysis_suite (void) tcase_add_test (tc_chain, test_no_buffer_album_1); tcase_add_test (tc_chain, test_no_buffer_album_2); tcase_add_test (tc_chain, test_empty_buffers); + tcase_add_test (tc_chain, test_gap_buffers); tcase_add_test (tc_chain, test_peak_float); tcase_add_test (tc_chain, test_peak_int16_16); -- cgit v1.2.1