From 0fe49d0fed262a0836c3998dc74c67a1584feff6 Mon Sep 17 00:00:00 2001 From: "jijoong.moon" Date: Fri, 9 Nov 2018 16:01:10 +0900 Subject: [PATCH] [Mux/Merge] Fix time synchronization buf for cornner cases For the basepad options with 0 and maximum duration, current implementation is not work properly. In order to support this situation, base time is decided min(duration, pts(nth)-pts(n-1 th)-1). **Self evaluation:** 1. Build test: [X]Passed [ ]Failed [ ]Skipped 2. Run test: [X]Passed [ ]Failed [ ]Skipped Signed-off-by: jijoong.moon --- gst/nnstreamer/tensor_common.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/gst/nnstreamer/tensor_common.c b/gst/nnstreamer/tensor_common.c index fe3ded7..fb74432 100644 --- a/gst/nnstreamer/tensor_common.c +++ b/gst/nnstreamer/tensor_common.c @@ -1168,8 +1168,28 @@ gst_gen_tensors_from_collectpad (GstCollectPads * collect, gint old_denominator = G_MAXINT; gint counting = 0; GstTensorConfig config; + GstClockTime base = 0; walk = collect->data; + + if (sync.mode == SYNC_BASEPAD) { + walk = g_slist_nth (walk, sync.data_basepad.sink_id); + GstCollectData *data = (GstCollectData *) walk->data; + GstTensorCollectPadData *pad = (GstTensorCollectPadData *) data; + GstBuffer *buf = NULL; + buf = gst_collect_pads_peek (collect, data); + if (buf != NULL) { + if (pad->buffer != NULL) + base = + MIN (sync.data_basepad.duration, + ABS (GST_CLOCK_DIFF (GST_BUFFER_PTS (buf), + GST_BUFFER_PTS (pad->buffer))) - 1); + gst_buffer_unref (buf); + } + } + + walk = collect->data; + while (walk) { GstCollectData *data = (GstCollectData *) walk->data; GstTensorCollectPadData *pad = (GstTensorCollectPadData *) data; @@ -1238,10 +1258,9 @@ gst_gen_tensors_from_collectpad (GstCollectPads * collect, return FALSE; } - if (pad->buffer != NULL && - (ABS (GST_CLOCK_DIFF (current_time, - GST_BUFFER_PTS (buf))) > - sync.data_basepad.duration)) { + if ((pad->buffer != NULL && + (ABS (GST_CLOCK_DIFF (current_time, + GST_BUFFER_PTS (buf))) > base))) { gst_buffer_unref (buf); buf = pad->buffer; } else { -- 2.7.4