From 645141a6ff29dfd7039e963f3ce6964506da1004 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 24 Jul 2007 04:57:20 +0000 Subject: [PATCH] Use the new buffer clipping function from gstaudio here and require gst-plugins-base CVS. Original commit message from CVS: * configure.ac: * ext/wavpack/gstwavpackdec.c: (gst_wavpack_dec_reset), (gst_wavpack_dec_chain), (gst_wavpack_dec_sink_event): Use the new buffer clipping function from gstaudio here and require gst-plugins-base CVS. * tests/check/elements/wavpackdec.c: (GST_START_TEST): For framed Wavpack buffers we require a valid timestamp. --- ChangeLog | 10 +++++++ configure.ac | 2 +- ext/wavpack/gstwavpackdec.c | 48 +++---------------------------- tests/check/elements/wavpackdec.c | 3 ++ 4 files changed, 18 insertions(+), 45 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2ef9a3d0bf..9ba8ca1ce8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2007-07-24 Sebastian Dröge + + * configure.ac: + * ext/wavpack/gstwavpackdec.c: (gst_wavpack_dec_reset), + (gst_wavpack_dec_chain), (gst_wavpack_dec_sink_event): + Use the new buffer clipping function from gstaudio here and + require gst-plugins-base CVS. + * tests/check/elements/wavpackdec.c: (GST_START_TEST): + For framed Wavpack buffers we require a valid timestamp. + 2007-07-23 Wim Taymans * gst/qtdemux/qtdemux.c: (gst_qtdemux_activate_segment), diff --git a/configure.ac b/configure.ac index 9140471792..2b0df861e3 100644 --- a/configure.ac +++ b/configure.ac @@ -47,7 +47,7 @@ AM_PROG_LIBTOOL dnl *** required versions of GStreamer stuff *** GST_REQ=0.10.13 -GSTPB_REQ=0.10.13 +GSTPB_REQ=0.10.13.1 dnl *** autotools stuff **** diff --git a/ext/wavpack/gstwavpackdec.c b/ext/wavpack/gstwavpackdec.c index f763a8ee81..7ed14c4b9c 100644 --- a/ext/wavpack/gstwavpackdec.c +++ b/ext/wavpack/gstwavpackdec.c @@ -129,7 +129,7 @@ gst_wavpack_dec_reset (GstWavpackDec * dec) dec->sample_rate = 0; dec->depth = 0; - gst_segment_init (&dec->segment, GST_FORMAT_UNDEFINED); + gst_segment_init (&dec->segment, GST_FORMAT_TIME); dec->next_block_index = 0; } @@ -202,47 +202,6 @@ gst_wavpack_dec_sink_set_caps (GstPad * pad, GstCaps * caps) return TRUE; } -static gboolean -gst_wavpack_dec_clip_outgoing_buffer (GstWavpackDec * dec, GstBuffer * buf) -{ - gint64 start, stop, cstart, cstop, diff; - - if (dec->segment.format != GST_FORMAT_TIME) - return TRUE; - - start = GST_BUFFER_TIMESTAMP (buf); - stop = start + GST_BUFFER_DURATION (buf); - - if (gst_segment_clip (&dec->segment, GST_FORMAT_TIME, - start, stop, &cstart, &cstop)) { - - diff = cstart - start; - if (diff > 0) { - GST_BUFFER_TIMESTAMP (buf) = cstart; - GST_BUFFER_DURATION (buf) -= diff; - - diff = 4 * dec->channels - * GST_CLOCK_TIME_TO_FRAMES (diff, dec->sample_rate); - GST_BUFFER_DATA (buf) += diff; - GST_BUFFER_SIZE (buf) -= diff; - } - - diff = stop - cstop; - if (diff > 0) { - GST_BUFFER_DURATION (buf) -= diff; - - diff = 4 * dec->channels - * GST_CLOCK_TIME_TO_FRAMES (diff, dec->sample_rate); - GST_BUFFER_SIZE (buf) -= diff; - } - } else { - GST_DEBUG_OBJECT (dec, "buffer is outside configured segment"); - return FALSE; - } - - return TRUE; -} - static void gst_wavpack_dec_post_tags (GstWavpackDec * dec) { @@ -375,7 +334,8 @@ gst_wavpack_dec_chain (GstPad * pad, GstBuffer * buf) if (decoded != wph.block_samples) goto decode_error; - if (gst_wavpack_dec_clip_outgoing_buffer (dec, outbuf)) { + if ((outbuf = gst_audio_buffer_clip (outbuf, &dec->segment, + dec->sample_rate, 4 * dec->channels))) { GST_LOG_OBJECT (dec, "pushing buffer with time %" GST_TIME_FORMAT, GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (outbuf))); ret = gst_pad_push (dec->srcpad, outbuf); @@ -438,7 +398,7 @@ gst_wavpack_dec_sink_event (GstPad * pad, GstEvent * event) gst_segment_set_newsegment (&dec->segment, is_update, rate, fmt, start, end, base); } else { - gst_segment_init (&dec->segment, GST_FORMAT_UNDEFINED); + gst_segment_init (&dec->segment, GST_FORMAT_TIME); } break; } diff --git a/tests/check/elements/wavpackdec.c b/tests/check/elements/wavpackdec.c index 5a8cb87e73..7fac678559 100644 --- a/tests/check/elements/wavpackdec.c +++ b/tests/check/elements/wavpackdec.c @@ -111,6 +111,7 @@ GST_START_TEST (test_decode_frame) inbuffer = gst_buffer_new_and_alloc (sizeof (test_frame)); memcpy (GST_BUFFER_DATA (inbuffer), test_frame, sizeof (test_frame)); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); + GST_BUFFER_TIMESTAMP (inbuffer) = 0; gst_buffer_ref (inbuffer); gst_element_set_bus (wavpackdec, bus); @@ -164,6 +165,7 @@ GST_START_TEST (test_decode_frame_with_broken_header) /* break header */ GST_BUFFER_DATA (inbuffer)[2] = 'e'; ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); + GST_BUFFER_TIMESTAMP (inbuffer) = 0; gst_buffer_ref (inbuffer); gst_element_set_bus (wavpackdec, bus); @@ -201,6 +203,7 @@ GST_START_TEST (test_decode_frame_with_incomplete_frame) inbuffer = gst_buffer_new_and_alloc (sizeof (test_frame) - 2); memcpy (GST_BUFFER_DATA (inbuffer), test_frame, sizeof (test_frame) - 2); ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); + GST_BUFFER_TIMESTAMP (inbuffer) = 0; gst_buffer_ref (inbuffer); gst_element_set_bus (wavpackdec, bus);