From 6425f71b72f8ecf098bf4fe9c7ad6c5962581423 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 28 Sep 2006 11:46:26 +0000 Subject: [PATCH] gst/audiorate/gstaudiorate.c: Set caps on outgoing buffers. Original commit message from CVS: * gst/audiorate/gstaudiorate.c: (gst_audio_rate_chain): Set caps on outgoing buffers. * gst/videorate/gstvideorate.c: (gst_video_rate_flush_prev), (gst_video_rate_event), (gst_video_rate_chain): * gst/videorate/gstvideorate.h: Fix videorate some more. Fixes #357977 --- ChangeLog | 10 ++++++++++ gst/audiorate/gstaudiorate.c | 3 +++ gst/videorate/gstvideorate.c | 39 +++++++++++++++++++++------------------ gst/videorate/gstvideorate.h | 3 ++- 4 files changed, 36 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index 081dfd8..b72e4ee 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2006-09-28 Wim Taymans + + * gst/audiorate/gstaudiorate.c: (gst_audio_rate_chain): + Set caps on outgoing buffers. + + * gst/videorate/gstvideorate.c: (gst_video_rate_flush_prev), + (gst_video_rate_event), (gst_video_rate_chain): + * gst/videorate/gstvideorate.h: + Fix videorate some more. Fixes #357977 + 2006-09-28 Tim-Philipp Müller * tests/check/elements/adder.c: (adder_suite): diff --git a/gst/audiorate/gstaudiorate.c b/gst/audiorate/gstaudiorate.c index 598c8d8..db58c93 100644 --- a/gst/audiorate/gstaudiorate.c +++ b/gst/audiorate/gstaudiorate.c @@ -553,6 +553,7 @@ gst_audio_rate_chain (GstPad * pad, GstBuffer * buf) GST_BUFFER_FLAG_SET (fill, GST_BUFFER_FLAG_DISCONT); audiorate->discont = FALSE; } + gst_buffer_set_caps (fill, GST_PAD_CAPS (audiorate->srcpad)); ret = gst_pad_push (audiorate->srcpad, fill); if (ret != GST_FLOW_OK) @@ -600,6 +601,8 @@ gst_audio_rate_chain (GstPad * pad, GstBuffer * buf) gst_buffer_unref (buf); buf = trunc; + gst_buffer_set_caps (buf, GST_PAD_CAPS (audiorate->srcpad)); + audiorate->drop += truncsamples; } } diff --git a/gst/videorate/gstvideorate.c b/gst/videorate/gstvideorate.c index d4a9e36..3a31fa8 100644 --- a/gst/videorate/gstvideorate.c +++ b/gst/videorate/gstvideorate.c @@ -435,19 +435,20 @@ gst_video_rate_flush_prev (GstVideoRate * videorate) /* this is the timestamp we put on the buffer */ push_ts = videorate->next_ts; - GST_BUFFER_TIMESTAMP (outbuf) = push_ts; videorate->out++; if (videorate->to_rate_numerator) { - videorate->next_ts = + /* interpolate next expected timestamp in the segment */ + videorate->next_ts = videorate->segment.accum + videorate->segment.start + gst_util_uint64_scale (videorate->out, videorate->to_rate_denominator * GST_SECOND, videorate->to_rate_numerator); - GST_BUFFER_DURATION (outbuf) = - videorate->next_ts - GST_BUFFER_TIMESTAMP (outbuf); + GST_BUFFER_DURATION (outbuf) = videorate->next_ts - push_ts; } + /* adapt for looping, bring back to time in current segment. */ - GST_BUFFER_TIMESTAMP (outbuf) -= videorate->segment.accum; + GST_BUFFER_TIMESTAMP (outbuf) = push_ts - videorate->segment.accum; + gst_buffer_set_caps (outbuf, GST_PAD_CAPS (videorate->srcpad)); GST_LOG_OBJECT (videorate, @@ -489,25 +490,24 @@ gst_video_rate_event (GstPad * pad, GstEvent * event) case GST_EVENT_NEWSEGMENT: { gint64 start, stop, time; - gdouble rate; + gdouble rate, arate; gboolean update; GstFormat format; - gst_event_parse_new_segment (event, &update, &rate, &format, &start, - &stop, &time); + gst_event_parse_new_segment_full (event, &update, &rate, &arate, &format, + &start, &stop, &time); - if (format != videorate->segment.format) + if (format != GST_FORMAT_TIME) goto format_error; + GST_DEBUG_OBJECT (videorate, "handle NEWSEGMENT"); + /* We just want to update the accumulated stream_time */ - gst_segment_set_newsegment (&videorate->segment, update, rate, + gst_segment_set_newsegment_full (&videorate->segment, update, rate, arate, format, start, stop, time); - GST_DEBUG_OBJECT (videorate, "Updated segment.accum:%" GST_TIME_FORMAT - " segment.start:%" GST_TIME_FORMAT " segment.stop:%" - GST_TIME_FORMAT, GST_TIME_ARGS (videorate->segment.accum), - GST_TIME_ARGS (videorate->segment.start), - GST_TIME_ARGS (videorate->segment.stop)); + GST_DEBUG_OBJECT (videorate, "updated segment: %" GST_SEGMENT_FORMAT, + &videorate->segment); break; } case GST_EVENT_EOS: @@ -561,14 +561,17 @@ gst_video_rate_chain (GstPad * pad, GstBuffer * buffer) GST_DEBUG_OBJECT (videorate, "got buffer with timestamp %" GST_TIME_FORMAT, GST_TIME_ARGS (in_ts)); - intime = gst_segment_to_running_time (&videorate->segment, - GST_FORMAT_TIME, in_ts); + /* the input time is the time in the segment + all previously accumulated + * segments */ + intime = in_ts + videorate->segment.accum; /* we need to have two buffers to compare */ if (videorate->prevbuf == NULL) { gst_video_rate_swap_prev (videorate, buffer, intime); videorate->in++; - videorate->next_ts = 0; + /* new buffer, we expect to output a buffer that matches the first + * timestamp in the segment */ + videorate->next_ts = videorate->segment.start; } else { GstClockTime prevtime; gint count = 0; diff --git a/gst/videorate/gstvideorate.h b/gst/videorate/gstvideorate.h index 19007d9..36cae5c 100644 --- a/gst/videorate/gstvideorate.h +++ b/gst/videorate/gstvideorate.h @@ -55,11 +55,12 @@ struct _GstVideoRate guint64 next_ts; /* Timestamp of next buffer to output */ GstBuffer *prevbuf; guint64 prev_ts; /* Previous buffer timestamp */ - guint64 in, out, dup, drop; /* segment handling */ GstSegment segment; + /* properties */ + guint64 in, out, dup, drop; gboolean silent; gdouble new_pref; }; -- 2.7.4