This commit is contained in:
2026-06-18 20:48:54 +02:00
parent 8efb9c031e
commit 3d42a7b61b
215 changed files with 235 additions and 233 deletions

View File

@ -8,6 +8,8 @@ pub struct VideoFrame {
pub lines: Vec<VideoLine>,
}
const LINES_PER_FRAME: usize = 480; // NTSC (576 for PAL)
pub struct LineAssembler<I> {
pub inner: I,
pub current_line: Vec<Sample>,
@ -37,22 +39,57 @@ where
self.current_line.push(s);
}
Ok(SyncEvent::HSync) => {
// Save the finished line
let line = VideoLine {
samples: std::mem::take(&mut self.current_line),
};
self.current_frame.push(line);
if self.current_frame.len() >= LINES_PER_FRAME {
let frame = VideoFrame {
lines: std::mem::take(&mut self.current_frame),
};
return Some(Ok(frame));
}
}
Ok(SyncEvent::VSync) => {
// Frame finished
let frame = VideoFrame {
lines: std::mem::take(&mut self.current_frame),
};
return Some(Ok(frame));
// test without vsync
}
Err(e) => return Some(Err(e)),
}
}
}
}
// impl<I, E> Iterator for LineAssembler<I>
// where
// I: Iterator<Item = Result<SyncEvent, E>>,
// {
// type Item = Result<VideoFrame, E>;
//
// fn next(&mut self) -> Option<Self::Item> {
// loop {
// match self.inner.next()? {
// Ok(SyncEvent::VideoSample(s)) => {
// self.current_line.push(s);
// }
// Ok(SyncEvent::HSync) => {
// // Save the finished line
// let line = VideoLine {
// samples: std::mem::take(&mut self.current_line),
// };
//
// self.current_frame.push(line);
// }
// Ok(SyncEvent::VSync) => {
// // Frame finished
// let frame = VideoFrame {
// lines: std::mem::take(&mut self.current_frame),
// };
// self.current_line.clear();
// return Some(Ok(frame));
// }
// Err(e) => return Some(Err(e)),
// }
// }
// }
// }