[2/2] movdec: Don't require first_sample_flags in trun for marking keyframes

Message ID 1328007721-26731-2-git-send-email-martin@martin.st
State Superseded
Headers show

Commit Message

Martin Storsjö Jan. 31, 2012, 11:02 a.m.
The code for setting the keyframe flag for samples where all the
the upper sample flags bits were 0 only did this if the
sample flags were set by the first_sample_flags field in trun.

In a sample produced by Sorenson Squeeze, the trun atoms don't
contain any first_sample_flags at all, but these flags are
inherited from tfhd.

If the sample flags are to be interpreted even more consistently,
the !i check wouldn't be needed either, to allow samples other
than the first one in a trun to get the keyframe flag. However,
for this particular sample, all samples actually have the same
flags set, so the code after this patch sets the keyframe flag
for the first sample in each trun, which seems to be right.

This fixes seeking in the Sorenson Squeeze sample in bug 215.
 libavformat/mov.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)


diff --git a/libavformat/mov.c b/libavformat/mov.c
index 2e27a94..24cc797 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -2269,7 +2269,7 @@  static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
         sc->ctts_data[sc->ctts_count].duration = (flags & 0x800) ? avio_rb32(pb) : 0;
         if ((keyframe = st->codec->codec_type == AVMEDIA_TYPE_AUDIO ||
-             (flags & 0x004 && !i && !(sample_flags & 0xffff0000)) || sample_flags & 0x2000000))
+             (!i && !(sample_flags & 0xffff0000)) || sample_flags & 0x2000000))
             distance = 0;
         av_add_index_entry(st, offset, dts, sample_size, distance,
                            keyframe ? AVINDEX_KEYFRAME : 0);