diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-10-20 06:42:26 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-10-20 06:42:26 (GMT) |
commit | ce82eb2e13d909bb399b40822bc1aae777acb814 (patch) | |
tree | 488bd0ef27547aef50eb67828ac3f4a0f7f62d01 /Modules/audioop.c | |
parent | d49c47bfb0ea3bc2e7d8778d8002c0f628d97488 (diff) | |
download | cpython-ce82eb2e13d909bb399b40822bc1aae777acb814.zip cpython-ce82eb2e13d909bb399b40822bc1aae777acb814.tar.gz cpython-ce82eb2e13d909bb399b40822bc1aae777acb814.tar.bz2 |
Issue #12866: Fix bias() for 24-bit. Add more tests.
Diffstat (limited to 'Modules/audioop.c')
-rw-r--r-- | Modules/audioop.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/Modules/audioop.c b/Modules/audioop.c index 362dc06..5e1de1b 100644 --- a/Modules/audioop.c +++ b/Modules/audioop.c @@ -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; } |