aggregator: fix start-time-selection=first on negative rate

When the property "start-time-selection" is set to "first", it
calculates the start time of the output from the buffer pts
(converting it to running time of the segment), but if the
rate is negative, the real start is not the pts, but the
pts + duration, because it plays from the end of the buffer
to it's start.
As a result of this bug, in the negative rate, when the
start-time-selection=first, the first frame is dropped
by the videoaggregator (reproduced on d3d11compositor).

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5276>
This commit is contained in:
Alexander Slobodeniuk 2023-09-04 14:02:25 +02:00 committed by GStreamer Marge Bot
parent 9dbe8a1e36
commit 5ad1f00605

View file

@ -3244,6 +3244,7 @@ gst_aggregator_pad_chain_internal (GstAggregator * self,
{ {
GstFlowReturn flow_return; GstFlowReturn flow_return;
GstClockTime buf_pts; GstClockTime buf_pts;
GstClockTime buf_duration;
GST_TRACE_OBJECT (aggpad, GST_TRACE_OBJECT (aggpad,
"entering chain internal with %" GST_PTR_FORMAT, buffer); "entering chain internal with %" GST_PTR_FORMAT, buffer);
@ -3256,6 +3257,7 @@ gst_aggregator_pad_chain_internal (GstAggregator * self,
PAD_UNLOCK (aggpad); PAD_UNLOCK (aggpad);
buf_pts = GST_BUFFER_PTS (buffer); buf_pts = GST_BUFFER_PTS (buffer);
buf_duration = GST_BUFFER_DURATION (buffer);
for (;;) { for (;;) {
SRC_LOCK (self); SRC_LOCK (self);
@ -3312,6 +3314,9 @@ gst_aggregator_pad_chain_internal (GstAggregator * self,
if (aggpad->priv->head_segment.format == GST_FORMAT_TIME) { if (aggpad->priv->head_segment.format == GST_FORMAT_TIME) {
start_time = buf_pts; start_time = buf_pts;
if (start_time != -1) { if (start_time != -1) {
if (aggpad->priv->head_segment.rate < 0.0 && buf_duration != -1) {
start_time += buf_duration;
}
start_time = MAX (start_time, aggpad->priv->head_segment.start); start_time = MAX (start_time, aggpad->priv->head_segment.start);
start_time = start_time =
gst_segment_to_running_time (&aggpad->priv->head_segment, gst_segment_to_running_time (&aggpad->priv->head_segment,