decklink: Use gst_clock_adjust_with_calibration() and unadjust_with_calibration()
authorSebastian Dröge <sebastian@centricular.com>
Wed, 2 Nov 2016 13:00:36 +0000 (15:00 +0200)
committerSebastian Dröge <sebastian@centricular.com>
Wed, 2 Nov 2016 13:00:36 +0000 (15:00 +0200)
Instead of hand-crafted versions of the same calculation. These
calculations are still too complicated though.

sys/decklink/gstdecklinkvideosink.cpp
sys/decklink/gstdecklinkvideosrc.cpp

index db7fa9d5b384bc82fcc8238e9faa4181e54d2ef0..6fbcb34a7092c06cf30f8048ebf93841ddaa5a1d 100644 (file)
@@ -483,15 +483,9 @@ convert_to_internal_clock (GstDecklinkVideoSink * self,
       // according to our internal clock.
       //
       // For the duration we just scale
-      if (external > external_timestamp) {
-        guint64 diff = external - external_timestamp;
-        diff = gst_util_uint64_scale (diff, rate_d, rate_n);
-        *timestamp = internal - diff;
-      } else {
-        guint64 diff = external_timestamp - external;
-        diff = gst_util_uint64_scale (diff, rate_d, rate_n);
-        *timestamp = internal + diff;
-      }
+      *timestamp =
+          gst_clock_unadjust_with_calibration (NULL, external_timestamp,
+          internal, external, rate_n, rate_d);
 
       GST_LOG_OBJECT (self,
           "Converted %" GST_TIME_FORMAT " to %" GST_TIME_FORMAT " (internal: %"
index d82c5fc73046987a3454fd28410398fe99b8b4ce..0e8103406d97073d9ac974980f7118d422c78b7c 100644 (file)
@@ -464,15 +464,9 @@ gst_decklink_video_src_convert_to_external_clock (GstDecklinkVideoSrc * self,
       // according to our external clock.
       //
       // For the duration we just scale
-      if (internal > internal_timestamp) {
-        guint64 diff = internal - internal_timestamp;
-        diff = gst_util_uint64_scale (diff, rate_n, rate_d);
-        *timestamp = external - diff;
-      } else {
-        guint64 diff = internal_timestamp - internal;
-        diff = gst_util_uint64_scale (diff, rate_n, rate_d);
-        *timestamp = external + diff;
-      }
+      *timestamp =
+          gst_clock_adjust_with_calibration (NULL, internal_timestamp, internal,
+          external, rate_n, rate_d);
 
       GST_LOG_OBJECT (self,
           "Converted %" GST_TIME_FORMAT " to %" GST_TIME_FORMAT " (external: %"