Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8be1740

Browse files
Use uint16_t instead of short in audioop.
1 parent 5f1a518 commit 8be1740

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

Modules/audioop.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ static unsigned char
240240
st_linear2alaw(int16_t pcm_val) /* 2's complement (13-bit range) */
241241
{
242242
int16_t mask;
243-
short seg;
243+
int16_t seg;
244244
unsigned char aval;
245245

246246
/* A-law using even bit inversion */
@@ -294,7 +294,7 @@ static const int stepsizeTable[89] = {
294294

295295

296296
#define GETINT8(cp, i) GETINTX(signed char, (cp), (i))
297-
#define GETINT16(cp, i) GETINTX(short, (cp), (i))
297+
#define GETINT16(cp, i) GETINTX(int16_t, (cp), (i))
298298
#define GETINT32(cp, i) GETINTX(int32_t, (cp), (i))
299299

300300
#if WORDS_BIGENDIAN
@@ -311,7 +311,7 @@ static const int stepsizeTable[89] = {
311311

312312

313313
#define SETINT8(cp, i, val) SETINTX(signed char, (cp), (i), (val))
314-
#define SETINT16(cp, i, val) SETINTX(short, (cp), (i), (val))
314+
#define SETINT16(cp, i, val) SETINTX(int16_t, (cp), (i), (val))
315315
#define SETINT32(cp, i, val) SETINTX(int32_t, (cp), (i), (val))
316316

317317
#if WORDS_BIGENDIAN
@@ -542,7 +542,7 @@ audioop_rms_impl(PyObject *module, Py_buffer *fragment, int width)
542542
return PyLong_FromUnsignedLong(res);
543543
}
544544

545-
static double _sum2(const short *a, const short *b, Py_ssize_t len)
545+
static double _sum2(const int16_t *a, const int16_t *b, Py_ssize_t len)
546546
{
547547
Py_ssize_t i;
548548
double sum = 0.0;
@@ -600,7 +600,7 @@ audioop_findfit_impl(PyObject *module, Py_buffer *fragment,
600600
Py_buffer *reference)
601601
/*[clinic end generated code: output=5752306d83cbbada input=62c305605e183c9a]*/
602602
{
603-
const short *cp1, *cp2;
603+
const int16_t *cp1, *cp2;
604604
Py_ssize_t len1, len2;
605605
Py_ssize_t j, best_j;
606606
double aj_m1, aj_lm1;
@@ -610,9 +610,9 @@ audioop_findfit_impl(PyObject *module, Py_buffer *fragment,
610610
PyErr_SetString(AudioopError, "Strings should be even-sized");
611611
return NULL;
612612
}
613-
cp1 = (const short *)fragment->buf;
613+
cp1 = (const int16_t *)fragment->buf;
614614
len1 = fragment->len >> 1;
615-
cp2 = (const short *)reference->buf;
615+
cp2 = (const int16_t *)reference->buf;
616616
len2 = reference->len >> 1;
617617

618618
if (len1 < len2) {
@@ -669,7 +669,7 @@ audioop_findfactor_impl(PyObject *module, Py_buffer *fragment,
669669
Py_buffer *reference)
670670
/*[clinic end generated code: output=14ea95652c1afcf8 input=816680301d012b21]*/
671671
{
672-
const short *cp1, *cp2;
672+
const int16_t *cp1, *cp2;
673673
Py_ssize_t len;
674674
double sum_ri_2, sum_aij_ri, result;
675675

@@ -681,8 +681,8 @@ audioop_findfactor_impl(PyObject *module, Py_buffer *fragment,
681681
PyErr_SetString(AudioopError, "Samples should be same size");
682682
return NULL;
683683
}
684-
cp1 = (const short *)fragment->buf;
685-
cp2 = (const short *)reference->buf;
684+
cp1 = (const int16_t *)fragment->buf;
685+
cp2 = (const int16_t *)reference->buf;
686686
len = fragment->len >> 1;
687687
sum_ri_2 = _sum2(cp2, cp2, len);
688688
sum_aij_ri = _sum2(cp1, cp2, len);
@@ -711,7 +711,7 @@ audioop_findmax_impl(PyObject *module, Py_buffer *fragment,
711711
Py_ssize_t length)
712712
/*[clinic end generated code: output=f008128233523040 input=2f304801ed42383c]*/
713713
{
714-
const short *cp1;
714+
const int16_t *cp1;
715715
Py_ssize_t len1;
716716
Py_ssize_t j, best_j;
717717
double aj_m1, aj_lm1;
@@ -721,7 +721,7 @@ audioop_findmax_impl(PyObject *module, Py_buffer *fragment,
721721
PyErr_SetString(AudioopError, "Strings should be even-sized");
722722
return NULL;
723723
}
724-
cp1 = (const short *)fragment->buf;
724+
cp1 = (const int16_t *)fragment->buf;
725725
len1 = fragment->len >> 1;
726726

727727
if (length < 0 || len1 < length) {
@@ -1122,7 +1122,7 @@ audioop_bias_impl(PyObject *module, Py_buffer *fragment, int width, int bias)
11221122
if (width == 1)
11231123
val = GETINTX(unsigned char, fragment->buf, i);
11241124
else if (width == 2)
1125-
val = GETINTX(unsigned short, fragment->buf, i);
1125+
val = GETINTX(uint16_t, fragment->buf, i);
11261126
else if (width == 3)
11271127
val = ((unsigned int)GETINT24(fragment->buf, i)) & 0xffffffu;
11281128
else {
@@ -1137,7 +1137,7 @@ audioop_bias_impl(PyObject *module, Py_buffer *fragment, int width, int bias)
11371137
if (width == 1)
11381138
SETINTX(unsigned char, ncp, i, val);
11391139
else if (width == 2)
1140-
SETINTX(unsigned short, ncp, i, val);
1140+
SETINTX(uint16_t, ncp, i, val);
11411141
else if (width == 3)
11421142
SETINT24(ncp, i, (int)val);
11431143
else {

0 commit comments

Comments
 (0)