route the size and byte maths through saturating helpers

This commit is contained in:
2026-09-21 01:20:11 +03:00
parent 7c577eafd7
commit cd583ba02b
3 changed files with 46 additions and 21 deletions
+1 -1
View File
@@ -724,7 +724,7 @@ fn compute_output_dims(
let cap = width_limit.unwrap_or(u32::MAX);
if raw_w > cap {
let scale = f64::from(cap) / f64::from(raw_w);
let nh = (f64::from(raw_h) * scale).round() as u32;
let nh = crate::encode::round_u32(f64::from(raw_h) * scale);
(cap, (nh / 2) * 2)
} else {
((raw_w / 2) * 2, (raw_h / 2) * 2)