From fedd46b25f2ae63504366c34d264f9503f97540a Mon Sep 17 00:00:00 2001 From: Dan Ellis Date: Fri, 29 Mar 2024 23:00:35 -0400 Subject: [PATCH] filters.c: Find max_val even when norm_bits is 0. --- src/filters.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/filters.c b/src/filters.c index b7d1229..e3a43f8 100644 --- a/src/filters.c +++ b/src/filters.c @@ -629,13 +629,15 @@ SAMPLE block_norm(SAMPLE* block, int len, int bits) { AMY_PROFILE_START(BLOCK_NORM) SAMPLE max_val = 0; - if (bits > 0) { + if (bits >= 0) { + // do this even if bits == 0 to ensure max_val is set. while(len--) { *block = SHIFTL(*block, bits); if (*block > max_val) max_val = *block; ++block; } - } else if (bits < 0) { + } else { + // bits is negative - right-shift. bits = -bits; while(len--) { *block = SHIFTR(*block, bits);