]> git.nihav.org Git - nihav.git/commitdiff
mov: take audio frame size/length into account while demuxing
authorKostya Shishkov <kostya.shishkov@gmail.com>
Mon, 6 Jul 2020 12:15:38 +0000 (14:15 +0200)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Mon, 6 Jul 2020 12:15:38 +0000 (14:15 +0200)
nihav-commonfmt/src/demuxers/mov.rs

index 19a602ffc88e53f7788c509c661edb2566b6630c..4904697e193a901b9b974f518ff90f559b75824f 100644 (file)
@@ -846,8 +846,14 @@ impl Track {
             self.last_offset += size as u64;
             if self.stream_type == StreamType::Video {
                 self.samples_left -= 1;
-            } else if self.frame_samples != 0 {
-                self.samples_left -= self.frame_samples.min(self.samples_left);
+            } else if self.frame_samples != 0 && self.bsize != 0 {
+                let nblocks = size / self.bsize;
+                if nblocks > 0 {
+                    let consumed = (nblocks * self.frame_samples).min(self.samples_left);
+                    self.samples_left -= consumed;
+                } else {
+                    self.samples_left = 0;
+                }
             } else {
                 self.samples_left = 0;
             }