Skip to content

Commit

Permalink
filters.c: Find max_val even when norm_bits is 0.
Browse files Browse the repository at this point in the history
  • Loading branch information
dpwe authored Mar 30, 2024
1 parent 2894bf6 commit fedd46b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/filters.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit fedd46b

Please sign in to comment.