Add PSHR32_ovflw() and use it in IMDCT
Prevents integer overflow UB in the shift rounding when the signal blows up on bad bitstreams (if it triggers, the signal was already unusable anyway).
This commit is contained in:
parent
fba923d83a
commit
edffe56b30
4 changed files with 10 additions and 4 deletions
|
@ -69,6 +69,8 @@ extern opus_int64 celt_mips;
|
|||
/* Avoid MSVC warning C4146: unary minus operator applied to unsigned type */
|
||||
/** Negate 32-bit value, ignore any overflows */
|
||||
#define NEG32_ovflw(a) (celt_mips+=2,(opus_val32)(0-(opus_uint32)(a)))
|
||||
/** 32-bit arithmetic shift right with rounding-to-nearest, ignoring overflows */
|
||||
#define PSHR32_ovflw(a,shift) (SHR32(ADD32_ovflw(a, (EXTEND32(1)<<(shift)>>1)),shift))
|
||||
|
||||
static OPUS_INLINE short NEG16(int x)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue