diff options
author | Wim Taymans <wim.taymans@gmail.com> | 2006-04-10 14:20:41 +0000 |
---|---|---|
committer | Wim Taymans <wim.taymans@gmail.com> | 2006-04-10 14:20:41 +0000 |
commit | 5b097ce855df239faee7bd170abd79f22263c4e3 (patch) | |
tree | 78b5e0f29325776274176894d11bb8b04c37d671 /gst | |
parent | 7ea44d8a2f9ba74a89eaa9059d83da6d5b05bef4 (diff) | |
download | gst-plugins-bad-5b097ce855df239faee7bd170abd79f22263c4e3.tar.gz gst-plugins-bad-5b097ce855df239faee7bd170abd79f22263c4e3.tar.bz2 gst-plugins-bad-5b097ce855df239faee7bd170abd79f22263c4e3.zip |
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.
Diffstat (limited to 'gst')
-rw-r--r-- | gst/qtdemux/qtdemux.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/gst/qtdemux/qtdemux.c b/gst/qtdemux/qtdemux.c index 689651a7..490dd130 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, |