From 5b097ce855df239faee7bd170abd79f22263c4e3 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 10 Apr 2006 14:20:41 +0000 Subject: [PATCH] gst/qtdemux/qtdemux.c: Fix framerate calculation. Original commit message from CVS: * gst/qtdemux/qtdemux.c: (gst_qtdemux_add_stream), (qtdemux_parse_trak): Fix framerate calculation. --- ChangeLog | 6 ++++++ gst/qtdemux/qtdemux.c | 15 +++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0bd10af4f9..fcb359a2d8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-04-10 Wim Taymans + + * gst/qtdemux/qtdemux.c: (gst_qtdemux_add_stream), + (qtdemux_parse_trak): + Fix framerate calculation. + 2006-04-10 Tim-Philipp Müller * ext/swfdec/gstswfdec.c: (gst_swfdecbuffer_class_init): diff --git a/gst/qtdemux/qtdemux.c b/gst/qtdemux/qtdemux.c index 689651a789..490dd13013 100644 --- a/gst/qtdemux/qtdemux.c +++ b/gst/qtdemux/qtdemux.c @@ -105,6 +105,8 @@ struct _QtDemuxStream guint32 n_samples; QtDemuxSample *samples; gboolean all_keyframe; /* TRUE when all samples are keyframes (no stss) */ + guint32 min_duration; /* duration of dirst sample, used for figuring out + the framerate, in timescale units */ /* if we use chunks or samples */ gboolean sampled; @@ -1757,16 +1759,17 @@ gst_qtdemux_add_stream (GstQTDemux * qtdemux, gst_pad_new_from_static_template (&gst_qtdemux_videosrc_template, name); g_free (name); - /* guess fps, FIXME */ - if ((stream->n_samples == 1) && (stream->samples[0].duration == 0)) { + /* fps is calculated base on the duration of the first frames since + * qt does not have a fixed framerate. */ + if ((stream->n_samples == 1) && (stream->min_duration == 0)) { stream->fps_n = 0; stream->fps_d = 1; } else { stream->fps_n = stream->timescale; - if (stream->samples[0].duration == 0) + if (stream->min_duration == 0) stream->fps_d = 1; else - stream->fps_d = stream->samples[0].duration; + stream->fps_d = stream->min_duration; } if (stream->caps) { @@ -3368,6 +3371,7 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak) n_sample_times = QTDEMUX_GUINT32_GET (stts->data + 12); timestamp = 0; + stream->min_duration = 0; time = 0; index = 0; for (i = 0; i < n_sample_times; i++) { @@ -3381,6 +3385,9 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak) index, GST_TIME_ARGS (timestamp)); samples[index].timestamp = timestamp; + /* take first duration for fps */ + if (stream->min_duration == 0) + stream->min_duration = duration; /* add non-scaled values to avoid rounding errors */ time += duration; timestamp = gst_util_uint64_scale_int (time,