From 31c26a4551fbde1bd254e180a41a4563f7ea9acf Mon Sep 17 00:00:00 2001 From: Mark Nauwelaerts Date: Thu, 10 Mar 2011 16:02:42 +0100 Subject: [PATCH] qtmux: also track original PTS buffer timestamp in reorder dts-method --- gst/quicktime/gstqtmux.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gst/quicktime/gstqtmux.c b/gst/quicktime/gstqtmux.c index 1477db7c8e..f66f65c542 100644 --- a/gst/quicktime/gstqtmux.c +++ b/gst/quicktime/gstqtmux.c @@ -2028,6 +2028,8 @@ gst_qt_mux_get_asc_buffer_ts (GstQTMux * qtmux, GstQTPad * pad, GstBuffer * buf) pad->buf_entries[pad->buf_head++] = NULL; pad->buf_head %= wrap; buf = gst_buffer_make_metadata_writable (buf); + /* track original ts (= pts ?) for later */ + GST_BUFFER_OFFSET_END (buf) = GST_BUFFER_TIMESTAMP (buf); GST_BUFFER_TIMESTAMP (buf) = ts; GST_DEBUG_OBJECT (qtmux, "next buffer uses reordered ts %" GST_TIME_FORMAT, GST_TIME_ARGS (ts)); @@ -2105,7 +2107,7 @@ again: * - collect some buffers and re-order timestamp, * then process the oldest buffer with smallest timestamps. * This should typically compensate for some codec's handywork with ts. - * ... but in case this makes ts end up where not expected: + * ... but in case this makes ts end up where not expected, in DTS_METHOD_ASC: * - keep each ts with its buffer and still keep a list of most recent X ts, * use the (ascending) minimum of those as DTS (and the difference as ts delta), * and use this DTS as a basis to obtain a (positive) CTS offset. @@ -2273,7 +2275,9 @@ again: if ((pad->have_dts || qtmux->guess_pts) && pad->is_out_of_order) { guint64 pts; - pts = gst_util_uint64_scale_round (GST_BUFFER_TIMESTAMP (last_buf), + pts = qtmux->dts_method == DTS_METHOD_REORDER ? + GST_BUFFER_OFFSET_END (last_buf) : GST_BUFFER_TIMESTAMP (last_buf); + pts = gst_util_uint64_scale_round (pts, atom_trak_get_timescale (pad->trak), GST_SECOND); pts_offset = (gint64) (pts - last_dts); do_pts = TRUE;