mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
Issue #12866: Fix bias() for 24-bit. Add more tests.
This commit is contained in:
parent
d49c47bfb0
commit
ce82eb2e13
2 changed files with 44 additions and 4 deletions
|
|
@ -985,10 +985,12 @@ audioop_bias(PyObject *self, PyObject *args)
|
|||
val = GETINTX(unsigned char, cp, i);
|
||||
else if (size == 2)
|
||||
val = GETINTX(unsigned short, cp, i);
|
||||
else if (size == 2)
|
||||
else if (size == 3)
|
||||
val = ((unsigned int)GETINT24(cp, i)) & 0xffffffu;
|
||||
else
|
||||
else {
|
||||
assert(size == 4);
|
||||
val = GETINTX(PY_UINT32_T, cp, i);
|
||||
}
|
||||
|
||||
val += (unsigned int)bias;
|
||||
/* wrap around in case of overflow */
|
||||
|
|
@ -998,10 +1000,12 @@ audioop_bias(PyObject *self, PyObject *args)
|
|||
SETINTX(unsigned char, ncp, i, val);
|
||||
else if (size == 2)
|
||||
SETINTX(unsigned short, ncp, i, val);
|
||||
else if (size == 2)
|
||||
else if (size == 3)
|
||||
SETINT24(ncp, i, (int)val);
|
||||
else
|
||||
else {
|
||||
assert(size == 4);
|
||||
SETINTX(PY_UINT32_T, ncp, i, val);
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue