aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandre Sicard <alexandre.sicard@smartjog.com>2013-06-07 14:56:16 +0200
committerClément Bœsch <ubitux@gmail.com>2013-06-07 16:30:27 +0200
commit8912029031d3cf4c42918931104d2ceec21d509a (patch)
treedee4066519380e37b6c952b9f797add390f518f0
parentc59c0488ec14f3efe8524c70e4496d3aaef16ffc (diff)
downloadffmpeg-8912029031d3cf4c42918931104d2ceec21d509a.tar.gz
avformat/mov: compute dts_shift with trun cts
Some movies have negative composition time offsets in their trun, causing pts < dts errors. This patch makes use of dts_shift to handle them. Signed-off-by: Alexandre Sicard <alexandre.sicard@smartjog.com>
-rw-r--r--libavformat/mov.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 1c03b1553a..407b52f342 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1839,6 +1839,13 @@ static int mov_read_stts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
return 0;
}
+static void mov_update_dts_shift(MOVStreamContext *sc, int duration)
+{
+ if (duration < 0) {
+ sc->dts_shift = FFMAX(sc->dts_shift, -duration);
+ }
+}
+
static int mov_read_ctts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
@@ -1881,8 +1888,8 @@ static int mov_read_ctts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
return 0;
}
- if (duration < 0 && i+2<entries)
- sc->dts_shift = FFMAX(sc->dts_shift, -duration);
+ if (i+2<entries)
+ mov_update_dts_shift(sc, duration);
}
sc->ctts_count = i;
@@ -2562,6 +2569,7 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
sc->ctts_data[sc->ctts_count].count = 1;
sc->ctts_data[sc->ctts_count].duration = (flags & MOV_TRUN_SAMPLE_CTS) ?
avio_rb32(pb) : 0;
+ mov_update_dts_shift(sc, sc->ctts_data[sc->ctts_count].duration);
sc->ctts_count++;
if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO)
keyframe = 1;