[gst-cvs] gst-plugins-good: qtdemux: simplify logic to calculate duration

Wim Taymans wtay at kemper.freedesktop.org
Tue Jan 5 06:57:37 PST 2010


Module: gst-plugins-good
Branch: master
Commit: 22eb18f828e9c6208fadd67b193261780b019255
URL:    http://cgit.freedesktop.org/gstreamer/gst-plugins-good/commit/?id=22eb18f828e9c6208fadd67b193261780b019255

Author: Wim Taymans <wim.taymans at collabora.co.uk>
Date:   Mon Jan  4 13:41:18 2010 +0100

qtdemux: simplify logic to calculate duration

Since we no longer store the timestamp and duration in nanoseconds, we can now
simply store the duration as-is.

---

 gst/qtdemux/qtdemux.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/gst/qtdemux/qtdemux.c b/gst/qtdemux/qtdemux.c
index 1652f0b..54e264b 100644
--- a/gst/qtdemux/qtdemux.c
+++ b/gst/qtdemux/qtdemux.c
@@ -4320,11 +4320,12 @@ qtdemux_parse_samples (GstQTDemux * qtdemux, QtDemuxStream * stream, guint32 n)
             "sample %d: timestamp %" GST_TIME_FORMAT ", size %u",
             j, GST_TIME_ARGS (gst_util_uint64_scale (stream->stco_sample_index,
                     GST_SECOND, stream->timescale)), stream->samples[j].size);
+
         stream->samples[j].timestamp = stream->stco_sample_index;
-        stream->stco_sample_index += stream->samples_per_chunk;
-        stream->samples[j].duration =
-            stream->stco_sample_index - stream->samples[j].timestamp;
+        stream->samples[j].duration = stream->samples_per_chunk;
         stream->samples[j].keyframe = TRUE;
+
+        stream->stco_sample_index += stream->samples_per_chunk;
         stream->stsc_chunk_index++;
       }
     }
@@ -4358,11 +4359,12 @@ done2:
             "sample %d: index %d, timestamp %" GST_TIME_FORMAT,
             index, j, GST_TIME_ARGS (gst_util_uint64_scale (stream->stts_time,
                     GST_SECOND, stream->timescale)));
+
         stream->samples[index].timestamp = stream->stts_time;
+        stream->samples[index].duration = stream->stts_duration;
+
         /* add non-scaled values to avoid rounding errors */
         stream->stts_time += stream->stts_duration;
-        stream->samples[index].duration =
-            stream->stts_time - stream->samples[index].timestamp;
         stream->stts_sample_index++;
         index++;
         if (G_UNLIKELY (index > n))





More information about the Gstreamer-commits mailing list