mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
matroskademux: set limit how much to backtrack to find a keyframe
If we seek without an index and land on a cluster that starts with a delta frame. https://bugzilla.gnome.org/show_bug.cgi?id=790696
This commit is contained in:
parent
ffb4533137
commit
2990f0730a
1 changed files with 17 additions and 0 deletions
|
@ -2082,6 +2082,12 @@ bit_reader_skip_ebml_num (GstBitReader * br)
|
|||
* (random value, mostly for sanity checking) */
|
||||
#define MAX_CLUSTER_INFO_PROBE_LENGTH 256
|
||||
|
||||
/* Don't scan back more than this much in time from the cluster we originally
|
||||
* landed on. This is mostly a sanity check in case a file always has keyframes
|
||||
* in the middle of clusters and never at the beginning. Without this we would
|
||||
* always scan back to the beginning of the file in that case. */
|
||||
#define MAX_CLUSTER_BACKTRACK_SECS 30
|
||||
|
||||
static gboolean
|
||||
gst_matroska_demux_peek_cluster_info (GstMatroskaDemux * demux,
|
||||
ClusterInfo * cluster, guint64 offset)
|
||||
|
@ -2243,6 +2249,17 @@ gst_matroska_demux_scan_back_for_keyframe_cluster (GstMatroskaDemux * demux,
|
|||
break;
|
||||
}
|
||||
|
||||
if (cluster.time != GST_CLOCK_TIME_NONE) {
|
||||
GstClockTimeDiff distance = GST_CLOCK_DIFF (cluster.time, *cluster_time);
|
||||
|
||||
if (distance < 0 || distance > MAX_CLUSTER_BACKTRACK_SECS * GST_SECOND) {
|
||||
GST_DEBUG_OBJECT (demux, "Haven't found cluster with keyframe within "
|
||||
"%u secs of original seek target cluster, stopping",
|
||||
MAX_CLUSTER_BACKTRACK_SECS);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
off -= cluster.prev_size;
|
||||
if (off <= first_cluster_offset) {
|
||||
GST_LOG_OBJECT (demux, "Reached first cluster, stopping");
|
||||
|
|
Loading…
Reference in a new issue