Skip to content

Commit

Permalink
Checks
Browse files Browse the repository at this point in the history
  • Loading branch information
kornelski committed Dec 6, 2023
1 parent 7531529 commit 912bea9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/denoise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ impl Acc {
/// Actual pixel + blurred pixel
#[inline(always)]
pub fn get(&self, idx: usize) -> Option<(RGB8, RGB8)> {
if idx >= LOOKAHEAD {
debug_assert!(idx < LOOKAHEAD);
return None;
}
if self.alpha_bits & (1 << idx) == 0 {
Some((
RGB8::new(self.r[idx], self.g[idx], self.b[idx]),
Expand Down Expand Up @@ -349,7 +353,7 @@ fn cohort(color: RGB8) -> bool {
/// importance = how much it exceeds percetible threshold
#[inline(always)]
fn pixel_importance(diff_with_bg: u32, threshold: u32, min: u8, max: u8) -> u8 {
assert!((u32::from(min) + u32::from(max)) <= 255);
debug_assert!((u32::from(min) + u32::from(max)) <= 255);
let exceeds = diff_with_bg.saturating_sub(threshold);
min + (exceeds.saturating_mul(u32::from(max)) / (threshold.saturating_mul(48))).min(u32::from(max)) as u8
}
Expand Down

0 comments on commit 912bea9

Please sign in to comment.