changeset 5347:f09a07cad10b libavformat

compute dts shift with ctts value, cslg atom might be missing, fix #419
author bcoudurier
date Thu, 05 Nov 2009 07:30:53 +0000
parents e226b1d6a6ee
children b14cad0786eb
files mov.c
diffstat 1 files changed, 5 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/mov.c	Thu Nov 05 07:17:10 2009 +0000
+++ b/mov.c	Thu Nov 05 07:30:53 2009 +0000
@@ -1362,29 +1362,6 @@
     return 0;
 }
 
-static int mov_read_cslg(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
-{
-    AVStream *st;
-    MOVStreamContext *sc;
-
-    if (c->fc->nb_streams < 1)
-        return 0;
-    st = c->fc->streams[c->fc->nb_streams-1];
-    sc = st->priv_data;
-
-    get_be32(pb); // version + flags
-
-    sc->dts_shift = get_be32(pb);
-    dprintf(c->fc, "dts shift %d\n", sc->dts_shift);
-
-    get_be32(pb); // least dts to pts delta
-    get_be32(pb); // greatest dts to pts delta
-    get_be32(pb); // pts start
-    get_be32(pb); // pts end
-
-    return 0;
-}
-
 static int mov_read_ctts(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
 {
     AVStream *st;
@@ -1415,7 +1392,12 @@
 
         sc->ctts_data[i].count   = count;
         sc->ctts_data[i].duration= duration;
+        if (duration < 0)
+            sc->dts_shift = FFMAX(sc->dts_shift, -duration);
     }
+
+    dprintf(c->fc, "dts shift %d\n", sc->shift);
+
     return 0;
 }
 
@@ -1978,7 +1960,6 @@
 static const MOVParseTableEntry mov_default_parse_table[] = {
 { MKTAG('a','v','s','s'), mov_read_extradata },
 { MKTAG('c','o','6','4'), mov_read_stco },
-{ MKTAG('c','s','l','g'), mov_read_cslg },
 { MKTAG('c','t','t','s'), mov_read_ctts }, /* composition time to sample */
 { MKTAG('d','i','n','f'), mov_read_default },
 { MKTAG('d','r','e','f'), mov_read_dref },