From cf857a20a69e05c43e7a60ad2715383b999a5be6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Wed, 2 Dec 2026 13:40:56 +0300 Subject: [PATCH] U16: move History::kept into the H265 next_picture, its only caller --- crates/ec-vk/src/h265.rs | 7 ++++++- crates/ec-vk/src/history.rs | 15 +++------------ 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/crates/ec-vk/src/h265.rs b/crates/ec-vk/src/h265.rs index 21aeb9e2..fd42a644 100644 --- a/crates/ec-vk/src/h265.rs +++ b/crates/ec-vk/src/h265.rs @@ -244,7 +244,12 @@ impl H265Encoder { .history .next(force_keyframe || self.position >= self.gop_size); self.poc = if step.key { 0 } else { self.poc + 1 }; - let keep = self.history.kept(&step); + let reference = step.reference.map(|(slot, _)| slot as usize); + let keep = std::array::from_fn(|i| { + self.history.slots[i] + .filter(|_| i != step.slot as usize && Some(i) != reference) + .map(|h| h.data) + }); self.history.store(&step, self.poc); self.position = if step.key { 1 } else { self.position + 1 }; self.flight.push(Meta { diff --git a/crates/ec-vk/src/history.rs b/crates/ec-vk/src/history.rs index 65e13eae..343d2908 100644 --- a/crates/ec-vk/src/history.rs +++ b/crates/ec-vk/src/history.rs @@ -5,10 +5,10 @@ const ANCHOR_EVERY: u64 = 16; const MAX_AGE: u64 = 120; #[derive(Debug, Clone, Copy)] -struct Held { +pub(crate) struct Held { id: u64, acked: bool, - data: T, + pub(crate) data: T, } /// Where the next picture goes and what it references. @@ -26,7 +26,7 @@ pub(crate) struct Step { /// acknowledged them, the last two chain each picture to the previous one. pub(crate) struct History { next_id: u64, - slots: [Option>; DPB_SLOTS], + pub(crate) slots: [Option>; DPB_SLOTS], last: Option<(usize, T)>, next_anchor: usize, armed: bool, @@ -107,15 +107,6 @@ impl History { self.last = Some((slot, data)); } - pub(crate) fn kept(&self, step: &Step) -> [Option; DPB_SLOTS] { - let reference = step.reference.map(|(slot, _)| slot as usize); - std::array::from_fn(|i| { - self.slots[i] - .filter(|_| i != step.slot as usize && Some(i) != reference) - .map(|h| h.data) - }) - } - fn newest_acked(&self, id: u64) -> Option<(usize, T)> { (0..DPB_SLOTS) .filter_map(|i| self.slots[i].map(|h| (i, h)))