Commit 9f4054a0 authored by John Stebbins's avatar John Stebbins Committed by Michael Niedermayer

libavformat/mov: fix multiple trun per traf

dts would start over at the beginning of each trun when they should be
computed contiguously for each trun in a traf

Fixes ticket 8070
Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent 21a65d63
...@@ -129,6 +129,7 @@ typedef struct MOVFragmentStreamInfo { ...@@ -129,6 +129,7 @@ typedef struct MOVFragmentStreamInfo {
int64_t sidx_pts; int64_t sidx_pts;
int64_t first_tfra_pts; int64_t first_tfra_pts;
int64_t tfdt_dts; int64_t tfdt_dts;
int64_t next_trun_dts;
int index_entry; int index_entry;
MOVEncryptionIndex *encryption_index; MOVEncryptionIndex *encryption_index;
} MOVFragmentStreamInfo; } MOVFragmentStreamInfo;
......
...@@ -1336,6 +1336,7 @@ static int update_frag_index(MOVContext *c, int64_t offset) ...@@ -1336,6 +1336,7 @@ static int update_frag_index(MOVContext *c, int64_t offset)
frag_stream_info[i].id = c->fc->streams[i]->id; frag_stream_info[i].id = c->fc->streams[i]->id;
frag_stream_info[i].sidx_pts = AV_NOPTS_VALUE; frag_stream_info[i].sidx_pts = AV_NOPTS_VALUE;
frag_stream_info[i].tfdt_dts = AV_NOPTS_VALUE; frag_stream_info[i].tfdt_dts = AV_NOPTS_VALUE;
frag_stream_info[i].next_trun_dts = AV_NOPTS_VALUE;
frag_stream_info[i].first_tfra_pts = AV_NOPTS_VALUE; frag_stream_info[i].first_tfra_pts = AV_NOPTS_VALUE;
frag_stream_info[i].index_entry = -1; frag_stream_info[i].index_entry = -1;
frag_stream_info[i].encryption_index = NULL; frag_stream_info[i].encryption_index = NULL;
...@@ -4614,6 +4615,7 @@ static int mov_read_tfhd(MOVContext *c, AVIOContext *pb, MOVAtom atom) ...@@ -4614,6 +4615,7 @@ static int mov_read_tfhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
MOVFragment *frag = &c->fragment; MOVFragment *frag = &c->fragment;
MOVTrackExt *trex = NULL; MOVTrackExt *trex = NULL;
int flags, track_id, i; int flags, track_id, i;
MOVFragmentStreamInfo * frag_stream_info;
avio_r8(pb); /* version */ avio_r8(pb); /* version */
flags = avio_rb24(pb); flags = avio_rb24(pb);
...@@ -4647,6 +4649,10 @@ static int mov_read_tfhd(MOVContext *c, AVIOContext *pb, MOVAtom atom) ...@@ -4647,6 +4649,10 @@ static int mov_read_tfhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
avio_rb32(pb) : trex->flags; avio_rb32(pb) : trex->flags;
av_log(c->fc, AV_LOG_TRACE, "frag flags 0x%x\n", frag->flags); av_log(c->fc, AV_LOG_TRACE, "frag flags 0x%x\n", frag->flags);
frag_stream_info = get_current_frag_stream_info(&c->frag_index);
if (frag_stream_info)
frag_stream_info->next_trun_dts = AV_NOPTS_VALUE;
return 0; return 0;
} }
...@@ -4800,7 +4806,9 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom) ...@@ -4800,7 +4806,9 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
frag_stream_info = get_current_frag_stream_info(&c->frag_index); frag_stream_info = get_current_frag_stream_info(&c->frag_index);
if (frag_stream_info) if (frag_stream_info)
{ {
if (frag_stream_info->first_tfra_pts != AV_NOPTS_VALUE && if (frag_stream_info->next_trun_dts != AV_NOPTS_VALUE) {
dts = frag_stream_info->next_trun_dts - sc->time_offset;
} else if (frag_stream_info->first_tfra_pts != AV_NOPTS_VALUE &&
c->use_mfra_for == FF_MOV_FLAG_MFRA_PTS) { c->use_mfra_for == FF_MOV_FLAG_MFRA_PTS) {
pts = frag_stream_info->first_tfra_pts; pts = frag_stream_info->first_tfra_pts;
av_log(c->fc, AV_LOG_DEBUG, "found mfra time %"PRId64 av_log(c->fc, AV_LOG_DEBUG, "found mfra time %"PRId64
...@@ -4960,6 +4968,8 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom) ...@@ -4960,6 +4968,8 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
sc->nb_frames_for_fps ++; sc->nb_frames_for_fps ++;
} }
} }
if (frag_stream_info)
frag_stream_info->next_trun_dts = dts + sc->time_offset;
if (i < entries) { if (i < entries) {
// EOF found before reading all entries. Fix the hole this would // EOF found before reading all entries. Fix the hole this would
// leave in index_entries and ctts_data // leave in index_entries and ctts_data
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment