mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-03-28 20:05:38 +00:00
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.
This commit is contained in:
parent
7f08081016
commit
0dd06da5e8
1 changed files with 18 additions and 5 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue