}
}
-/* scale rate up or down by factor of 10 to fit into [1000,10000] interval */
-static guint32
-adjust_rate (guint64 rate)
+/* return number of centiframes per second */
+static guint
+adjust_rate (gint n, gint d)
{
- if (rate == 0)
+ if (n == 0)
return 10000;
- while (rate >= 10000)
- rate /= 10;
-
- while (rate < 1000)
- rate *= 10;
+ if (d != 1 && d != 1001) {
+ /* otherwise there are probably rounding errors and we should rather guess
+ * if it's close enough to a well known framerate */
+ gst_video_guess_framerate (gst_util_uint64_scale (d, GST_SECOND, n), &n,
+ &d);
+ }
- return (guint32) rate;
+ return gst_util_uint64_scale (n, 100, d);
}
static gboolean
/* bring frame numerator into a range that ensures both reasonable resolution
* as well as a fair duration */
rate = qtmux->trak_timescale ?
- qtmux->trak_timescale : adjust_rate (framerate_num);
+ qtmux->trak_timescale : adjust_rate (framerate_num, framerate_den);
GST_DEBUG_OBJECT (qtmux, "Rate of video track selected: %" G_GUINT32_FORMAT,
rate);