]> git.nihav.org Git - nihav-player.git/commitdiff
switch to NATimeInfo::rescale_ts()
authorKostya Shishkov <kostya.shishkov@gmail.com>
Thu, 22 Jan 2026 18:07:05 +0000 (19:07 +0100)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Thu, 22 Jan 2026 18:07:05 +0000 (19:07 +0100)
sndplay/src/demux.rs
sndplay/src/main.rs
videoplayer/src/audiodec.rs
videoplayer/src/videodec.rs

index f8e3c757a8348dd1bc8f9a0e98c029c5feb09236..4e96c1b953eeb27c98229ff77026ed24f3ebf7b8 100644 (file)
@@ -26,7 +26,7 @@ impl<'a> RawStreamCtx<'a> {
         }
         if packet.is_keyframe() {
             let pts = packet.get_pts().unwrap_or(self.pts);
-            let time = NATimeInfo::ts_to_time(pts, 1000, self.stream.tb_num, self.stream.tb_den);
+            let time = NATimeInfo::rescale_ts(pts, self.stream.tb_num, self.stream.tb_den, 1, 1000);
             let in_range = if let Some(last) = self.seek.seek_info[0].entries.last() {
                     last.pts >= pts
                 } else {
@@ -159,7 +159,7 @@ impl<'a> DemuxerObject<'a> {
             DemuxerObject::Normal(ref dmx) => dmx.get_duration(),
             DemuxerObject::Raw(ref dmx, _, _) => dmx.get_duration(),
             DemuxerObject::RawStream(ref ctx) => {
-                NATimeInfo::ts_to_time(ctx.stream.duration, 1000, ctx.stream.tb_num, ctx.stream.tb_den)
+                NATimeInfo::rescale_ts(ctx.stream.duration, ctx.stream.tb_num, ctx.stream.tb_den, 1, 1000)
             },
             _ => 0,
         }
index f829f635610ca6f48ef36e902d50838e743a5156..80a6d40c192691e5f94348b8eb0f1e806719e451 100644 (file)
@@ -151,7 +151,7 @@ impl<'a> Decoder<'a> {
                                     return false;
                                 }
                                 if let Some(pts) = frm.ts.get_pts() {
-                                    self.samplepos = NATimeInfo::ts_to_time(pts, u64::from(self.arate), frm.ts.tb_num, frm.ts.tb_den);
+                                    self.samplepos = NATimeInfo::rescale_ts(pts, frm.ts.tb_num, frm.ts.tb_den, 1, self.arate);
                                 }
                                 if buf.get_audio_length() == 0 {
                                     return false;
@@ -290,7 +290,7 @@ impl Player {
                 ainfo = Some(info);
                 stream_no = i;
                 if s.duration > 0 {
-                    duration = NATimeInfo::ts_to_time(s.duration, 1000, s.tb_num, s.tb_den);
+                    duration = NATimeInfo::rescale_ts(s.duration, s.tb_num, s.tb_den, 1, 1000);
                 }
                 break;
             }
index 726758ef468ae7913c39ac2c8548d67d3de3bc19..fac1c0007d855360ab108683dd457a048b04dcdd 100644 (file)
@@ -203,7 +203,7 @@ fn start_audio_decoding(asystem: &AudioSubsystem, ainfo: NAAudioInfo, sbr_hack:
                             if let Ok(frm) = adec.decode(&mut audio_dec.dsupp, &pkt) {
                                 let buf = frm.get_buffer();
                                 if let Some(pts) = frm.get_pts() {
-                                    samplepos = NATimeInfo::ts_to_time(pts, u64::from(dst_info.sample_rate), frm.ts.tb_num, frm.ts.tb_den) as usize;
+                                    samplepos = NATimeInfo::rescale_ts(pts, frm.ts.tb_num, frm.ts.tb_den, 1, dst_info.sample_rate) as usize;
                                     if sbr_hack {
                                         samplepos >>= 2;
                                     }
index 295cfc753ee64002f9288eacf7f54f256d6fbbba..d43953748f9d5dc9439f1cc8deadaa89b8e05136 100644 (file)
@@ -85,7 +85,7 @@ impl VideoDecoder {
         let ret = self.scaler.convert(&bt, &mut opic);
         if ret.is_err() { println!(" scaler error {:?}", ret.err()); return None; }
         ret.unwrap();
-        let time = NATimeInfo::ts_to_time(ts, 1000, self.tb_num, self.tb_den);
+        let time = NATimeInfo::rescale_ts(ts, self.tb_num, self.tb_den, 1, 1000);
         Some((opic, time))
     }
     pub fn next_frame(&mut self, pkt: &NAPacket) -> Option<FrameRecord> {