shuffel for every frame

This commit is contained in:
0m.ax 2026-07-18 20:48:20 +02:00
parent 1e93198c31
commit 28d5d6db14

View file

@ -229,12 +229,13 @@ fn packer_loop(
continue; continue;
} }
// Regenerate the permutation when the frame size changes. // Rebuild index array only when frame size changes; otherwise
// re-shuffle the existing permutation in place.
if frame.len() != last_frame_len { if frame.len() != last_frame_len {
permutation = (0..frame.len()).collect(); permutation = (0..frame.len()).collect();
fisher_yates_shuffle(&mut permutation, &mut rng);
last_frame_len = frame.len(); last_frame_len = frame.len();
} }
fisher_yates_shuffle(&mut permutation, &mut rng);
// Walk the permutation, packing pixels into packets. // Walk the permutation, packing pixels into packets.
let mut buf = grab_buf(&queue); let mut buf = grab_buf(&queue);