]> git.nihav.org Git - nihav.git/commitdiff
allow to skip index building
authorKostya Shishkov <kostya.shishkov@gmail.com>
Sat, 16 Nov 2019 08:59:40 +0000 (09:59 +0100)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Sat, 16 Nov 2019 08:59:40 +0000 (09:59 +0100)
nihav-commonfmt/src/demuxers/avi.rs
nihav-core/src/demuxers/mod.rs
nihav-realmedia/src/demuxers/realmedia.rs

index 93ac060b96b37326e39bdb7801287ae3c3f43cae..3361806d9f3afb8ec99c8238016b9aec9d63c41e 100644 (file)
@@ -224,16 +224,18 @@ impl<'a> AVIDemuxer<'a> {
             }
             rest_size -= csz;
         }
-        self.src.read_skip(self.movi_size)?;
-        while rest_size > 0 {
-            let ret = self.parse_chunk(strmgr, RIFFTag::Chunk(mktag!(b"idx1")), rest_size,0);
-            if ret.is_err() { break; }
-            let (csz, end) = ret.unwrap();
-            if end {
-                let _res = parse_idx1(&mut self.src, strmgr, seek_idx, csz, self.movi_pos);
-                break;
+        if !seek_idx.skip_index {
+            self.src.read_skip(self.movi_size)?;
+            while rest_size > 0 {
+                let ret = self.parse_chunk(strmgr, RIFFTag::Chunk(mktag!(b"idx1")), rest_size,0);
+                if ret.is_err() { break; }
+                let (csz, end) = ret.unwrap();
+                if end {
+                    let _res = parse_idx1(&mut self.src, strmgr, seek_idx, csz, self.movi_pos);
+                    break;
+                }
+                rest_size -= csz;
             }
-            rest_size -= csz;
         }
         if self.movi_pos != 0 {
             self.src.seek(SeekFrom::Start(self.movi_pos))?;
index 08837822be8c6253af59f739c3325be85935d2a3..ee2fe58ae871aa604a05ee13b0092acf0153ad4b 100644 (file)
@@ -203,6 +203,7 @@ pub struct SeekIndexResult {
 pub struct SeekIndex {
     pub seek_info:  Vec<StreamSeekInfo>,
     pub mode:       SeekIndexMode,
+    pub skip_index: bool,
 }
 
 impl SeekIndex {
@@ -307,6 +308,9 @@ impl<'a> Demuxer<'a> {
         }
     }
     pub fn seek(&mut self, time: u64) -> DemuxerResult<()> {
+        if self.seek_idx.skip_index {
+            return Err(DemuxerError::NotPossible);
+        }
         self.dmx.seek(time, &self.seek_idx)
     }
     pub fn get_seek_index(&self) -> &SeekIndex {
index e3d7447f580335e50127a831d1835ce092a83b8c..fa3920a0a3d0d042d7493bcf24755cf370ded324 100644 (file)
@@ -1060,7 +1060,11 @@ impl<'a> RealMediaDemuxer<'a> {
         else if id == mktag!(b"DATA") {
             self.data_chunks.push((self.src.tell() - 10, size, ver));
         }
-        else if id == mktag!(b"INDX") { self.parse_index(seek_idx, (size as usize) - 10, ver)?; }
+        else if id == mktag!(b"INDX") {
+            if !seek_idx.skip_index {
+                self.parse_index(seek_idx, (size as usize) - 10, ver)?;
+            }
+        }
         else if id == 0               { return Ok(true); }
         else                          { println!("unknown chunk type {:08X}", id); }