From bd0e0f2a3ded47cd5cc2ebfabfe5cdc823c57acb Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Thu, 26 Feb 2026 18:43:38 +0100 Subject: [PATCH] hwdec-vaapi: fix some PTS/DTS confusion --- hwdec-vaapi/src/lib.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/hwdec-vaapi/src/lib.rs b/hwdec-vaapi/src/lib.rs index 25e8bba..b4cdc7b 100644 --- a/hwdec-vaapi/src/lib.rs +++ b/hwdec-vaapi/src/lib.rs @@ -184,7 +184,7 @@ struct WaitingFrame { } struct Reorderer { - last_ref_dts: Option, + last_ref_pts: Option, frames: VecDeque, 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"); -- 2.39.5