From: Kostya Shishkov Date: Mon, 6 Jul 2020 12:15:38 +0000 (+0200) Subject: mov: take audio frame size/length into account while demuxing X-Git-Url: https://git.nihav.org/?p=nihav.git;a=commitdiff_plain;h=d940f0c273d4f783e5ec5509e7006322f6d33e05 mov: take audio frame size/length into account while demuxing --- diff --git a/nihav-commonfmt/src/demuxers/mov.rs b/nihav-commonfmt/src/demuxers/mov.rs index 19a602f..4904697 100644 --- a/nihav-commonfmt/src/demuxers/mov.rs +++ b/nihav-commonfmt/src/demuxers/mov.rs @@ -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; }