convert the last lossy casts to checked ones

This commit is contained in:
2026-09-21 01:22:16 +03:00
parent cd583ba02b
commit d297ec4271
5 changed files with 47 additions and 25 deletions
+13 -1
View File
@@ -44,6 +44,18 @@ pub(crate) fn round_u64(v: f64) -> u64 {
out
}
/// Round a logical-pixel measurement to the signed int a Win32 call wants.
/// DPI scales here are at most a handful, so the result is nothing like i32
/// range; clamping just makes that explicit.
pub(crate) fn round_i32(v: f64) -> i32 {
#[allow(
clippy::cast_possible_truncation,
reason = "value is clamped into i32 range on the line above the cast"
)]
let out = v.round().clamp(f64::from(i32::MIN), f64::from(i32::MAX)) as i32;
out
}
/// Progress update sent during encoding.
/// pass: 1-based pass number (1 or 2 for two-pass video, 1 for GIF).
/// `total_passes`: total number of passes.
@@ -614,7 +626,7 @@ fn encode_gif(ffmpeg: &Path, req: &TranscodeRequest) -> Result<()> {
let pass_start = std::time::Instant::now();
encode_gif_pass(
ffmpeg, req, scale_width, effective_fps,
(attempt as u8) + 1, max_attempts,
(u8::try_from(attempt).unwrap_or(0)) + 1, max_attempts,
)?;
tracing::info!(
attempt = attempt + 1,