changeset 510:133287132e1d libavformat

* simplifying OpenDML AVI handling. * adding code to skip over JUNK. It turns out that video editing software uses junk to resize ix## chunks without actually scrubbing the data. That trips up our packet extraction code since it recognizes ix## entries as "packets". Basically we have to skip over JUNK chunks for exactly the same reason we have to skip over ix## entries.
author romansh
date Wed, 04 Aug 2004 20:57:35 +0000
parents 45abb3409125
children 056991ab9f10
files avidec.c
diffstat 1 files changed, 20 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/avidec.c	Mon Aug 02 13:00:58 2004 +0000
+++ b/avidec.c	Wed Aug 04 20:57:35 2004 +0000
@@ -49,6 +49,7 @@
     int64_t  movi_end;
     offset_t movi_list;
     int index_loaded;
+    int is_odml;
     DVDemuxContext* dv_demux;
 } AVIContext;
 
@@ -128,6 +129,10 @@
                 goto end_of_header;
             }
             break;
+        case MKTAG('d', 'm', 'l', 'h'):
+	    avi->is_odml = 1;
+	    url_fskip(pb, size + (size & 1));
+	    break;
         case MKTAG('a', 'v', 'i', 'h'):
 	    /* avi header */
             /* using frame_period is bad idea */
@@ -363,7 +368,8 @@
 {
     AVIContext *avi = s->priv_data;
     ByteIOContext *pb = &s->pb;
-    int n, d[8], size, i;
+    int n, d[8], size;
+    offset_t i;
     void* dstr;
 
     memset(d, -1, sizeof(int)*8);
@@ -377,19 +383,12 @@
     for(i=url_ftell(pb); !url_feof(pb); i++) {
         int j;
 
-	if (i >= avi->movi_end) { /* Let's see if it's an OpenDML AVI */
-	    uint32_t tag, size, tag2;
-	    url_fskip(pb, avi->riff_end - url_ftell(pb));
-	    if (get_riff(avi, pb) < 0)
-	        return -1;
-	    
-	    tag = get_le32(pb);
-	    size = get_le32(pb);
-	    tag2 = get_le32(pb);
-	    if (tag == MKTAG('L','I','S','T') && tag2 == MKTAG('m','o','v','i'))
-	        avi->movi_end = url_ftell(pb) + size - 4; 
-	    else
-	        return -1;
+	if (i >= avi->movi_end) {
+	    if (avi->is_odml) {
+		url_fskip(pb, avi->riff_end - i);
+	        avi->riff_end = avi->movi_end = url_filesize(url_fileno(pb));
+	    } else
+	        break;
 	}
 
         for(j=0; j<7; j++)
@@ -408,6 +407,13 @@
             
             url_fskip(pb, size);
         }
+
+	//parse JUNK
+        if(d[0] == 'J' && d[1] == 'U' && d[2] == 'N' && d[3] == 'K' &&
+           i + size <= avi->movi_end) {
+            
+            url_fskip(pb, size);
+        }
         
         //parse ##dc/##wb
         n= (d[0] - '0') * 10 + (d[1] - '0');