changeset 1005:d5b8ab2409f7 libavformat

some mov files have invalid pts so we need to consider these pts too in calculating the timabase
author michael
date Sat, 11 Mar 2006 11:30:07 +0000
parents 409b399440a3
children 15bfc3c063dc
files mov.c
diffstat 1 files changed, 11 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mov.c	Sat Mar 11 04:27:58 2006 +0000
+++ b/mov.c	Sat Mar 11 11:30:07 2006 +0000
@@ -1258,6 +1258,8 @@
 
 static int mov_read_ctts(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
 {
+    AVStream *st = c->fc->streams[c->fc->nb_streams-1];
+    MOVStreamContext *sc = (MOVStreamContext *)st->priv_data;
     unsigned int i, entries;
 
     get_byte(pb); /* version */
@@ -1266,14 +1268,19 @@
     if(entries >= UINT_MAX / sizeof(Time2Sample))
         return -1;
 
-    c->streams[c->fc->nb_streams-1]->ctts_count = entries;
-    c->streams[c->fc->nb_streams-1]->ctts_data = av_malloc(entries * sizeof(Time2Sample));
+    sc->ctts_count = entries;
+    sc->ctts_data = av_malloc(entries * sizeof(Time2Sample));
 
     dprintf("track[%i].ctts.entries = %i\n", c->fc->nb_streams-1, entries);
 
     for(i=0; i<entries; i++) {
-        c->streams[c->fc->nb_streams - 1]->ctts_data[i].count= get_be32(pb);
-        c->streams[c->fc->nb_streams - 1]->ctts_data[i].duration= get_be32(pb);
+        int count    =get_be32(pb);
+        int duration =get_be32(pb);
+
+        sc->ctts_data[i].count   = count;
+        sc->ctts_data[i].duration= duration;
+
+        sc->time_rate= ff_gcd(sc->time_rate, duration);
     }
     return 0;
 }