]> git.nihav.org Git - nihav-player.git/commitdiff
hwdec-vaapi: fix some PTS/DTS confusion
authorKostya Shishkov <kostya.shishkov@gmail.com>
Thu, 26 Feb 2026 17:43:38 +0000 (18:43 +0100)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Thu, 26 Feb 2026 17:43:38 +0000 (18:43 +0100)
hwdec-vaapi/src/lib.rs

index 25e8bba5c65b844b175143029a1a1624b5ce9530..b4cdc7b143c94871a2ecc7f5005fbc9108048437 100644 (file)
@@ -184,7 +184,7 @@ struct WaitingFrame {
 }
 
 struct Reorderer {
-    last_ref_dts:   Option<u64>,
+    last_ref_pts:   Option<u64>,
     frames:         VecDeque<WaitingFrame>,
     flush:          bool,
 }
@@ -194,7 +194,7 @@ const MAX_DPB_SIZE: usize = 16;
 impl Default for Reorderer {
     fn default() -> Self {
         Self {
-            last_ref_dts:   None,
+            last_ref_pts:   None,
             frames:         VecDeque::with_capacity(MAX_DPB_SIZE),
             flush:          false,
         }
@@ -206,10 +206,10 @@ impl Reorderer {
         if self.frames.is_empty() {
             self.frames.push_back(new_frame);
         } else {
-            let new_dts = new_frame.ts;
+            let new_pts = new_frame.ts;
             let mut idx = 0;
             for frm in self.frames.iter() {
-                if frm.ts > new_dts {
+                if frm.ts > new_pts {
                     break;
                 }
                 idx += 1;
@@ -222,17 +222,17 @@ impl Reorderer {
             self.flush = false;
         }
         if !self.frames.is_empty() && self.frames[0].pic.query_status() == Ok(VASurfaceStatus::Ready) {
-            let expected_ts = self.last_ref_dts.map(|ts| ts + 1);
+            let expected_ts = self.last_ref_pts.map(|ts| ts + 1);
             let first_ts = self.frames[0].ts;
             if self.flush || Some(first_ts) == expected_ts || self.frames.len() >= MAX_DPB_SIZE {
-                self.last_ref_dts = Some(first_ts);
+                self.last_ref_pts = Some(first_ts);
                 return self.frames.pop_front();
             }
         }
         None
     }
     fn flush(&mut self) {
-        self.last_ref_dts = None;
+        self.last_ref_pts = None;
         self.flush = true;
     }
 }
@@ -655,7 +655,7 @@ println!("config creation failed!");
         let src = pkt.get_buffer();
         let vactx = if let Some(ref mut ctx) = self.vaapi { ctx } else { return Err(DecoderError::Bug) };
 
-        let timestamp = pkt.get_dts().unwrap_or_else(|| pkt.get_pts().unwrap_or(0));
+        let timestamp = pkt.get_pts().unwrap_or(0);
 
         if vactx.surfaces.is_empty() {
 panic!("ran out of free surfaces");
@@ -1080,7 +1080,7 @@ panic!("ran out of free surfaces");
                         vactx.ref_pics.push((pic, id));
                     }
 
-                    let ts = NATimeInfo::new(None, Some(ts), None, self.tb_num, self.tb_den);
+                    let ts = NATimeInfo::new(Some(ts), None, None, self.tb_num, self.tb_den);
                     Some(NAFrame::new(ts, ftype, is_idr, self.info.clone(), self.out_frm.clone()).into_ref())
                 } else {
                     panic!("can't sync");
@@ -1113,7 +1113,7 @@ panic!("ran out of free surfaces");
                         vactx.ref_pics.push((pic, id));
                     }
 
-                    let ts = NATimeInfo::new(None, Some(ts), None, self.tb_num, self.tb_den);
+                    let ts = NATimeInfo::new(Some(ts), None, None, self.tb_num, self.tb_den);
                     Some(NAFrame::new(ts, ftype, is_idr, self.info.clone(), self.out_frm.clone()).into_ref())
                 } else {
                     panic!("can't sync");
@@ -1354,7 +1354,7 @@ mod test {
             }
             dec.decode(&pkt).expect("decoded");
             let frm = dec.get_last_frames().expect("get frame");
-            let timestamp = frm.get_dts().unwrap_or_else(|| frm.get_pts().unwrap_or(0));
+            let timestamp = frm.get_pts().unwrap_or(0);
 
             let pic = frm.get_buffer().get_vbuf().expect("got picture");