diff options
author | Kostya Shishkov <kostya.shishkov@gmail.com> | 2022-11-04 18:25:56 +0100 |
---|---|---|
committer | Kostya Shishkov <kostya.shishkov@gmail.com> | 2022-11-04 18:25:56 +0100 |
commit | 8e14efb001fac3fecb0cb56df8705d23fa2231a8 (patch) | |
tree | bdd21683de1db9d4c39d0d68cf8e180e7ea902cb /nihav-game/src | |
parent | 3867d436b51515207e0035e2c6cb127de3935c57 (diff) | |
download | nihav-8e14efb001fac3fecb0cb56df8705d23fa2231a8.tar.gz |
switch demuxers to use NAStream::make_ts()
Diffstat (limited to 'nihav-game/src')
-rw-r--r-- | nihav-game/src/demuxers/bmv.rs | 12 | ||||
-rw-r--r-- | nihav-game/src/demuxers/fst.rs | 6 | ||||
-rw-r--r-- | nihav-game/src/demuxers/gdv.rs | 6 | ||||
-rw-r--r-- | nihav-game/src/demuxers/hl_fmv.rs | 6 | ||||
-rw-r--r-- | nihav-game/src/demuxers/imax.rs | 6 | ||||
-rw-r--r-- | nihav-game/src/demuxers/q.rs | 6 | ||||
-rw-r--r-- | nihav-game/src/demuxers/siff.rs | 12 | ||||
-rw-r--r-- | nihav-game/src/demuxers/smush.rs | 19 | ||||
-rw-r--r-- | nihav-game/src/demuxers/vmd.rs | 3 | ||||
-rw-r--r-- | nihav-game/src/demuxers/vx.rs | 3 |
10 files changed, 26 insertions, 53 deletions
diff --git a/nihav-game/src/demuxers/bmv.rs b/nihav-game/src/demuxers/bmv.rs index ee88262..700c8d0 100644 --- a/nihav-game/src/demuxers/bmv.rs +++ b/nihav-game/src/demuxers/bmv.rs @@ -48,8 +48,7 @@ impl<'a> DemuxCore<'a> for BMVDemuxer<'a> { asize = (nblocks as usize) * 65 + 1; validate!(asize < size); let str = strmgr.get_stream(self.aud_id).unwrap(); - let (tb_num, tb_den) = str.get_timebase(); - let ts = NATimeInfo::new(Some(self.apos), None, None, tb_num, tb_den); + let ts = str.make_ts(Some(self.apos), None, None); let apkt = self.src.read_packet(str, ts, false, asize)?; self.apos += u64::from(nblocks) * 32; self.pkt_buf.push(apkt); @@ -61,8 +60,7 @@ impl<'a> DemuxCore<'a> for BMVDemuxer<'a> { self.src.read_buf(&mut buf[1..])?; let str = strmgr.get_stream(self.vid_id).unwrap(); - let (tb_num, tb_den) = str.get_timebase(); - let ts = NATimeInfo::new(Some(self.vpos), None, None, tb_num, tb_den); + let ts = str.make_ts(Some(self.vpos), None, None); let pkt = NAPacket::new(str, ts, (ctype & 3) == 3, buf); self.vpos += 1; @@ -189,8 +187,7 @@ impl<'a> DemuxCore<'a> for BMV3Demuxer<'a> { self.src.read_buf(&mut buf[1..])?; let str = strmgr.get_stream(self.aud_id).unwrap(); - let (tb_num, tb_den) = str.get_timebase(); - let ts = NATimeInfo::new(Some(self.apos), None, None, tb_num, tb_den); + let ts = str.make_ts(Some(self.apos), None, None); let apkt = NAPacket::new(str, ts, false, buf); self.apos += (asize as u64) / 41 * 32; @@ -210,8 +207,7 @@ impl<'a> DemuxCore<'a> for BMV3Demuxer<'a> { self.src.read_buf(&mut buf[1..])?; let str = strmgr.get_stream(self.vid_id).unwrap(); - let (tb_num, tb_den) = str.get_timebase(); - let ts = NATimeInfo::new(Some(self.vpos), None, None, tb_num, tb_den); + let ts = str.make_ts(Some(self.vpos), None, None); let pkt = NAPacket::new(str, ts, (ctype & 3) == 3, buf); self.vpos += 1; diff --git a/nihav-game/src/demuxers/fst.rs b/nihav-game/src/demuxers/fst.rs index c70584a..68f9537 100644 --- a/nihav-game/src/demuxers/fst.rs +++ b/nihav-game/src/demuxers/fst.rs @@ -73,8 +73,7 @@ impl<'a> DemuxCore<'a> for FutureVisionVideoDemuxer<'a> { } let str = strmgr.get_stream(id).unwrap(); - let (tb_num, tb_den) = str.get_timebase(); - let ts = NATimeInfo::new(Some(pts), None, None, tb_num, tb_den); + let ts = str.make_ts(Some(pts), None, None); self.src.read_packet(str, ts, true, size) } @@ -148,8 +147,7 @@ impl<'a> DemuxCore<'a> for FutureVisionAudioDemuxer<'a> { let pts = (self.src.tell() - 14) * 2; let str = strmgr.get_stream(self.a_id).unwrap(); - let (tb_num, tb_den) = str.get_timebase(); - let ts = NATimeInfo::new(Some(pts), None, None, tb_num, tb_den); + let ts = str.make_ts(Some(pts), None, None); self.src.read_packet(str, ts, true, size) } diff --git a/nihav-game/src/demuxers/gdv.rs b/nihav-game/src/demuxers/gdv.rs index 8f54bca..876f3c1 100644 --- a/nihav-game/src/demuxers/gdv.rs +++ b/nihav-game/src/demuxers/gdv.rs @@ -143,8 +143,7 @@ pktdta: Vec::new(), fn read_achunk(&mut self, strmgr: &mut StreamManager) -> DemuxerResult<NAPacket> { self.state = GDVState::AudioRead; let str = strmgr.get_stream(self.a_id.unwrap()).unwrap(); - let (tb_num, tb_den) = str.get_timebase(); - let ts = NATimeInfo::new(Some(u64::from(self.cur_frame)), None, None, tb_num, tb_den); + let ts = str.make_ts(Some(u64::from(self.cur_frame)), None, None); self.src.read_packet(str, ts, true, self.asize) } @@ -158,8 +157,7 @@ pktdta: Vec::new(), let flags = (tmp & 0xFF) as usize; self.state = GDVState::NewFrame; self.cur_frame += 1; - let (tb_num, tb_den) = str.get_timebase(); - let ts = NATimeInfo::new(Some(u64::from(self.cur_frame - 1)), None, None, tb_num, tb_den); + let ts = str.make_ts(Some(u64::from(self.cur_frame - 1)), None, None); src.read_packet(str, ts, (flags & 64) != 0, size) } } diff --git a/nihav-game/src/demuxers/hl_fmv.rs b/nihav-game/src/demuxers/hl_fmv.rs index b511bb9..20a8767 100644 --- a/nihav-game/src/demuxers/hl_fmv.rs +++ b/nihav-game/src/demuxers/hl_fmv.rs @@ -41,15 +41,13 @@ impl<'a> DemuxCore<'a> for HighlanderFMVDemuxer<'a> { match &tag { b"AUD1" => { let stream = strmgr.get_stream_by_id(1).unwrap(); - let (tb_num, tb_den) = stream.get_timebase(); - let ts = NATimeInfo::new(Some(self.apts), None, None, tb_num, tb_den); + let ts = stream.make_ts(Some(self.apts), None, None); self.apts += size as u64; self.src.read_packet(stream, ts, true, size) }, b"VID3" => { let stream = strmgr.get_stream_by_id(0).unwrap(); - let (tb_num, tb_den) = stream.get_timebase(); - let ts = NATimeInfo::new(Some(self.vpts), None, None, tb_num, tb_den); + let ts = stream.make_ts(Some(self.vpts), None, None); self.vpts += 1; self.src.read_packet(stream, ts, true, size) }, diff --git a/nihav-game/src/demuxers/imax.rs b/nihav-game/src/demuxers/imax.rs index a477ebe..2cd9f70 100644 --- a/nihav-game/src/demuxers/imax.rs +++ b/nihav-game/src/demuxers/imax.rs @@ -49,8 +49,7 @@ impl<'a> DemuxCore<'a> for IMAXDemuxer<'a> { match ftype { 0xAA97 => { let str = strmgr.get_stream(self.v_id).unwrap(); - let (tb_num, tb_den) = str.get_timebase(); - let ts = NATimeInfo::new(Some(self.cur_frame), None, None, tb_num, tb_den); + let ts = str.make_ts(Some(self.cur_frame), None, None); self.cur_frame += 1; let mut pkt = self.src.read_packet(str, ts, true, fsize)?; pkt.add_side_data(NASideData::Palette(self.pal_change, self.pal.clone())); @@ -73,8 +72,7 @@ impl<'a> DemuxCore<'a> for IMAXDemuxer<'a> { }, 0xAA99 => { let str = strmgr.get_stream(self.a_id).unwrap(); - let (tb_num, tb_den) = str.get_timebase(); - let ts = NATimeInfo::new(Some(self.apos), None, None, tb_num, tb_den); + let ts = str.make_ts(Some(self.apos), None, None); self.apos += fsize as u64; return self.src.read_packet(str, ts, true, fsize); }, diff --git a/nihav-game/src/demuxers/q.rs b/nihav-game/src/demuxers/q.rs index 6c52ab8..3735bfa 100644 --- a/nihav-game/src/demuxers/q.rs +++ b/nihav-game/src/demuxers/q.rs @@ -82,8 +82,7 @@ impl<'a> DemuxCore<'a> for QDemuxer<'a> { 0 => { if let Some(a_id) = self.a_id { let str = strmgr.get_stream(a_id).unwrap(); - let (tb_num, tb_den) = str.get_timebase(); - let ts = NATimeInfo::new(Some(self.apts), None, None, tb_num, tb_den); + let ts = str.make_ts(Some(self.apts), None, None); self.apts += (size / self.bps) as u64; return self.src.read_packet(str, ts, true, size); } else { @@ -101,8 +100,7 @@ impl<'a> DemuxCore<'a> for QDemuxer<'a> { 2 | 3 | 4 | 11 => { validate!(self.v_id.is_some()); let str = strmgr.get_stream(self.v_id.unwrap_or(0)).unwrap(); - let (tb_num, tb_den) = str.get_timebase(); - let ts = NATimeInfo::new(Some(self.vpts), None, None, tb_num, tb_den); + let ts = str.make_ts(Some(self.vpts), None, None); self.vpts += 1; let cur_len = self.side_data.len(); diff --git a/nihav-game/src/demuxers/siff.rs b/nihav-game/src/demuxers/siff.rs index 33c26f8..7bc29fc 100644 --- a/nihav-game/src/demuxers/siff.rs +++ b/nihav-game/src/demuxers/siff.rs @@ -83,8 +83,7 @@ impl<'a> SIFFDemuxer<'a> { let size = self.src.read_u16le()? as usize; validate!(size > 8); let stream = strmgr.get_stream(0).unwrap(); - let (tb_num, tb_den) = stream.get_timebase(); - let ts = NATimeInfo::new(Some(self.vpts), None, None, tb_num, tb_den); + let ts = stream.make_ts(Some(self.vpts), None, None); let kframe = self.vpts == 0; self.cframe += 1; let pkt = self.src.read_packet(stream, ts, kframe, size - 2)?; @@ -164,8 +163,7 @@ impl<'a> SIFFDemuxer<'a> { let size = self.src.read_u32le()? as usize; validate!(size > 6); let stream = strmgr.get_stream(0).unwrap(); - let (tb_num, tb_den) = stream.get_timebase(); - let ts = NATimeInfo::new(Some(self.vpts), None, None, tb_num, tb_den); + let ts = stream.make_ts(Some(self.vpts), None, None); let kframe = self.vpts == 0; self.cframe += 1; let pkt = self.src.read_packet(stream, ts, kframe, size - 4)?; @@ -238,8 +236,7 @@ impl<'a> SIFFDemuxer<'a> { let cur_size = self.size.min(1024 * (self.ablock as u32)); let stream = strmgr.get_stream(0).unwrap(); - let (tb_num, tb_den) = stream.get_timebase(); - let ts = NATimeInfo::new(None, None, None, tb_num, tb_den); + let ts = stream.make_ts(None, None, None); let pkt = self.src.read_packet(stream, ts, true, cur_size as usize)?; self.size -= cur_size; @@ -282,8 +279,7 @@ impl<'a> DemuxCore<'a> for SIFFDemuxer<'a> { std::mem::swap(&mut buf, &mut self.abuf); if let Some(stream) = strmgr.get_stream(1) { - let (tb_num, tb_den) = stream.get_timebase(); - let ts = NATimeInfo::new(Some(self.apts), None, None, tb_num, tb_den); + let ts = stream.make_ts(Some(self.apts), None, None); self.apts += (buf.len() / self.ablock) as u64; return Ok(NAPacket::new(stream, ts, true, buf)); } diff --git a/nihav-game/src/demuxers/smush.rs b/nihav-game/src/demuxers/smush.rs index 6476184..6132d9c 100644 --- a/nihav-game/src/demuxers/smush.rs +++ b/nihav-game/src/demuxers/smush.rs @@ -288,8 +288,7 @@ impl<'a> SmushDemuxer<'a> { let mut buf = Vec::new(); std::mem::swap(&mut self.chunks, &mut buf); let stream = strmgr.get_stream(0).unwrap(); - let (tb_num, tb_den) = stream.get_timebase(); - let ts = NATimeInfo::new(Some(self.cur_frame as u64 - 1), None, None, tb_num, tb_den); + let ts = stream.make_ts(Some(self.cur_frame as u64 - 1), None, None); return Ok(NAPacket::new(stream, ts, false, buf)); } if self.cur_frame == self.nframes { @@ -320,8 +319,7 @@ impl<'a> SmushDemuxer<'a> { let flags = self.src.read_u16le()?; if (opcode == 8) && (flags == 0x2E) { if let Some(stream) = strmgr.get_stream(1) { - let (tb_num, tb_den) = stream.get_timebase(); - let ts = NATimeInfo::new(None, None, None, tb_num, tb_den); + let ts = stream.make_ts(None, None, None); let mut buf = vec![0; size as usize]; write_u16le(&mut buf[0..2], opcode).unwrap(); @@ -342,10 +340,8 @@ impl<'a> SmushDemuxer<'a> { if size > 0x30 { self.src.read_skip(0x30)?; if let Some(stream) = strmgr.get_stream(1) { - let (tb_num, tb_den) = stream.get_timebase(); - let audio_size = size - 0x30; - let ts = NATimeInfo::new(Some(self.asize), None, None, tb_num, tb_den); + let ts = stream.make_ts(Some(self.asize), None, None); let pkt = self.src.read_packet(stream, ts, true, audio_size as usize)?; self.asize += audio_size; if (self.src.tell() & 1) == 1 { @@ -379,8 +375,7 @@ impl<'a> SmushDemuxer<'a> { let mut buf = Vec::new(); std::mem::swap(&mut self.chunks, &mut buf); let stream = strmgr.get_stream(0).unwrap(); - let (tb_num, tb_den) = stream.get_timebase(); - let ts = NATimeInfo::new(Some(self.cur_frame as u64 - 1), None, None, tb_num, tb_den); + let ts = stream.make_ts(Some(self.cur_frame as u64 - 1), None, None); return Ok(NAPacket::new(stream, ts, self.keyframe, buf)); } if self.cur_frame == self.nframes { @@ -427,8 +422,7 @@ impl<'a> SmushDemuxer<'a> { } } - let (tb_num, tb_den) = stream.get_timebase(); - let mut ts = NATimeInfo::new(None, None, None, tb_num, tb_den); + let mut ts = stream.make_ts(None, None, None); if nsamples != 0 { ts.pts = Some(self.asize); self.asize += u64::from(nsamples); @@ -616,8 +610,7 @@ impl<'a> DemuxCore<'a> for MCMPDemuxer<'a> { self.src.read_buf(&mut buf[4..])?; let stream = strmgr.get_stream(0).unwrap(); - let (tb_num, tb_den) = stream.get_timebase(); - let ts = NATimeInfo::new(Some(self.pts[idx]), None, None, tb_num, tb_den); + let ts = stream.make_ts(Some(self.pts[idx]), None, None); self.cur_frame += 1; diff --git a/nihav-game/src/demuxers/vmd.rs b/nihav-game/src/demuxers/vmd.rs index 663a1a8..c1ef0be 100644 --- a/nihav-game/src/demuxers/vmd.rs +++ b/nihav-game/src/demuxers/vmd.rs @@ -173,8 +173,7 @@ impl<'a> DemuxCore<'a> for VMDDemuxer<'a> { let str_id = if is_video { self.vid_id } else { self.aud_id }; let str = strmgr.get_stream(str_id).unwrap(); - let (tb_num, tb_den) = str.get_timebase(); - let ts = NATimeInfo::new(Some(u64::from(cur_frame.ts)), None, None, tb_num, tb_den); + let ts = str.make_ts(Some(u64::from(cur_frame.ts)), None, None); let pkt = NAPacket::new(str, ts, false, buf); Ok(pkt) diff --git a/nihav-game/src/demuxers/vx.rs b/nihav-game/src/demuxers/vx.rs index 1722841..1817682 100644 --- a/nihav-game/src/demuxers/vx.rs +++ b/nihav-game/src/demuxers/vx.rs @@ -84,8 +84,7 @@ impl<'a> DemuxCore<'a> for VXDemuxer<'a> { let stream = strmgr.get_stream(self.vid_id); if stream.is_none() { return Err(DemuxerError::InvalidData); } let stream = stream.unwrap(); - let (tn, td) = stream.get_timebase(); - let ts = NATimeInfo::new(Some(self.vno), None, None, tn, td); + let ts = stream.make_ts(Some(self.vno), None, None); let size = self.src.read_u16le()? as usize; validate!(size > 2); let _num_achunks = self.src.read_u16le()?; |