avwait: Deserialised timecodes set after caps event now get correct framerate
authorVivia Nikolaidou <vivia@ahiru.eu>
Tue, 14 Nov 2017 16:13:54 +0000 (18:13 +0200)
committerVivia Nikolaidou <vivia@ahiru.eu>
Tue, 14 Nov 2017 16:29:49 +0000 (18:29 +0200)
A deserialised timecode has a framerate of 0/1 by default. That breaks
it when comparing the frames field with another timecode (incoming from
the frame). We were setting the framerate when receiving the caps event,
but not when setting the timecode in set_property, so it was broken for
timecodes set after the caps event.

Also checking if the fps_n we got from the caps event is != 0 before
setting it - also at the caps event.

https://bugzilla.gnome.org/show_bug.cgi?id=790334

gst/timecode/gstavwait.c

index 841d3d28da72581429f0cf7f719c0c90dd2e3fad..e550afdd7f63a0498fe624bdbf94098247988dad 100644 (file)
@@ -387,10 +387,6 @@ gst_avwait_set_property (GObject * object, guint prop_id,
       frames = g_ascii_strtoll (parts[3], NULL, 10);
       gst_video_time_code_init (self->tc, 0, 1, NULL, 0, hours, minutes,
           seconds, frames, 0);
-      if (self->vinfo.finfo != NULL) {
-        self->tc->config.fps_n = self->vinfo.fps_n;
-        self->tc->config.fps_d = self->vinfo.fps_d;
-      }
       if (self->end_tc
           && gst_video_time_code_compare (self->tc, self->end_tc) != -1) {
         gchar *end_tc;
@@ -402,6 +398,12 @@ gst_avwait_set_property (GObject * object, guint prop_id,
         gst_video_time_code_free (self->tc);
         g_free (end_tc);
         self->tc = gst_video_time_code_new_empty ();
+      } else {
+        if (GST_VIDEO_INFO_FORMAT (&self->vinfo) != GST_VIDEO_FORMAT_UNKNOWN
+            && self->vinfo.fps_n != 0) {
+          self->tc->config.fps_n = self->vinfo.fps_n;
+          self->tc->config.fps_d = self->vinfo.fps_d;
+        }
       }
       g_strfreev (parts);
       break;
@@ -423,6 +425,13 @@ gst_avwait_set_property (GObject * object, guint prop_id,
         g_free (start_tc);
         g_free (end_tc);
         self->tc = gst_video_time_code_new_empty ();
+      } else {
+        if (self->tc->config.fps_n == 0
+            && GST_VIDEO_INFO_FORMAT (&self->vinfo) !=
+            GST_VIDEO_FORMAT_UNKNOWN && self->vinfo.fps_n != 0) {
+          self->tc->config.fps_n = self->vinfo.fps_n;
+          self->tc->config.fps_d = self->vinfo.fps_d;
+        }
       }
       break;
     }
@@ -443,6 +452,13 @@ gst_avwait_set_property (GObject * object, guint prop_id,
         self->end_tc = NULL;
         g_free (start_tc);
         g_free (end_tc);
+      } else {
+        if (self->end_tc->config.fps_n == 0
+            && GST_VIDEO_INFO_FORMAT (&self->vinfo) !=
+            GST_VIDEO_FORMAT_UNKNOWN && self->vinfo.fps_n != 0) {
+          self->end_tc->config.fps_n = self->vinfo.fps_n;
+          self->end_tc->config.fps_d = self->vinfo.fps_d;
+        }
       }
       break;
     }
@@ -523,11 +539,12 @@ gst_avwait_vsink_event (GstPad * pad, GstObject * parent, GstEvent * event)
         return FALSE;
       }
       g_mutex_lock (&self->mutex);
-      if (self->tc && self->tc->config.fps_n == 0) {
+      if (self->tc && self->tc->config.fps_n == 0 && self->vinfo.fps_n != 0) {
         self->tc->config.fps_n = self->vinfo.fps_n;
         self->tc->config.fps_d = self->vinfo.fps_d;
       }
-      if (self->end_tc && self->end_tc->config.fps_n == 0) {
+      if (self->end_tc && self->end_tc->config.fps_n == 0
+          && self->vinfo.fps_n != 0) {
         self->end_tc->config.fps_n = self->vinfo.fps_n;
         self->end_tc->config.fps_d = self->vinfo.fps_d;
       }