From d67a671bfb9f0f7e0ae412f9eb784e891f1c3270 Mon Sep 17 00:00:00 2001 From: Mathieu Duponchelle Date: Fri, 19 Jul 2013 22:59:15 +0200 Subject: [PATCH] videomixer: use gst_util_uint64_scale*_round. There could be a case where: 1) you do a new set_caps after buffers have been processed. 2) ts_offset gets set to a different value, eg 0.033333333 3) your pads get EOS, but the check dor that doesn't work because you use ts_offset + a truncated value < segment.stop 4) so in the next collected, you end up comparing for example: 0.9999999999 > 1., which is false and means you don't send EOS. Also adds scale_round in two other places where it potentially could have caused problems. --- gst/videomixer/videomixer2.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gst/videomixer/videomixer2.c b/gst/videomixer/videomixer2.c index 464dc48..63f4204 100644 --- a/gst/videomixer/videomixer2.c +++ b/gst/videomixer/videomixer2.c @@ -590,7 +590,7 @@ gst_videomixer2_update_qos (GstVideoMixer2 * mix, gdouble proportion, if (G_LIKELY (timestamp != GST_CLOCK_TIME_NONE)) { if (G_UNLIKELY (diff > 0)) mix->earliest_time = - timestamp + 2 * diff + gst_util_uint64_scale_int (GST_SECOND, + timestamp + 2 * diff + gst_util_uint64_scale_int_round (GST_SECOND, GST_VIDEO_INFO_FPS_D (&mix->info), GST_VIDEO_INFO_FPS_N (&mix->info)); else mix->earliest_time = timestamp + diff; @@ -1013,7 +1013,7 @@ gst_videomixer2_collected (GstCollectPads * pads, GstVideoMixer2 * mix) } output_end_time = - mix->ts_offset + gst_util_uint64_scale (mix->nframes + 1, + mix->ts_offset + gst_util_uint64_scale_round (mix->nframes + 1, GST_SECOND * GST_VIDEO_INFO_FPS_D (&mix->info), GST_VIDEO_INFO_FPS_N (&mix->info)) + mix->segment.start; if (mix->segment.stop != -1) @@ -1664,7 +1664,7 @@ gst_videomixer2_sink_clip (GstCollectPads * pads, end_time = GST_BUFFER_DURATION (buf); if (end_time == -1 && GST_VIDEO_INFO_FPS_N (&pad->info) != 0) end_time = - gst_util_uint64_scale_int (GST_SECOND, + gst_util_uint64_scale_int_round (GST_SECOND, GST_VIDEO_INFO_FPS_D (&pad->info), GST_VIDEO_INFO_FPS_N (&pad->info)); if (end_time == -1) { *outbuf = buf; -- 2.7.4