From 7a64d22411385e0464c2fd67b061147cc5c30a04 Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Thu, 9 Oct 2025 18:01:23 +0200 Subject: [PATCH] nihav_codec_support: use clamp() where appropriate --- nihav-codec-support/src/test/wavwriter.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/nihav-codec-support/src/test/wavwriter.rs b/nihav-codec-support/src/test/wavwriter.rs index c711dad..dad60e3 100644 --- a/nihav-codec-support/src/test/wavwriter.rs +++ b/nihav-codec-support/src/test/wavwriter.rs @@ -22,9 +22,7 @@ fn write_s32(wr: &mut dyn ByteIO, sample: i32) -> ByteIOResult<()> { } fn write_f32(wr: &mut dyn ByteIO, sample: f32) -> ByteIOResult<()> { - let mut out = (sample * 32768.0) as i32; - if out < -32768 { out = -32768; } - if out > 32767 { out = 32767; } + let mut out = ((sample * 32768.0) as i32).clamp(-32768, 32767); if out < 0 { out += 65536; } wr.write_u16le(out as u16) } -- 2.39.5