From aafda1c76f4089505e16b6128f8b80ab316ab2f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 25 Jul 2019 18:27:30 +0300 Subject: [PATCH] timecodestamper: Validate LTC timestamps before trying to use them There's no point in working with invalid LTC timestamps as all future calculations will be wrong based on this, and invalid LTC timestamps can sometimes be read via the audio input. --- gst/timecode/gsttimecodestamper.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/gst/timecode/gsttimecodestamper.c b/gst/timecode/gsttimecodestamper.c index a3098a235f..cd357f4e79 100644 --- a/gst/timecode/gsttimecodestamper.c +++ b/gst/timecode/gsttimecodestamper.c @@ -1089,10 +1089,17 @@ gst_timecodestamper_transform_ip (GstBaseTransform * vfilter, if (timecodestamper->ltc_auto_resync) { if (timecodestamper->ltc_internal_tc) gst_video_time_code_free (timecodestamper->ltc_internal_tc); - timecodestamper->ltc_internal_tc = - gst_video_time_code_copy (ltc_read_tc_ptr); - updated_internal = TRUE; - GST_INFO_OBJECT (timecodestamper, "Resynced internal LTC counter"); + if (gst_video_time_code_is_valid (ltc_read_tc_ptr)) { + timecodestamper->ltc_internal_tc = + gst_video_time_code_copy (ltc_read_tc_ptr); + updated_internal = TRUE; + GST_INFO_OBJECT (timecodestamper, "Resynced internal LTC counter"); + } else { + tc_str = gst_video_time_code_to_string (ltc_read_tc_ptr); + GST_INFO_OBJECT (timecodestamper, "Invalid LTC timecode %s", + tc_str); + g_free (tc_str); + } } /* And store it for the next frame in case it has more or less the