gst/videorate/gstvideorate.c: Event handling (fixes #159986).
Original commit message from CVS: Reviewed by: Ronald S. Bultje <rbultje@ronald.bitfreak.net> * gst/videorate/gstvideorate.c: (gst_videorate_blank_data), (gst_videorate_init), (gst_videorate_chain), (gst_videorate_change_state): Event handling (fixes #159986).
This commit is contained in:
parent
50f80de3be
commit
3b7785eb8e
@ -1,3 +1,12 @@
|
|||||||
|
2004-12-19 Edward Hervey <bilboed@bilboed.com>
|
||||||
|
|
||||||
|
Reviewed by: Ronald S. Bultje <rbultje@ronald.bitfreak.net>
|
||||||
|
|
||||||
|
* gst/videorate/gstvideorate.c: (gst_videorate_blank_data),
|
||||||
|
(gst_videorate_init), (gst_videorate_chain),
|
||||||
|
(gst_videorate_change_state):
|
||||||
|
Event handling (fixes #159986).
|
||||||
|
|
||||||
2004-12-19 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
|
2004-12-19 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
|
||||||
|
|
||||||
* gst-libs/gst/riff/riff-media.c:
|
* gst-libs/gst/riff/riff-media.c:
|
||||||
|
@ -51,6 +51,7 @@ struct _GstVideorate
|
|||||||
/* video state */
|
/* video state */
|
||||||
gdouble from_fps, to_fps;
|
gdouble from_fps, to_fps;
|
||||||
guint64 next_ts;
|
guint64 next_ts;
|
||||||
|
guint64 first_ts;
|
||||||
GstBuffer *prevbuf;
|
GstBuffer *prevbuf;
|
||||||
guint64 in, out, dup, drop;
|
guint64 in, out, dup, drop;
|
||||||
|
|
||||||
@ -285,6 +286,21 @@ gst_videorate_link (GstPad * pad, const GstCaps * caps)
|
|||||||
return GST_PAD_LINK_OK;
|
return GST_PAD_LINK_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_videorate_blank_data (GstVideorate * videorate)
|
||||||
|
{
|
||||||
|
GST_DEBUG ("resetting data");
|
||||||
|
if (videorate->prevbuf)
|
||||||
|
gst_buffer_unref (videorate->prevbuf);
|
||||||
|
videorate->prevbuf = NULL;
|
||||||
|
videorate->in = 0;
|
||||||
|
videorate->out = 0;
|
||||||
|
videorate->drop = 0;
|
||||||
|
videorate->dup = 0;
|
||||||
|
videorate->next_ts = 0LL;
|
||||||
|
videorate->first_ts = 0LL;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_videorate_init (GstVideorate * videorate)
|
gst_videorate_init (GstVideorate * videorate)
|
||||||
{
|
{
|
||||||
@ -306,11 +322,7 @@ gst_videorate_init (GstVideorate * videorate)
|
|||||||
gst_pad_set_getcaps_function (videorate->srcpad, gst_videorate_getcaps);
|
gst_pad_set_getcaps_function (videorate->srcpad, gst_videorate_getcaps);
|
||||||
gst_pad_set_link_function (videorate->srcpad, gst_videorate_link);
|
gst_pad_set_link_function (videorate->srcpad, gst_videorate_link);
|
||||||
|
|
||||||
videorate->prevbuf = NULL;
|
gst_videorate_blank_data (videorate);
|
||||||
videorate->in = 0;
|
|
||||||
videorate->out = 0;
|
|
||||||
videorate->drop = 0;
|
|
||||||
videorate->dup = 0;
|
|
||||||
videorate->silent = DEFAULT_SILENT;
|
videorate->silent = DEFAULT_SILENT;
|
||||||
videorate->new_pref = DEFAULT_NEW_PREF;
|
videorate->new_pref = DEFAULT_NEW_PREF;
|
||||||
}
|
}
|
||||||
@ -324,28 +336,48 @@ gst_videorate_chain (GstPad * pad, GstData * data)
|
|||||||
if (GST_IS_EVENT (data)) {
|
if (GST_IS_EVENT (data)) {
|
||||||
GstEvent *event = GST_EVENT (data);
|
GstEvent *event = GST_EVENT (data);
|
||||||
|
|
||||||
|
if (!videorate->prevbuf) {
|
||||||
gst_pad_event_default (pad, event);
|
gst_pad_event_default (pad, event);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (GST_EVENT_TYPE (event) == GST_EVENT_DISCONTINUOUS) {
|
||||||
|
gint64 etime;
|
||||||
|
|
||||||
|
if (!(gst_event_discont_get_value (event, GST_FORMAT_TIME, &etime)))
|
||||||
|
GST_WARNING ("Got discont but doesn't have GST_FORMAT_TIME value");
|
||||||
|
else {
|
||||||
|
gst_videorate_blank_data (videorate);
|
||||||
|
videorate->first_ts = etime;
|
||||||
|
}
|
||||||
|
gst_pad_event_default (pad, event);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
buf = GST_BUFFER (data);
|
buf = GST_BUFFER (data);
|
||||||
|
|
||||||
/* pull in 2 buffers */
|
/* pull in 2 buffers */
|
||||||
if (videorate->prevbuf == NULL) {
|
if (videorate->prevbuf == NULL) {
|
||||||
|
/* We're sure it's a GstBuffer here */
|
||||||
videorate->prevbuf = buf;
|
videorate->prevbuf = buf;
|
||||||
|
videorate->next_ts = videorate->first_ts = GST_BUFFER_TIMESTAMP (buf);
|
||||||
} else {
|
} else {
|
||||||
GstClockTime prevtime, intime;
|
GstClockTime prevtime, intime;
|
||||||
gint count = 0;
|
gint count = 0;
|
||||||
gint64 diff1, diff2;
|
gint64 diff1, diff2;
|
||||||
|
|
||||||
prevtime = GST_BUFFER_TIMESTAMP (videorate->prevbuf);
|
prevtime = GST_BUFFER_TIMESTAMP (videorate->prevbuf);
|
||||||
intime = GST_BUFFER_TIMESTAMP (buf);
|
/* If it's a GstEvent, we give him the time of the next outputed frame */
|
||||||
|
intime = (GST_IS_EVENT (data))
|
||||||
|
? videorate->next_ts +
|
||||||
|
(1 / videorate->to_fps * GST_SECOND) : GST_BUFFER_TIMESTAMP (buf);
|
||||||
|
|
||||||
GST_LOG_OBJECT (videorate,
|
GST_LOG_OBJECT (videorate,
|
||||||
"prev buf %" GST_TIME_FORMAT " new buf %" GST_TIME_FORMAT
|
"prev buf %" GST_TIME_FORMAT " new buf %" GST_TIME_FORMAT
|
||||||
" outgoing ts %" GST_TIME_FORMAT, GST_TIME_ARGS (prevtime),
|
" outgoing ts %" GST_TIME_FORMAT, GST_TIME_ARGS (prevtime),
|
||||||
GST_TIME_ARGS (intime), GST_TIME_ARGS (videorate->next_ts));
|
GST_TIME_ARGS (intime), GST_TIME_ARGS (videorate->next_ts));
|
||||||
|
|
||||||
|
if (GST_IS_BUFFER (data))
|
||||||
videorate->in++;
|
videorate->in++;
|
||||||
|
|
||||||
/* got 2 buffers, see which one is the best */
|
/* got 2 buffers, see which one is the best */
|
||||||
@ -375,7 +407,9 @@ gst_videorate_chain (GstPad * pad, GstData * data)
|
|||||||
GST_BUFFER_SIZE (videorate->prevbuf));
|
GST_BUFFER_SIZE (videorate->prevbuf));
|
||||||
GST_BUFFER_TIMESTAMP (outbuf) = videorate->next_ts;
|
GST_BUFFER_TIMESTAMP (outbuf) = videorate->next_ts;
|
||||||
videorate->out++;
|
videorate->out++;
|
||||||
videorate->next_ts = videorate->out / videorate->to_fps * GST_SECOND;
|
videorate->next_ts =
|
||||||
|
videorate->first_ts +
|
||||||
|
(videorate->out / videorate->to_fps * GST_SECOND);
|
||||||
GST_BUFFER_DURATION (outbuf) =
|
GST_BUFFER_DURATION (outbuf) =
|
||||||
videorate->next_ts - GST_BUFFER_TIMESTAMP (outbuf);
|
videorate->next_ts - GST_BUFFER_TIMESTAMP (outbuf);
|
||||||
gst_pad_push (videorate->srcpad, GST_DATA (outbuf));
|
gst_pad_push (videorate->srcpad, GST_DATA (outbuf));
|
||||||
@ -405,14 +439,17 @@ gst_videorate_chain (GstPad * pad, GstData * data)
|
|||||||
}
|
}
|
||||||
GST_LOG_OBJECT (videorate,
|
GST_LOG_OBJECT (videorate,
|
||||||
"left loop, putting new in old, diff1 %" GST_TIME_FORMAT
|
"left loop, putting new in old, diff1 %" GST_TIME_FORMAT
|
||||||
", diff2 %" GST_TIME_FORMAT
|
", diff2 %" GST_TIME_FORMAT ", next_ts %" GST_TIME_FORMAT
|
||||||
", in %lld, out %lld, drop %lld, dup %lld", GST_TIME_ARGS (diff1),
|
", in %lld, out %lld, drop %lld, dup %lld", GST_TIME_ARGS (diff1),
|
||||||
GST_TIME_ARGS (diff2), videorate->in, videorate->out, videorate->drop,
|
GST_TIME_ARGS (diff2), GST_TIME_ARGS (videorate->next_ts),
|
||||||
videorate->dup);
|
videorate->in, videorate->out, videorate->drop, videorate->dup);
|
||||||
|
|
||||||
|
if (GST_IS_BUFFER (data)) {
|
||||||
/* swap in new one when it's the best */
|
/* swap in new one when it's the best */
|
||||||
gst_buffer_unref (videorate->prevbuf);
|
gst_buffer_unref (videorate->prevbuf);
|
||||||
videorate->prevbuf = buf;
|
videorate->prevbuf = buf;
|
||||||
|
} else
|
||||||
|
gst_pad_event_default (pad, GST_EVENT (data));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -473,6 +510,7 @@ gst_videorate_change_state (GstElement * element)
|
|||||||
|
|
||||||
switch (GST_STATE_TRANSITION (element)) {
|
switch (GST_STATE_TRANSITION (element)) {
|
||||||
case GST_STATE_PAUSED_TO_READY:
|
case GST_STATE_PAUSED_TO_READY:
|
||||||
|
gst_videorate_blank_data (GST_VIDEORATE (element));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user