diff options
-rw-r--r-- | gst/qtmux/atoms.c | 29 | ||||
-rw-r--r-- | gst/qtmux/atoms.h | 8 | ||||
-rw-r--r-- | gst/qtmux/atomsrecovery.c | 2 | ||||
-rw-r--r-- | gst/qtmux/gstqtmux.c | 15 |
4 files changed, 26 insertions, 28 deletions
diff --git a/gst/qtmux/atoms.c b/gst/qtmux/atoms.c index ebbd7c09b..bdba5bc5a 100644 --- a/gst/qtmux/atoms.c +++ b/gst/qtmux/atoms.c @@ -538,6 +538,7 @@ atom_ctts_init (AtomCTTS * ctts) atom_full_init (&ctts->header, FOURCC_ctts, 0, 0, 0, flags); atom_array_init (&ctts->entries, 128); + ctts->do_pts = FALSE; } static AtomCTTS * @@ -2019,7 +2020,7 @@ atom_stbl_copy_data (AtomSTBL * stbl, guint8 ** buffer, guint64 * size, if (!atom_stsz_copy_data (&stbl->stsz, buffer, size, offset)) { return 0; } - if (stbl->ctts) { + if (stbl->ctts && stbl->ctts->do_pts) { if (!atom_ctts_copy_data (stbl->ctts, buffer, size, offset)) { return 0; } @@ -2553,6 +2554,8 @@ atom_ctts_add_entry (AtomCTTS * ctts, guint32 nsamples, guint32 offset) nentry.samplecount = nsamples; nentry.sampleoffset = offset; atom_array_append (&ctts->entries, nentry, 256); + if (offset != 0) + ctts->do_pts = TRUE; } else { entry->samplecount += nsamples; } @@ -2569,8 +2572,7 @@ atom_stbl_add_ctts_entry (AtomSTBL * stbl, guint32 nsamples, guint32 offset) void atom_stbl_add_samples (AtomSTBL * stbl, guint32 nsamples, guint32 delta, - guint32 size, guint64 chunk_offset, gboolean sync, - gboolean do_pts, gint64 pts_offset) + guint32 size, guint64 chunk_offset, gboolean sync, gint64 pts_offset) { atom_stts_add_entry (&stbl->stts, nsamples, delta); atom_stsz_add_entry (&stbl->stsz, nsamples, size); @@ -2579,18 +2581,17 @@ atom_stbl_add_samples (AtomSTBL * stbl, guint32 nsamples, guint32 delta, atom_stco64_get_entry_count (&stbl->stco64), nsamples); if (sync) atom_stbl_add_stss_entry (stbl); - if (do_pts) - atom_stbl_add_ctts_entry (stbl, nsamples, pts_offset); + /* always store to arrange for consistent content */ + atom_stbl_add_ctts_entry (stbl, nsamples, pts_offset); } void atom_trak_add_samples (AtomTRAK * trak, guint32 nsamples, guint32 delta, - guint32 size, guint64 chunk_offset, gboolean sync, - gboolean do_pts, gint64 pts_offset) + guint32 size, guint64 chunk_offset, gboolean sync, gint64 pts_offset) { AtomSTBL *stbl = &trak->mdia.minf.stbl; atom_stbl_add_samples (stbl, nsamples, delta, size, chunk_offset, sync, - do_pts, pts_offset); + pts_offset); } /* trak and moov molding */ @@ -3593,18 +3594,17 @@ atom_sdtp_add_samples (AtomSDTP * sdtp, guint8 val) static void atom_trun_add_samples (AtomTRUN * trun, guint32 delta, guint32 size, - guint32 flags, gboolean do_pts, gint64 pts_offset) + guint32 flags, gint64 pts_offset) { TRUNSampleEntry nentry; - if (do_pts) { + if (pts_offset != 0) trun->header.flags[1] |= TR_COMPOSITION_TIME_OFFSETS; - } nentry.sample_duration = delta; nentry.sample_size = size; nentry.sample_flags = flags; - nentry.sample_composition_time_offset = do_pts ? pts_offset : 0; + nentry.sample_composition_time_offset = pts_offset; atom_array_append (&trun->entries, nentry, 256); trun->sample_count++; } @@ -3637,7 +3637,7 @@ atom_traf_add_trun (AtomTRAF * traf, AtomTRUN * trun) void atom_traf_add_samples (AtomTRAF * traf, guint32 delta, guint32 size, - gboolean sync, gboolean do_pts, gint64 pts_offset, gboolean sdtp_sync) + gboolean sync, gint64 pts_offset, gboolean sdtp_sync) { AtomTRUN *trun; guint32 flags; @@ -3683,8 +3683,7 @@ atom_traf_add_samples (AtomTRAF * traf, guint32 delta, guint32 size, } } - atom_trun_add_samples (traf->truns->data, delta, size, flags, do_pts, - pts_offset); + atom_trun_add_samples (traf->truns->data, delta, size, flags, pts_offset); if (traf->sdtps) atom_sdtp_add_samples (traf->sdtps->data, 0x10 | ((flags & 0xff) >> 4)); diff --git a/gst/qtmux/atoms.h b/gst/qtmux/atoms.h index b65be8256..d1241184d 100644 --- a/gst/qtmux/atoms.h +++ b/gst/qtmux/atoms.h @@ -479,6 +479,7 @@ typedef struct _AtomCTTS /* also entry count here */ ATOM_ARRAY (CTTSEntry) entries; + gboolean do_pts; } AtomCTTS; typedef struct _AtomSTBL @@ -806,7 +807,7 @@ void atom_ftyp_free (AtomFTYP *ftyp); AtomTRAK* atom_trak_new (AtomsContext *context); void atom_trak_add_samples (AtomTRAK * trak, guint32 nsamples, guint32 delta, guint32 size, guint64 chunk_offset, gboolean sync, - gboolean do_pts, gint64 pts_offset); + gint64 pts_offset); void atom_trak_add_elst_entry (AtomTRAK * trak, guint32 duration, guint32 media_time, guint32 rate); guint32 atom_trak_get_timescale (AtomTRAK *trak); @@ -814,7 +815,7 @@ guint32 atom_trak_get_id (AtomTRAK * trak); void atom_stbl_add_samples (AtomSTBL * stbl, guint32 nsamples, guint32 delta, guint32 size, guint64 chunk_offset, gboolean sync, - gboolean do_pts, gint64 pts_offset); + gint64 pts_offset); AtomMOOV* atom_moov_new (AtomsContext *context); void atom_moov_free (AtomMOOV *moov); @@ -850,8 +851,7 @@ guint64 atom_moof_copy_data (AtomMOOF *moof, guint8 **buffer, guint64 AtomTRAF * atom_traf_new (AtomsContext * context, guint32 track_ID); void atom_traf_free (AtomTRAF * traf); void atom_traf_add_samples (AtomTRAF * traf, guint32 delta, - guint32 size, gboolean sync, - gboolean do_pts, gint64 pts_offset, + guint32 size, gboolean sync, gint64 pts_offset, gboolean sdtp_sync); guint32 atom_traf_get_sample_num (AtomTRAF * traf); void atom_moof_add_traf (AtomMOOF *moof, AtomTRAF *traf); diff --git a/gst/qtmux/atomsrecovery.c b/gst/qtmux/atomsrecovery.c index c9684b1f3..1f5a287d1 100644 --- a/gst/qtmux/atomsrecovery.c +++ b/gst/qtmux/atomsrecovery.c @@ -761,7 +761,7 @@ trak_recov_data_add_sample (TrakRecovData * trak, TrakBufferEntryInfo * b) { trak->duration += b->nsamples * b->delta; atom_stbl_add_samples (&trak->stbl, b->nsamples, b->delta, b->size, - b->chunk_offset, b->sync, b->do_pts, b->pts_offset); + b->chunk_offset, b->sync, b->pts_offset); } /** diff --git a/gst/qtmux/gstqtmux.c b/gst/qtmux/gstqtmux.c index 9ef8caf14..de067b743 100644 --- a/gst/qtmux/gstqtmux.c +++ b/gst/qtmux/gstqtmux.c @@ -1838,8 +1838,7 @@ ftyp_error: static GstFlowReturn gst_qt_mux_pad_fragment_add_buffer (GstQTMux * qtmux, GstQTPad * pad, GstBuffer * buf, gboolean force, guint32 nsamples, gint64 dts, - guint32 delta, guint32 size, gboolean sync, gboolean do_pts, - gint64 pts_offset) + guint32 delta, guint32 size, gboolean sync, gint64 pts_offset) { GstFlowReturn ret = GST_FLOW_OK; @@ -1913,7 +1912,7 @@ init: } /* add buffer and metadata */ - atom_traf_add_samples (pad->traf, delta, size, sync, do_pts, pts_offset, + atom_traf_add_samples (pad->traf, delta, size, sync, pts_offset, pad->sync && sync); atom_array_append (&pad->fragment_buffers, buf, 256); pad->fragment_duration -= delta; @@ -2159,8 +2158,8 @@ gst_qt_mux_add_buffer (GstQTMux * qtmux, GstQTPad * pad, GstBuffer * buf) /* note that a new chunk is started each time (not fancy but works) */ if (qtmux->moov_recov_file) { if (!atoms_recov_write_trak_samples (qtmux->moov_recov_file, pad->trak, - nsamples, scaled_duration, sample_size, chunk_offset, sync, do_pts, - pts_offset)) { + nsamples, (gint32) scaled_duration, sample_size, chunk_offset, sync, + do_pts, pts_offset)) { GST_WARNING_OBJECT (qtmux, "Failed to write sample information to " "recovery file, disabling recovery"); fclose (qtmux->moov_recov_file); @@ -2175,10 +2174,10 @@ gst_qt_mux_add_buffer (GstQTMux * qtmux, GstQTPad * pad, GstBuffer * buf) /* ensure that always sync samples are marked as such */ return gst_qt_mux_pad_fragment_add_buffer (qtmux, pad, last_buf, buf == NULL, nsamples, last_dts, scaled_duration, sample_size, - !pad->sync || sync, do_pts, pts_offset); + !pad->sync || sync, pts_offset); } else { - atom_trak_add_samples (pad->trak, nsamples, scaled_duration, sample_size, - chunk_offset, sync, do_pts, pts_offset); + atom_trak_add_samples (pad->trak, nsamples, scaled_duration, + sample_size, chunk_offset, sync, pts_offset); return gst_qt_mux_send_buffer (qtmux, last_buf, &qtmux->mdat_size, TRUE); } |