From: Kostya Shishkov Date: Thu, 9 Oct 2025 16:01:23 +0000 (+0200) Subject: nihav_codec_support: use clamp() where appropriate X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;h=7a64d22411385e0464c2fd67b061147cc5c30a04;p=nihav.git nihav_codec_support: use clamp() where appropriate --- 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) }