diff options
author | Edward Hervey <bilboed@bilboed.com> | 2010-02-13 11:01:53 +0100 |
---|---|---|
committer | Edward Hervey <bilboed@bilboed.com> | 2010-02-13 14:57:59 +0100 |
commit | 0dd06da5e87a09633b3afbfe726ca49d311828d8 (patch) | |
tree | 22342f0e48471badcbaa3f6967fa23939749be2c /gst | |
parent | 7f08081016379dd163c2a1a0eb7251c5540b96f7 (diff) |
flvdemux: Speedup GstIndex usage
Used the _add_associationv variant of GstIndex since we know how many
associations we're adding. Trims up to 50% from index generation time.
Note : It would be great if the index could be generated on the fly or
on request as opposed to being fully created at startup.
Diffstat (limited to 'gst')
-rw-r--r-- | gst/flv/gstflvparse.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/gst/flv/gstflvparse.c b/gst/flv/gstflvparse.c index 43dc1eb4b..c62433fbd 100644 --- a/gst/flv/gstflvparse.c +++ b/gst/flv/gstflvparse.c @@ -425,14 +425,20 @@ gst_flv_parse_tag_script (GstFLVDemux * demux, GstBuffer * buffer) /* If an index was found and we're in push mode, insert associations */ for (i = 0; i < MIN (demux->times->len, demux->filepositions->len); i++) { guint64 time, fileposition; + static GstIndexAssociation associations[2]; time = g_array_index (demux->times, gdouble, i) * GST_SECOND; fileposition = g_array_index (demux->filepositions, gdouble, i); GST_LOG_OBJECT (demux, "adding association %" GST_TIME_FORMAT "-> %" G_GUINT64_FORMAT, GST_TIME_ARGS (time), fileposition); - gst_index_add_association (demux->index, demux->index_id, - GST_ASSOCIATION_FLAG_KEY_UNIT, GST_FORMAT_TIME, time, - GST_FORMAT_BYTES, fileposition, NULL); + associations[0].format = GST_FORMAT_TIME; + associations[0].value = time; + associations[1].format = GST_FORMAT_BYTES; + associations[1].value = fileposition; + + gst_index_add_associationv (demux->index, demux->index_id, + GST_ASSOCIATION_FLAG_KEY_UNIT, 2, + (const GstIndexAssociation *) &associations); } demux->indexed = TRUE; } @@ -1237,12 +1243,19 @@ gst_flv_parse_tag_timestamp (GstFLVDemux * demux, GstBuffer * buffer, if (demux->index && !demux->indexed && (type == 9 || (type == 8 && !demux->has_video))) { + static GstIndexAssociation associations[2]; GST_LOG_OBJECT (demux, "adding association %" GST_TIME_FORMAT "-> %" G_GUINT64_FORMAT, GST_TIME_ARGS (ret), demux->offset); - gst_index_add_association (demux->index, demux->index_id, + + associations[0].format = GST_FORMAT_TIME; + associations[0].value = ret; + associations[1].format = GST_FORMAT_BYTES; + associations[1].value = demux->offset; + + gst_index_add_associationv (demux->index, demux->index_id, (keyframe) ? GST_ASSOCIATION_FLAG_KEY_UNIT : GST_ASSOCIATION_FLAG_NONE, - GST_FORMAT_TIME, ret, GST_FORMAT_BYTES, demux->offset, NULL); + 2, (const GstIndexAssociation *) &associations); } if (demux->duration == GST_CLOCK_TIME_NONE || demux->duration < ret) |