[FFmpeg-cvslog] mov: Allow more than one keyframe per trun

Martin Storsjö git at videolan.org
Tue Sep 8 14:46:12 CEST 2015


ffmpeg | branch: master | Martin Storsjö <martin at martin.st> | Wed Sep  2 13:05:45 2015 +0300| [7cad1bf0759ada2a1fc3e80bb232a5377dd4fda4] | committer: Martin Storsjö

mov: Allow more than one keyframe per trun

The previous restriction was partially designed to fix certain
(broken) samples from bug 215. There should be no restriction on the
number of keyframes per fragment or trun.

The spec suggests that all frames lacking MOV_FRAG_SAMPLE_FLAG_IS_NON_SYNC
are key frames, but we require the flag MOV_FRAG_SAMPLE_FLAG_DEPENDS_YES
to be unset as well. This works for (possibly broken) media that never
sets the NON_SYNC flag and should also be correct for any spec-compliant
file.

For files that never set either of the flags, all samples are marked
as keyframes.

Signed-off-by: Martin Storsjö <martin at martin.st>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7cad1bf0759ada2a1fc3e80bb232a5377dd4fda4
---

 libavformat/mov.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 8bf1b90..bb99f75 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -2836,7 +2836,7 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
     int64_t dts;
     int data_offset = 0;
     unsigned entries, first_sample_flags = frag->flags;
-    int flags, distance, i, found_keyframe = 0, err;
+    int flags, distance, i, err;
 
     for (i = 0; i < c->fc->nb_streams; i++) {
         if (c->fc->streams[i]->id == frag->track_id) {
@@ -2900,8 +2900,8 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
         sc->ctts_count++;
         if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO)
             keyframe = 1;
-        else if (!found_keyframe)
-            keyframe = found_keyframe =
+        else
+            keyframe =
                 !(sample_flags & (MOV_FRAG_SAMPLE_FLAG_IS_NON_SYNC |
                                   MOV_FRAG_SAMPLE_FLAG_DEPENDS_YES));
         if (keyframe)



More information about the ffmpeg-cvslog mailing list