From: Kostya Shishkov Date: Thu, 2 Apr 2026 04:38:29 +0000 (+0200) Subject: use explicit "timestamp valid" flag in display queue X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;h=17b81a088d1c9971e21ce40d8bf02a1ebaebc3fa;p=nihav-player.git use explicit "timestamp valid" flag in display queue --- diff --git a/videoplayer/src/main.rs b/videoplayer/src/main.rs index 47d4dbb..64db90d 100644 --- a/videoplayer/src/main.rs +++ b/videoplayer/src/main.rs @@ -319,6 +319,7 @@ pub struct DispFrame<'a> { pub struct DispQueue<'a> { pub pool: Vec>, pub first_ts: u64, + pub ts_valid: bool, pub last_ts: u64, pub start: usize, pub end: usize, @@ -346,7 +347,7 @@ impl<'a> DispQueue<'a> { let mut osd_tex = texture_creator.create_texture_streaming(PixelFormatEnum::RGBA8888, width as u32, OSD_HEIGHT as u32).expect("failed to create RGBA texture"); osd_tex.set_blend_mode(BlendMode::Blend); - Self { pool, osd_tex, first_ts: 0, last_ts: 0, start: 0, end: 0, len, width, height } + Self { pool, osd_tex, first_ts: 0, last_ts: 0, ts_valid: false, start: 0, end: 0, len, width, height } } fn flush(&mut self) { @@ -354,6 +355,7 @@ impl<'a> DispQueue<'a> { self.end = 0; self.first_ts = 0; self.last_ts = 0; + self.ts_valid = false; for frm in self.pool.iter_mut() { frm.valid = false; } @@ -382,6 +384,8 @@ impl<'a> DispQueue<'a> { } if !self.is_empty() { self.first_ts = self.pool[self.start].ts; + } else { + self.ts_valid = false; } } } @@ -551,7 +555,7 @@ impl Player { self.tkeep.reset_ts(); self.prefill(dmx, disp_queue)?; - if !disp_queue.is_empty() { + if disp_queue.ts_valid { self.tkeep.reset_all(disp_queue.first_ts); } else { let mut iterations = 0; diff --git a/videoplayer/src/videodec.rs b/videoplayer/src/videodec.rs index c910d6d..e44755b 100644 --- a/videoplayer/src/videodec.rs +++ b/videoplayer/src/videodec.rs @@ -472,7 +472,6 @@ impl VideoControl { pub fn fill(&mut self, disp_queue: &mut DispQueue) { while !disp_queue.is_full() { - let is_empty = disp_queue.is_empty(); if let Ok((pic, time)) = self.vfrecv.try_recv() { let buf = pic.get_vbuf().expect("video frame should be of u8 type"); self.do_yuv = buf.get_info().get_format().get_model().is_yuv(); @@ -495,8 +494,9 @@ impl VideoControl { frm.valid = true; frm.is_yuv = self.do_yuv; frm.ts = time; - if is_empty { + if !disp_queue.ts_valid { disp_queue.first_ts = time; + disp_queue.ts_valid = true; } disp_queue.last_ts = time; } else {