mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-30 04:00:37 +00:00
matroskademux: calculate segment duration after parsing all the IDs
Since the segment duration is given in terms of the GST_MATROSKA_ID_TIMECODESCALE we should only convert it into nanoseconds when we are sure that any scale specified in the file has been read. https://bugzilla.gnome.org/show_bug.cgi?id=650258
This commit is contained in:
parent
5b99b910ec
commit
bdc464a778
1 changed files with 14 additions and 12 deletions
|
@ -3501,6 +3501,7 @@ static GstFlowReturn
|
|||
gst_matroska_demux_parse_info (GstMatroskaDemux * demux, GstEbmlRead * ebml)
|
||||
{
|
||||
GstFlowReturn ret = GST_FLOW_OK;
|
||||
gdouble dur_f = -1.0;
|
||||
guint32 id;
|
||||
|
||||
DEBUG_ELEMENT_START (demux, ebml, "SegmentInfo");
|
||||
|
@ -3529,23 +3530,15 @@ gst_matroska_demux_parse_info (GstMatroskaDemux * demux, GstEbmlRead * ebml)
|
|||
}
|
||||
|
||||
case GST_MATROSKA_ID_DURATION:{
|
||||
gdouble num;
|
||||
GstClockTime dur;
|
||||
|
||||
if ((ret = gst_ebml_read_float (ebml, &id, &num)) != GST_FLOW_OK)
|
||||
if ((ret = gst_ebml_read_float (ebml, &id, &dur_f)) != GST_FLOW_OK)
|
||||
break;
|
||||
|
||||
if (num <= 0.0) {
|
||||
GST_WARNING_OBJECT (demux, "Invalid duration %lf", num);
|
||||
if (dur_f <= 0.0) {
|
||||
GST_WARNING_OBJECT (demux, "Invalid duration %lf", dur_f);
|
||||
break;
|
||||
}
|
||||
|
||||
GST_DEBUG_OBJECT (demux, "Duration: %lf", num);
|
||||
|
||||
dur = gst_gdouble_to_guint64 (num *
|
||||
gst_guint64_to_gdouble (demux->time_scale));
|
||||
if (GST_CLOCK_TIME_IS_VALID (dur) && dur <= G_MAXINT64)
|
||||
gst_segment_set_duration (&demux->segment, GST_FORMAT_TIME, dur);
|
||||
GST_DEBUG_OBJECT (demux, "Duration: %lf", dur_f);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -3616,6 +3609,15 @@ gst_matroska_demux_parse_info (GstMatroskaDemux * demux, GstEbmlRead * ebml)
|
|||
}
|
||||
}
|
||||
|
||||
if (dur_f > 0.0) {
|
||||
GstClockTime dur_u;
|
||||
|
||||
dur_u = gst_gdouble_to_guint64 (dur_f *
|
||||
gst_guint64_to_gdouble (demux->time_scale));
|
||||
if (GST_CLOCK_TIME_IS_VALID (dur_u) && dur_u <= G_MAXINT64)
|
||||
gst_segment_set_duration (&demux->segment, GST_FORMAT_TIME, dur_u);
|
||||
}
|
||||
|
||||
DEBUG_ELEMENT_STOP (demux, ebml, "SegmentInfo", ret);
|
||||
|
||||
demux->segmentinfo_parsed = TRUE;
|
||||
|
|
Loading…
Reference in a new issue