Skip to content

Commit

Permalink
sdsp: Check for invalid scale in defined way.
Browse files Browse the repository at this point in the history
  • Loading branch information
bearoso committed Apr 30, 2023
1 parent bc98b1d commit cbc14ee
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions apu/bapu/dsp/SPC_DSP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -672,9 +672,10 @@ inline void SPC_DSP::decode_brr( voice_t* v )

// Shift sample based on header
int const shift = header >> 4;
s = (s << shift) >> 1;
if ( shift >= 0xD ) // handle invalid range
s = (s >> 25) << 11; // same as: s = (s < 0 ? -0x800 : 0)
if (shift <= 12)
s = (s << shift) >> 1;
else
s &= 0x7ff;

// Apply IIR filter (8 is the most commonly used)
int const filter = header & 0x0C;
Expand Down

0 comments on commit cbc14ee

Please sign in to comment.