+/* FIXME 2.0: Remove clock parameter below */
+/**
+ * gst_clock_unadjust_with_calibration:
+ * @clock: (allow-none): a #GstClock to use
+ * @external_target: a clock time
+ * @cinternal: a reference internal time
+ * @cexternal: a reference external time
+ * @cnum: the numerator of the rate of the clock relative to its
+ * internal time
+ * @cdenom: the denominator of the rate of the clock
+ *
+ * Converts the given @external_target clock time to the internal time,
+ * using the passed calibration parameters. This function performs the
+ * same calculation as gst_clock_unadjust_unlocked() when called using the
+ * current calibration parameters.
+ *
+ * Note: The @clock parameter is unused and can be NULL
+ *
+ * Returns: the converted time of the clock.
+ *
+ * Since: 1.8
+ */
+GstClockTime
+gst_clock_unadjust_with_calibration (GstClock * clock,
+ GstClockTime external_target, GstClockTime cinternal,
+ GstClockTime cexternal, GstClockTime cnum, GstClockTime cdenom)
+{
+ GstClockTime ret;
+
+ /* avoid divide by 0 */
+ if (G_UNLIKELY (cnum == 0))
+ cnum = cdenom = 1;
+
+ /* The formula is (external - cexternal) * cdenom / cnum + cinternal */
+ if (G_LIKELY (external_target >= cexternal)) {
+ ret = external_target - cexternal;
+ ret = gst_util_uint64_scale (ret, cdenom, cnum);
+ ret += cinternal;
+ } else {
+ ret = cexternal - external_target;
+ ret = gst_util_uint64_scale (ret, cdenom, cnum);
+ if (G_LIKELY (cinternal > ret))
+ ret = cinternal - ret;
+ else
+ ret = 0;
+ }
+
+ return ret;
+}
+