]> git.nihav.org Git - nihav-player.git/commitdiff
use explicit "timestamp valid" flag in display queue master
authorKostya Shishkov <kostya.shishkov@gmail.com>
Thu, 2 Apr 2026 04:38:29 +0000 (06:38 +0200)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Thu, 2 Apr 2026 04:38:29 +0000 (06:38 +0200)
videoplayer/src/main.rs
videoplayer/src/videodec.rs

index 47d4dbb9618ef08dca982dabec992e18f5368151..64db90d02a8c2e566aaa48d83458a3b53782cfac 100644 (file)
@@ -319,6 +319,7 @@ pub struct DispFrame<'a> {
 pub struct DispQueue<'a> {
     pub pool:       Vec<DispFrame<'a>>,
     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;
index c910d6d00e587d29e0cd0b52a292dcd64148ddab..e44755b8de43bbe83aa078330fc1b73cee7f1d3a 100644 (file)
@@ -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 {