Commit 645141a6 authored by Sebastian Dröge's avatar Sebastian Dröge 🍵
Browse files

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.
parent 98ec7850
2007-07-24 Sebastian Dröge <slomo@circular-chaos.org>
* 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 <wim.taymans@gmail.com>
* gst/qtdemux/qtdemux.c: (gst_qtdemux_activate_segment),
......
......@@ -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 ****
......
......@@ -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;
}
......
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment