Use one texture with two channels for video

This commit is contained in:
2024-11-03 13:26:01 -05:00
parent 8fdff927eb
commit b025f72604
5 changed files with 25 additions and 42 deletions
+9 -9
View File
@@ -113,7 +113,7 @@ impl CoreVB {
unsafe { vb_emulate(self.sim, &mut cycles) };
}
pub fn read_pixels(&mut self, buffers: &mut [Vec<u8>; 2]) -> bool {
pub fn read_pixels(&mut self, buffers: &mut [u8]) -> bool {
// SAFETY: the *mut VB owns its userdata.
// There is no way for the userdata to be null or otherwise invalid.
let data: &mut VBState = unsafe { &mut *vb_get_user_data(self.sim).cast() };
@@ -122,17 +122,17 @@ impl CoreVB {
}
data.frame_seen = false;
assert_eq!(buffers[0].len(), 384 * 224);
assert_eq!(buffers[1].len(), 384 * 224);
// the buffer must be big enough for our data
assert!(buffers.len() >= 384 * 224 * 2);
unsafe {
vb_get_pixels(
self.sim,
buffers[0].as_mut_ptr().cast(),
1,
384,
buffers[1].as_mut_ptr().cast(),
1,
384,
buffers.as_mut_ptr().cast(),
2,
384 * 2,
buffers.as_mut_ptr().offset(1).cast(),
2,
384 * 2,
);
};
true