diff options
author | Sebastian Dröge <sebastian@centricular.com> | 2017-04-14 13:38:53 +0300 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2017-05-08 18:21:30 +0200 |
commit | c15074cd5412c3117950f0d35fb241eff2e06149 (patch) | |
tree | 968b5107332655b56318c5d4f67b15048d383d12 | |
parent | 84cb0852e1184176ab953bda459b811a050dfcd1 (diff) | |
download | gstreamer-plugins-good-c15074cd5412c3117950f0d35fb241eff2e06149.tar.gz |
qtmux: Fix timescale of timecode tracks
They should have ideally the same timescale of the video track, which we
can't guarantee here as in theory timecode configuration and video
framerate could be different. However we should set a correct timescale
based on the framerate given in the timecode configuration, and not just
use the framerate numerator.
Different than the 1.12 version of the patch, this uses the previous,
suboptimal calculation of the timescale for video tracks to be
consistent with the video track.
-rw-r--r-- | gst/isomp4/atoms.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/gst/isomp4/atoms.c b/gst/isomp4/atoms.c index 8ada78be0..b288215d7 100644 --- a/gst/isomp4/atoms.c +++ b/gst/isomp4/atoms.c @@ -3759,6 +3759,22 @@ atom_trak_add_audio_entry (AtomTRAK * trak, AtomsContext * context, return mp4a; } +/* return number of centiframes per second */ +static guint32 +adjust_rate (guint64 rate) +{ + if (rate == 0) + return 10000; + + while (rate >= 10000) + rate /= 10; + + while (rate < 1000) + rate *= 10; + + return (guint32) rate; +} + static SampleTableEntryTMCD * atom_trak_add_timecode_entry (AtomTRAK * trak, AtomsContext * context, GstVideoTimeCode * tc) @@ -3770,7 +3786,7 @@ atom_trak_add_timecode_entry (AtomTRAK * trak, AtomsContext * context, trak->mdia.hdlr.handler_type = FOURCC_tmcd; g_free (trak->mdia.hdlr.name); trak->mdia.hdlr.name = g_strdup ("Time Code Media Handler"); - trak->mdia.mdhd.time_info.timescale = tc->config.fps_n / tc->config.fps_d; + trak->mdia.mdhd.time_info.timescale = adjust_rate (tc->config.fps_n); tmcd->se.kind = TIMECODE; tmcd->se.data_reference_index = 1; @@ -3779,8 +3795,8 @@ atom_trak_add_timecode_entry (AtomTRAK * trak, AtomsContext * context, tmcd->tc_flags |= TC_DROP_FRAME; tmcd->name.language_code = 0; tmcd->name.name = g_strdup ("Tape"); - tmcd->timescale = tc->config.fps_n; - tmcd->frame_duration = tc->config.fps_d; + tmcd->timescale = adjust_rate (tc->config.fps_n); + tmcd->frame_duration = 100; if (tc->config.fps_d == 1001) tmcd->n_frames = tc->config.fps_n / 1000; else |