Commit 346301e9 authored by Michael Smith's avatar Michael Smith
Browse files

ext/theora/theoraparse.c: Fix flushing.

Original commit message from CVS:
* ext/theora/theoraparse.c: (parse_granulepos),
(theora_parse_drain_queue_prematurely),
(theora_parse_queue_buffer), (theora_parse_sink_event):
Fix flushing.
Fix invalid granulepos outputs when starting with a non-keyframe.
parent 077ba914
2006-05-05 Michael Smith <msmith@fluendo.com>
* ext/theora/theoraparse.c: (parse_granulepos),
(theora_parse_drain_queue_prematurely),
(theora_parse_queue_buffer), (theora_parse_sink_event):
Fix flushing.
Fix invalid granulepos outputs when starting with a non-keyframe.
2006-05-05 Jan Schmidt <thaytan@mad.scientist.com>
 
* gst/typefind/gsttypefindfunctions.c: (mpeg2_sys_type_find),
......
......@@ -249,8 +249,13 @@ static void
parse_granulepos (gint64 granulepos, gint shift, gint64 * keyframe,
gint64 * frame)
{
*keyframe = granulepos >> shift;
*frame = *keyframe + (granulepos & ((1 << shift) - 1));
gint64 kf;
kf = granulepos >> shift;
if (keyframe)
*keyframe = kf;
if (frame)
*frame = kf + (granulepos & ((1 << shift) - 1));
}
static gboolean
......@@ -307,6 +312,20 @@ theora_parse_drain_queue_prematurely (GstTheoraParse * parse)
/* we have a keyframe */
parse->prev_keyframe = parse->prev_frame;
if (parse->prev_keyframe < 0) {
if (GST_BUFFER_OFFSET_END_IS_VALID (buf)) {
parse_granulepos (GST_BUFFER_OFFSET_END (buf), parse->shift,
&parse->prev_keyframe, NULL);
} else {
/* No previous keyframe known; can't extract one from this frame. That
* means we can't do any valid output for this frame, just continue to
* the next frame.
*/
gst_buffer_unref (buf);
continue;
}
}
ret = theora_parse_push_buffer (parse, buf, parse->prev_keyframe,
parse->prev_frame);
......@@ -361,8 +380,13 @@ theora_parse_queue_buffer (GstTheoraParse * parse, GstBuffer * buf)
g_queue_push_tail (parse->buffer_queue, buf);
if (GST_BUFFER_OFFSET_END_IS_VALID (buf))
if (GST_BUFFER_OFFSET_END_IS_VALID (buf)) {
if (parse->prev_keyframe < 0) {
parse_granulepos (GST_BUFFER_OFFSET_END (buf), parse->shift,
&parse->prev_keyframe, NULL);
}
ret = theora_parse_drain_queue (parse, GST_BUFFER_OFFSET_END (buf));
}
return ret;
}
......@@ -405,7 +429,7 @@ theora_parse_sink_event (GstPad * pad, GstEvent * event)
parse = GST_THEORA_PARSE (gst_pad_get_parent (pad));
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_FLUSH_START:
case GST_EVENT_FLUSH_STOP:
theora_parse_clear_queue (parse);
parse->prev_keyframe = -1;
parse->prev_frame = -1;
......
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