diff options
author | Yusuke Nakamura <muken.the.vfrmaniac@gmail.com> | 2011-06-05 02:45:54 +0900 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-10-28 01:37:50 +0200 |
commit | 05e417aa63ef73b3c3a767c334f6c53abdb1ea20 (patch) | |
tree | 3871caf8bb2327c4c8417f29591afcd693a7046c /libavformat/mov.c | |
parent | e7f008a53406e17c91d4fd12ffd140baac2560ff (diff) | |
download | ffmpeg-05e417aa63ef73b3c3a767c334f6c53abdb1ea20.tar.gz |
mov: Support empty first edit + normal second edit.
(cherry picked from commit df342c91e6cfceb2537c2d1b2442dd685381a0ca)
Reviewed-by: Baptiste Coudurier
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/mov.c')
-rw-r--r-- | libavformat/mov.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/libavformat/mov.c b/libavformat/mov.c index f1ceb56e9f..03f01e05d5 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1651,9 +1651,10 @@ static void mov_build_index(MOVContext *mov, AVStream *st) uint64_t stream_size = 0; /* adjust first dts according to edit list */ - if (sc->time_offset && mov->time_scale > 0) { - if (sc->time_offset < 0) - sc->time_offset = av_rescale(sc->time_offset, sc->time_scale, mov->time_scale); + if ((sc->empty_duration || sc->start_time) && mov->time_scale > 0) { + if (sc->empty_duration) + sc->empty_duration = av_rescale(sc->empty_duration, sc->time_scale, mov->time_scale); + sc->time_offset = sc->start_time - sc->empty_duration; current_dts = -sc->time_offset; if (sc->ctts_data && sc->stts_data && sc->ctts_data[0].duration / FFMAX(sc->stts_data[0].duration, 1) > 16) { @@ -2297,7 +2298,7 @@ free_and_return: static int mov_read_elst(MOVContext *c, AVIOContext *pb, MOVAtom atom) { MOVStreamContext *sc; - int i, edit_count, version; + int i, edit_count, version, edit_start_index = 0; if (c->fc->nb_streams < 1) return 0; @@ -2321,9 +2322,11 @@ static int mov_read_elst(MOVContext *c, AVIOContext *pb, MOVAtom atom) time = (int32_t)avio_rb32(pb); /* media time */ } avio_rb32(pb); /* Media rate */ - if (i == 0 && time >= -1) { - sc->time_offset = time != -1 ? time : -duration; - } + if (i == 0 && time == -1) { + sc->empty_duration = duration; + edit_start_index = 1; + } else if (i == edit_start_index && time >= 0) + sc->start_time = time; } if (edit_count > 1) |