diff options
author | Vivia Nikolaidou <vivia@ahiru.eu> | 2018-01-19 15:05:26 +0200 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2018-01-23 16:40:36 +0200 |
commit | 379059b1c7baede5f8206dc2b132109831abcd93 (patch) | |
tree | d3b6b63340de84dc254f1f686b71fdb5d6fdab30 | |
parent | c71cd08d0edf39c0eb6be9b6458ea7ac8ac2b412 (diff) |
qtmux: Make sure timecode uses the same timescale as video
Don't blindly derive it from the frame rate, but try to get the per-pad
configured timescale first (if it exists)
https://bugzilla.gnome.org/show_bug.cgi?id=792680
-rw-r--r-- | gst/isomp4/atoms.c | 18 | ||||
-rw-r--r-- | gst/isomp4/atoms.h | 2 | ||||
-rw-r--r-- | gst/isomp4/gstqtmux.c | 6 |
3 files changed, 15 insertions, 11 deletions
diff --git a/gst/isomp4/atoms.c b/gst/isomp4/atoms.c index 9be74ac78..eb90b7929 100644 --- a/gst/isomp4/atoms.c +++ b/gst/isomp4/atoms.c @@ -3813,17 +3813,18 @@ atom_framerate_to_timescale (gint n, gint d) static SampleTableEntryTMCD * atom_trak_add_timecode_entry (AtomTRAK * trak, AtomsContext * context, - GstVideoTimeCode * tc) + guint32 trak_timescale, GstVideoTimeCode * tc) { AtomSTSD *stsd = &trak->mdia.minf.stbl.stsd; SampleTableEntryTMCD *tmcd = sample_entry_tmcd_new (); + g_assert (trak_timescale != 0); + trak->mdia.hdlr.component_type = FOURCC_mhlr; 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 = - atom_framerate_to_timescale (tc->config.fps_n, tc->config.fps_d); + trak->mdia.mdhd.time_info.timescale = trak_timescale; tmcd->se.kind = TIMECODE; tmcd->se.data_reference_index = 1; @@ -3832,9 +3833,10 @@ 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 = - atom_framerate_to_timescale (tc->config.fps_n, tc->config.fps_d); - tmcd->frame_duration = 100; + tmcd->timescale = trak_timescale; + tmcd->frame_duration = + gst_util_uint64_scale (tmcd->timescale, tc->config.fps_d, + tc->config.fps_n); if (tc->config.fps_d == 1001) tmcd->n_frames = tc->config.fps_n / 1000; else @@ -3991,7 +3993,7 @@ atom_trak_set_audio_type (AtomTRAK * trak, AtomsContext * context, SampleTableEntryTMCD * atom_trak_set_timecode_type (AtomTRAK * trak, AtomsContext * context, - GstVideoTimeCode * tc) + guint32 trak_timescale, GstVideoTimeCode * tc) { SampleTableEntryTMCD *ste; AtomGMHD *gmhd = trak->mdia.minf.gmhd; @@ -4000,7 +4002,7 @@ atom_trak_set_timecode_type (AtomTRAK * trak, AtomsContext * context, return NULL; } - ste = atom_trak_add_timecode_entry (trak, context, tc); + ste = atom_trak_add_timecode_entry (trak, context, trak_timescale, tc); gmhd = atom_gmhd_new (); gmhd->gmin.graphics_mode = 0x0040; diff --git a/gst/isomp4/atoms.h b/gst/isomp4/atoms.h index 37b1906a5..f73cb9f05 100644 --- a/gst/isomp4/atoms.h +++ b/gst/isomp4/atoms.h @@ -1039,7 +1039,7 @@ SampleTableEntryTX3G * atom_trak_set_subtitle_type (AtomTRAK * trak, AtomsContex SubtitleSampleEntry * entry); SampleTableEntryTMCD * -atom_trak_set_timecode_type (AtomTRAK * trak, AtomsContext * context, GstVideoTimeCode * tc); +atom_trak_set_timecode_type (AtomTRAK * trak, AtomsContext * context, guint trak_timescale, GstVideoTimeCode * tc); void atom_trak_update_bitrates (AtomTRAK * trak, guint32 avg_bitrate, guint32 max_bitrate); diff --git a/gst/isomp4/gstqtmux.c b/gst/isomp4/gstqtmux.c index e97228506..12a654e61 100644 --- a/gst/isomp4/gstqtmux.c +++ b/gst/isomp4/gstqtmux.c @@ -2588,7 +2588,8 @@ gst_qt_mux_prefill_samples (GstQTMux * qtmux) qpad->trak->tref = atom_tref_new (FOURCC_tmcd); atom_tref_add_entry (qpad->trak->tref, qpad->tc_trak->tkhd.track_ID); - atom_trak_set_timecode_type (qpad->tc_trak, qtmux->context, tc); + atom_trak_set_timecode_type (qpad->tc_trak, qtmux->context, + qpad->trak->mdia.mdhd.time_info.timescale, tc); atom_trak_add_samples (qpad->tc_trak, 1, 1, 4, qtmux->mdat_size, FALSE, 0); @@ -4086,7 +4087,8 @@ gst_qt_mux_check_and_update_timecode (GstQTMux * qtmux, GstQTPad * pad, pad->trak->tref = atom_tref_new (FOURCC_tmcd); atom_tref_add_entry (pad->trak->tref, pad->tc_trak->tkhd.track_ID); - atom_trak_set_timecode_type (pad->tc_trak, qtmux->context, pad->first_tc); + atom_trak_set_timecode_type (pad->tc_trak, qtmux->context, + pad->trak->mdia.mdhd.time_info.timescale, pad->first_tc); tc_buf = gst_buffer_new_allocate (NULL, 4, NULL); szret = gst_buffer_fill (tc_buf, 0, &frames_since_daily_jam, 4); |