From: Wim Taymans Date: Tue, 4 May 2010 11:36:58 +0000 (+0200) Subject: oggdemux: use the index in push mode when we can X-Git-Tag: RELEASE-0.10.30~240 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a57b461af8103c1e5a79fc63bc90ec847195932a;p=platform%2Fupstream%2Fgst-plugins-base.git oggdemux: use the index in push mode when we can When seeking in push mode, try to use the index first before we use the bitrate estimation. --- diff --git a/ext/ogg/gstoggdemux.c b/ext/ogg/gstoggdemux.c index e7c1d41..8b2460a 100644 --- a/ext/ogg/gstoggdemux.c +++ b/ext/ogg/gstoggdemux.c @@ -1956,7 +1956,7 @@ gst_ogg_demux_do_seek (GstOggDemux * ogg, GstSegment * segment, gint64 begin, end; gint64 begintime, endtime; gint64 target, keytarget; - gint64 best, best_time; + gint64 best; gint64 total; gint64 result = 0; GstFlowReturn ret; @@ -1983,22 +1983,6 @@ gst_ogg_demux_do_seek (GstOggDemux * ogg, GstSegment * segment, endtime = begintime + chain->total_time; target = position - total + begintime; - if (do_index_search (ogg, chain, begin, end, begintime, endtime, target, - &best, &best_time)) { - /* the index gave some result */ - GST_DEBUG_OBJECT (ogg, - "found offset %" G_GINT64_FORMAT " with time %" G_GUINT64_FORMAT, best, - best_time); - -#if 1 - keytarget = best_time + begintime; - best += begin; - - gst_ogg_demux_seek (ogg, best); - goto done; -#endif - } - if (!do_binary_search (ogg, chain, begin, end, begintime, endtime, target, &best)) goto seek_error; @@ -2376,36 +2360,63 @@ static gboolean gst_ogg_demux_perform_seek_push (GstOggDemux * ogg, GstEvent * event) { gint bitrate; - gboolean res; + gboolean res = TRUE; + GstFormat format; + gdouble rate; + GstSeekFlags flags; + GstSeekType start_type, stop_type; + gint64 start, stop; + GstEvent *sevent; + GstOggChain *chain; + gint64 best, best_time; - bitrate = ogg->bitrate; + gst_event_parse_seek (event, &rate, &format, &flags, + &start_type, &start, &stop_type, &stop); - if (bitrate > 0) { - GstFormat format; - gdouble rate; - GstSeekFlags flags; - GstSeekType start_type, stop_type; - gint64 start, stop; - GstEvent *sevent; + if (format != GST_FORMAT_TIME) { + GST_DEBUG_OBJECT (ogg, "can only seek on TIME"); + goto error; + } - gst_event_parse_seek (event, &rate, &format, &flags, - &start_type, &start, &stop_type, &stop); + chain = ogg->current_chain; - /* convert the seek positions to bytes */ + if (do_index_search (ogg, chain, 0, -1, 0, -1, start, &best, &best_time)) { + /* the index gave some result */ + GST_DEBUG_OBJECT (ogg, + "found offset %" G_GINT64_FORMAT " with time %" G_GUINT64_FORMAT, + best, best_time); + start = best; + } else if ((bitrate = ogg->bitrate) > 0) { + /* try with bitrate convert the seek positions to bytes */ if (start_type != GST_SEEK_TYPE_NONE) { start = gst_util_uint64_scale (start, bitrate, 8 * GST_SECOND); } if (stop_type != GST_SEEK_TYPE_NONE) { stop = gst_util_uint64_scale (stop, bitrate, 8 * GST_SECOND); } + } else { + /* we don't know */ + res = FALSE; + } + + if (res) { + GST_DEBUG_OBJECT (ogg, + "seeking to %" G_GINT64_FORMAT " - %" G_GINT64_FORMAT, start, stop); + /* do seek */ sevent = gst_event_new_seek (rate, GST_FORMAT_BYTES, flags, start_type, start, stop_type, stop); res = gst_pad_push_event (ogg->sinkpad, sevent); - } else { - res = FALSE; } + return res; + + /* ERRORS */ +error: + { + GST_DEBUG_OBJECT (ogg, "seek failed"); + return FALSE; + } } static gboolean