mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-18 14:26:43 +00:00
imagefreeze: Always generate a perfectly timestamped stream
Before there could be rounding errors when calculating the duration, resulting in timestamp + duration being smaller than the next buffer's timestamp.
This commit is contained in:
parent
998adeb974
commit
d8ef9bb691
1 changed files with 9 additions and 5 deletions
|
@ -717,7 +717,7 @@ gst_image_freeze_src_loop (GstPad * pad)
|
|||
GstImageFreeze *self = GST_IMAGE_FREEZE (GST_PAD_PARENT (pad));
|
||||
GstBuffer *buffer;
|
||||
guint64 offset;
|
||||
GstClockTime timestamp, duration;
|
||||
GstClockTime timestamp, timestamp_end, duration;
|
||||
gint64 cstart, cstop;
|
||||
gboolean in_seg, eos;
|
||||
|
||||
|
@ -770,24 +770,28 @@ gst_image_freeze_src_loop (GstPad * pad)
|
|||
if (self->fps_n != 0) {
|
||||
timestamp =
|
||||
gst_util_uint64_scale (offset, self->fps_d * GST_SECOND, self->fps_n);
|
||||
duration = gst_util_uint64_scale_int (GST_SECOND, self->fps_d, self->fps_n);
|
||||
timestamp_end =
|
||||
gst_util_uint64_scale (offset + 1, self->fps_d * GST_SECOND,
|
||||
self->fps_n);
|
||||
duration = timestamp_end - timestamp;
|
||||
} else {
|
||||
timestamp = self->segment.start;
|
||||
timestamp_end = GST_CLOCK_TIME_NONE;
|
||||
duration = GST_CLOCK_TIME_NONE;
|
||||
}
|
||||
|
||||
eos = (self->fps_n == 0 && offset > 0) ||
|
||||
(self->segment.rate >= 0 && self->segment.stop != -1
|
||||
&& timestamp > self->segment.stop) || (self->segment.rate < 0
|
||||
&& offset == 0) || (self->segment.rate < 0
|
||||
&& self->segment.start != -1
|
||||
&& timestamp + duration < self->segment.start);
|
||||
&& self->segment.start != -1 && timestamp_end < self->segment.start);
|
||||
|
||||
if (self->fps_n == 0 && offset > 0)
|
||||
in_seg = FALSE;
|
||||
else
|
||||
in_seg =
|
||||
gst_segment_clip (&self->segment, GST_FORMAT_TIME, timestamp,
|
||||
timestamp + duration, &cstart, &cstop);
|
||||
timestamp_end, &cstart, &cstop);
|
||||
|
||||
if (in_seg)
|
||||
gst_segment_set_last_stop (&self->segment, GST_FORMAT_TIME, cstart);
|
||||
|
|
Loading…
Reference in a new issue