U16: move History::kept into the H265 next_picture, its only caller
Browse files at this commitcf857a20a69e05c43e7a60ad2715383b999a5be6Parent: 2b83b502 changed files +9 -13
- crates/ec-vk/src/h265.rs +6 -1
- crates/ec-vk/src/history.rs +3 -12
crates/ec-vk/src/h265.rsmodified+6 -1
| @@ -244,7 +244,12 @@ impl H265Encoder { | ||
| 244 | 244 | .history |
| 245 | 245 | .next(force_keyframe || self.position >= self.gop_size); |
| 246 | 246 | self.poc = if step.key { 0 } else { self.poc + 1 }; |
| 247 | - let keep = self.history.kept(&step); | |
| 247 | + let reference = step.reference.map(|(slot, _)| slot as usize); | |
| 248 | + let keep = std::array::from_fn(|i| { | |
| 249 | + self.history.slots[i] | |
| 250 | + .filter(|_| i != step.slot as usize && Some(i) != reference) | |
| 251 | + .map(|h| h.data) | |
| 252 | + }); | |
| 248 | 253 | self.history.store(&step, self.poc); |
| 249 | 254 | self.position = if step.key { 1 } else { self.position + 1 }; |
| 250 | 255 | self.flight.push(Meta { |
crates/ec-vk/src/history.rsmodified+3 -12
| @@ -5,10 +5,10 @@ const ANCHOR_EVERY: u64 = 16; | ||
| 5 | 5 | const MAX_AGE: u64 = 120; |
| 6 | 6 | |
| 7 | 7 | #[derive(Debug, Clone, Copy)] |
| 8 | -struct Held<T> { | |
| 8 | +pub(crate) struct Held<T> { | |
| 9 | 9 | id: u64, |
| 10 | 10 | acked: bool, |
| 11 | - data: T, | |
| 11 | + pub(crate) data: T, | |
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | /// Where the next picture goes and what it references. |
| @@ -26,7 +26,7 @@ pub(crate) struct Step<T> { | ||
| 26 | 26 | /// acknowledged them, the last two chain each picture to the previous one. |
| 27 | 27 | pub(crate) struct History<T> { |
| 28 | 28 | next_id: u64, |
| 29 | - slots: [Option<Held<T>>; DPB_SLOTS], | |
| 29 | + pub(crate) slots: [Option<Held<T>>; DPB_SLOTS], | |
| 30 | 30 | last: Option<(usize, T)>, |
| 31 | 31 | next_anchor: usize, |
| 32 | 32 | armed: bool, |
| @@ -107,15 +107,6 @@ impl<T: Copy> History<T> { | ||
| 107 | 107 | self.last = Some((slot, data)); |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - pub(crate) fn kept(&self, step: &Step<T>) -> [Option<T>; DPB_SLOTS] { | |
| 111 | - let reference = step.reference.map(|(slot, _)| slot as usize); | |
| 112 | - std::array::from_fn(|i| { | |
| 113 | - self.slots[i] | |
| 114 | - .filter(|_| i != step.slot as usize && Some(i) != reference) | |
| 115 | - .map(|h| h.data) | |
| 116 | - }) | |
| 117 | - } | |
| 118 | - | |
| 119 | 110 | fn newest_acked(&self, id: u64) -> Option<(usize, T)> { |
| 120 | 111 | (0..DPB_SLOTS) |
| 121 | 112 | .filter_map(|i| self.slots[i].map(|h| (i, h))) |