]> rtime.felk.cvut.cz Git - frescor/ffmpeg.git/commitdiff
Extend mov edit list support to work for a first padding entry with
authorreimar <reimar@9553f0bf-9b14-0410-a0b8-cfaf0461ba5b>
Mon, 16 Mar 2009 20:49:52 +0000 (20:49 +0000)
committerreimar <reimar@9553f0bf-9b14-0410-a0b8-cfaf0461ba5b>
Mon, 16 Mar 2009 20:49:52 +0000 (20:49 +0000)
time == -1 and duration. Complicated since time is relative to stream,
duration relative to container time base.

git-svn-id: file:///var/local/repositories/ffmpeg/trunk@18019 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b

libavformat/mov.c

index eec6ce59a6bc06ce7a32d2722f39d8acca3bf089..bb0c035ca64389cda72cceff1796513d015c6890 100644 (file)
@@ -1278,8 +1278,9 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
 
     /* adjust first dts according to edit list */
     if (sc->time_offset) {
+        int rescaled = sc->time_offset < 0 ? av_rescale(sc->time_offset, sc->time_scale, mov->time_scale) : sc->time_offset;
         assert(sc->time_offset % sc->time_rate == 0);
-        current_dts = - (sc->time_offset / sc->time_rate);
+        current_dts = - (rescaled / sc->time_rate);
     }
 
     /* only use old uncompressed audio chunk demuxing when stts specifies it */
@@ -1774,12 +1775,12 @@ static int mov_read_elst(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
 
     for(i=0; i<edit_count; i++){
         int time;
-        get_be32(pb); /* Track duration */
+        int duration = get_be32(pb); /* Track duration */
         time = get_be32(pb); /* Media time */
         get_be32(pb); /* Media rate */
-        if (i == 0 && time != -1) {
-            sc->time_offset = time;
-            sc->time_rate = av_gcd(sc->time_rate, time);
+        if (i == 0 && time >= -1) {
+            sc->time_offset = time != -1 ? time : -duration;
+            sc->time_rate = av_gcd(sc->time_rate, FFABS(sc->time_offset));
         }
     }