qtmux: remove subtraction that makes PTS/DTS start from 0

As qt uses durations, it doesn't matter, only the difference
between consecutive buffers is important. Also, collectpads
already replaces PTS/DTS with the running times for them.
This commit is contained in:
Thiago Santos 2015-04-07 00:53:35 -03:00
parent 9f7c659ff0
commit 5780afe131

View file

@ -2330,21 +2330,6 @@ init:
return ret; return ret;
} }
static void
check_and_subtract_ts (GstQTMux * qtmux, GstClockTime * ts_a, GstClockTime ts_b)
{
if (G_LIKELY (GST_CLOCK_TIME_IS_VALID (*ts_a))) {
if (G_LIKELY (*ts_a >= ts_b)) {
*ts_a -= ts_b;
} else {
*ts_a = 0;
GST_WARNING_OBJECT (qtmux, "Subtraction would result in negative value, "
"using 0 as result");
}
}
}
static GstFlowReturn static GstFlowReturn
gst_qt_mux_register_and_push_sample (GstQTMux * qtmux, GstQTPad * pad, gst_qt_mux_register_and_push_sample (GstQTMux * qtmux, GstQTPad * pad,
GstBuffer * buffer, gboolean is_last_buffer, guint nsamples, GstBuffer * buffer, gboolean is_last_buffer, guint nsamples,
@ -2408,13 +2393,6 @@ gst_qt_mux_add_buffer (GstQTMux * qtmux, GstQTPad * pad, GstBuffer * buf)
buf = pad->prepare_buf_func (pad, buf, qtmux); buf = pad->prepare_buf_func (pad, buf, qtmux);
} }
if (G_LIKELY (buf != NULL && GST_CLOCK_TIME_IS_VALID (pad->first_ts) &&
pad->first_ts != 0)) {
buf = gst_buffer_make_writable (buf);
check_and_subtract_ts (qtmux, &GST_BUFFER_DTS (buf), pad->first_ts);
check_and_subtract_ts (qtmux, &GST_BUFFER_PTS (buf), pad->first_ts);
}
last_buf = pad->last_buf; last_buf = pad->last_buf;
/* DTS delta is used to calculate sample duration. /* DTS delta is used to calculate sample duration.
@ -2429,11 +2407,7 @@ gst_qt_mux_add_buffer (GstQTMux * qtmux, GstQTPad * pad, GstBuffer * buf)
GST_BUFFER_DURATION (last_buf) : 0; GST_BUFFER_DURATION (last_buf) : 0;
buf = gst_buffer_make_writable (buf); buf = gst_buffer_make_writable (buf);
GST_BUFFER_DTS (buf) = GST_BUFFER_DTS (buf) = 0; /* running-time 0 */
gst_segment_to_running_time (&pad->collect.segment, GST_FORMAT_TIME,
pad->collect.segment.start);
if (GST_CLOCK_TIME_IS_VALID (pad->first_ts))
check_and_subtract_ts (qtmux, &GST_BUFFER_DTS (buf), pad->first_ts);
if (last_buf if (last_buf
&& (GST_BUFFER_DTS (last_buf) + last_buf_duration) > && (GST_BUFFER_DTS (last_buf) + last_buf_duration) >
@ -2471,7 +2445,6 @@ gst_qt_mux_add_buffer (GstQTMux * qtmux, GstQTPad * pad, GstBuffer * buf)
/* if this is the first buffer, store the timestamp */ /* if this is the first buffer, store the timestamp */
if (G_UNLIKELY (pad->first_ts == GST_CLOCK_TIME_NONE) && last_buf) { if (G_UNLIKELY (pad->first_ts == GST_CLOCK_TIME_NONE) && last_buf) {
if (GST_BUFFER_DTS_IS_VALID (last_buf)) { if (GST_BUFFER_DTS_IS_VALID (last_buf)) {
/* first pad always has DTS. If it was not provided by upstream it was set to segment start */
pad->first_ts = GST_BUFFER_DTS (last_buf); pad->first_ts = GST_BUFFER_DTS (last_buf);
} else if (GST_BUFFER_PTS_IS_VALID (last_buf)) { } else if (GST_BUFFER_PTS_IS_VALID (last_buf)) {
pad->first_ts = GST_BUFFER_PTS (last_buf); pad->first_ts = GST_BUFFER_PTS (last_buf);
@ -2479,23 +2452,14 @@ gst_qt_mux_add_buffer (GstQTMux * qtmux, GstQTPad * pad, GstBuffer * buf)
if (GST_CLOCK_TIME_IS_VALID (pad->first_ts)) { if (GST_CLOCK_TIME_IS_VALID (pad->first_ts)) {
GST_DEBUG ("setting first_ts to %" G_GUINT64_FORMAT, pad->first_ts); GST_DEBUG ("setting first_ts to %" G_GUINT64_FORMAT, pad->first_ts);
last_buf = gst_buffer_make_writable (last_buf);
check_and_subtract_ts (qtmux, &GST_BUFFER_DTS (last_buf), pad->first_ts);
check_and_subtract_ts (qtmux, &GST_BUFFER_PTS (last_buf), pad->first_ts);
if (buf) {
buf = gst_buffer_make_writable (buf);
check_and_subtract_ts (qtmux, &GST_BUFFER_DTS (buf), pad->first_ts);
check_and_subtract_ts (qtmux, &GST_BUFFER_PTS (buf), pad->first_ts);
}
} else { } else {
GST_ERROR_OBJECT (qtmux, "First buffer for pad %s has no timestamp, " GST_WARNING_OBJECT (qtmux, "First buffer for pad %s has no timestamp, "
"using 0 as first timestamp", GST_PAD_NAME (pad->collect.pad)); "using 0 as first timestamp", GST_PAD_NAME (pad->collect.pad));
pad->first_ts = 0; pad->first_ts = 0;
} }
GST_DEBUG_OBJECT (qtmux, "Stored first timestamp for pad %s %" GST_DEBUG_OBJECT (qtmux, "Stored first timestamp for pad %s %"
GST_TIME_FORMAT, GST_PAD_NAME (pad->collect.pad), GST_TIME_FORMAT, GST_PAD_NAME (pad->collect.pad),
GST_TIME_ARGS (pad->first_ts)); GST_TIME_ARGS (pad->first_ts));
} }
if (last_buf && buf && GST_CLOCK_TIME_IS_VALID (GST_BUFFER_DTS (buf)) && if (last_buf && buf && GST_CLOCK_TIME_IS_VALID (GST_BUFFER_DTS (buf)) &&