[FFmpeg-devel] [PATCH 2/2] mov: fix non-monotonous DTS when fragments overlap in time
Michael Niedermayer
michael at niedermayer.cc
Sat Sep 30 03:29:28 EEST 2017
On Fri, Sep 29, 2017 at 08:54:09AM -0700, John Stebbins wrote:
> ---
> libavformat/mov.c | 16 ++++++++++++++--
> 1 file changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index c7422cd9ed..871f10b240 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -4267,6 +4267,7 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
> int data_offset = 0;
> unsigned entries, first_sample_flags = frag->flags;
> int flags, distance, i;
> + AVIndexEntry *last_index_entry = NULL;
>
> for (i = 0; i < c->fc->nb_streams; i++) {
> if (c->fc->streams[i]->id == frag->track_id) {
> @@ -4294,6 +4295,10 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
> offset = frag->base_data_offset + data_offset;
> distance = 0;
> av_log(c->fc, AV_LOG_TRACE, "first sample flags 0x%x\n", first_sample_flags);
> +
> + if (st->nb_index_entries)
> + last_index_entry = &st->index_entries[st->nb_index_entries-1];
> +
> for (i = 0; i < entries && !pb->eof_reached; i++) {
> unsigned sample_size = frag->size;
> int sample_flags = i ? frag->flags : first_sample_flags;
> @@ -4302,6 +4307,7 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
> int keyframe = 0;
> int ctts_index = 0;
> int old_nb_index_entries = st->nb_index_entries;
> + int index_entry_flags = 0;
>
> if (flags & MOV_TRUN_SAMPLE_DURATION) sample_duration = avio_rb32(pb);
> if (flags & MOV_TRUN_SAMPLE_SIZE) sample_size = avio_rb32(pb);
> @@ -4338,10 +4344,16 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
> keyframe =
> !(sample_flags & (MOV_FRAG_SAMPLE_FLAG_IS_NON_SYNC |
> MOV_FRAG_SAMPLE_FLAG_DEPENDS_YES));
> - if (keyframe)
> + if (keyframe) {
> distance = 0;
> + index_entry_flags |= AVINDEX_KEYFRAME;
> + }
> + // Fragments can overlap in time. Discard overlapping frames after
> + // decoding.
> + if (last_index_entry && last_index_entry->timestamp >= dts)
the memory last_index_entry points to can be reallocated in this loop
making the pointer invalid
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Does the universe only have a finite lifespan? No, its going to go on
forever, its just that you wont like living in it. -- Hiranya Peiri
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20170930/57e61cb1/attachment.sig>
More information about the ffmpeg-devel
mailing list