Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
9824e7f5
Kaydet (Commit)
9824e7f5
authored
May 03, 2010
tarafından
Brett Cannon
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Clean up whitespace and remove unneeded variable initialization as found by
Clang.
üst
99ac9147
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
56 deletions
+52
-56
audioop.c
Modules/audioop.c
+52
-56
No files found.
Modules/audioop.c
Dosyayı görüntüle @
9824e7f5
...
@@ -286,7 +286,7 @@ static int stepsizeTable[89] = {
...
@@ -286,7 +286,7 @@ static int stepsizeTable[89] = {
5894
,
6484
,
7132
,
7845
,
8630
,
9493
,
10442
,
11487
,
12635
,
13899
,
5894
,
6484
,
7132
,
7845
,
8630
,
9493
,
10442
,
11487
,
12635
,
13899
,
15289
,
16818
,
18500
,
20350
,
22385
,
24623
,
27086
,
29794
,
32767
15289
,
16818
,
18500
,
20350
,
22385
,
24623
,
27086
,
29794
,
32767
};
};
#define CHARP(cp, i) ((signed char *)(cp+i))
#define CHARP(cp, i) ((signed char *)(cp+i))
#define SHORTP(cp, i) ((short *)(cp+i))
#define SHORTP(cp, i) ((short *)(cp+i))
#define LONGP(cp, i) ((Py_Int32 *)(cp+i))
#define LONGP(cp, i) ((Py_Int32 *)(cp+i))
...
@@ -485,7 +485,7 @@ audioop_findfit(PyObject *self, PyObject *args)
...
@@ -485,7 +485,7 @@ audioop_findfit(PyObject *self, PyObject *args)
}
}
len1
>>=
1
;
len1
>>=
1
;
len2
>>=
1
;
len2
>>=
1
;
if
(
len1
<
len2
)
{
if
(
len1
<
len2
)
{
PyErr_SetString
(
AudioopError
,
"First sample should be longer"
);
PyErr_SetString
(
AudioopError
,
"First sample should be longer"
);
return
0
;
return
0
;
...
@@ -498,9 +498,8 @@ audioop_findfit(PyObject *self, PyObject *args)
...
@@ -498,9 +498,8 @@ audioop_findfit(PyObject *self, PyObject *args)
best_result
=
result
;
best_result
=
result
;
best_j
=
0
;
best_j
=
0
;
j
=
0
;
for
(
j
=
1
;
j
<=
len1
-
len2
;
j
++
)
{
for
(
j
=
1
;
j
<=
len1
-
len2
;
j
++
)
{
aj_m1
=
(
double
)
cp1
[
j
-
1
];
aj_m1
=
(
double
)
cp1
[
j
-
1
];
aj_lm1
=
(
double
)
cp1
[
j
+
len2
-
1
];
aj_lm1
=
(
double
)
cp1
[
j
+
len2
-
1
];
...
@@ -514,11 +513,11 @@ audioop_findfit(PyObject *self, PyObject *args)
...
@@ -514,11 +513,11 @@ audioop_findfit(PyObject *self, PyObject *args)
best_result
=
result
;
best_result
=
result
;
best_j
=
j
;
best_j
=
j
;
}
}
}
}
factor
=
_sum2
(
cp1
+
best_j
,
cp2
,
len2
)
/
sum_ri_2
;
factor
=
_sum2
(
cp1
+
best_j
,
cp2
,
len2
)
/
sum_ri_2
;
return
Py_BuildValue
(
"(if)"
,
best_j
,
factor
);
return
Py_BuildValue
(
"(if)"
,
best_j
,
factor
);
}
}
...
@@ -566,7 +565,7 @@ audioop_findmax(PyObject *self, PyObject *args)
...
@@ -566,7 +565,7 @@ audioop_findmax(PyObject *self, PyObject *args)
double
aj_m1
,
aj_lm1
;
double
aj_m1
,
aj_lm1
;
double
result
,
best_result
;
double
result
,
best_result
;
if
(
!
PyArg_ParseTuple
(
args
,
"s#i:findmax"
,
if
(
!
PyArg_ParseTuple
(
args
,
"s#i:findmax"
,
(
char
**
)
&
cp1
,
&
len1
,
&
len2
)
)
(
char
**
)
&
cp1
,
&
len1
,
&
len2
)
)
return
0
;
return
0
;
if
(
len1
&
1
)
{
if
(
len1
&
1
)
{
...
@@ -574,7 +573,7 @@ audioop_findmax(PyObject *self, PyObject *args)
...
@@ -574,7 +573,7 @@ audioop_findmax(PyObject *self, PyObject *args)
return
0
;
return
0
;
}
}
len1
>>=
1
;
len1
>>=
1
;
if
(
len2
<
0
||
len1
<
len2
)
{
if
(
len2
<
0
||
len1
<
len2
)
{
PyErr_SetString
(
AudioopError
,
"Input sample should be longer"
);
PyErr_SetString
(
AudioopError
,
"Input sample should be longer"
);
return
0
;
return
0
;
...
@@ -584,9 +583,8 @@ audioop_findmax(PyObject *self, PyObject *args)
...
@@ -584,9 +583,8 @@ audioop_findmax(PyObject *self, PyObject *args)
best_result
=
result
;
best_result
=
result
;
best_j
=
0
;
best_j
=
0
;
j
=
0
;
for
(
j
=
1
;
j
<=
len1
-
len2
;
j
++
)
{
for
(
j
=
1
;
j
<=
len1
-
len2
;
j
++
)
{
aj_m1
=
(
double
)
cp1
[
j
-
1
];
aj_m1
=
(
double
)
cp1
[
j
-
1
];
aj_lm1
=
(
double
)
cp1
[
j
+
len2
-
1
];
aj_lm1
=
(
double
)
cp1
[
j
+
len2
-
1
];
...
@@ -596,7 +594,7 @@ audioop_findmax(PyObject *self, PyObject *args)
...
@@ -596,7 +594,7 @@ audioop_findmax(PyObject *self, PyObject *args)
best_result
=
result
;
best_result
=
result
;
best_j
=
j
;
best_j
=
j
;
}
}
}
}
return
PyInt_FromLong
(
best_j
);
return
PyInt_FromLong
(
best_j
);
...
@@ -628,7 +626,7 @@ audioop_avgpp(PyObject *self, PyObject *args)
...
@@ -628,7 +626,7 @@ audioop_avgpp(PyObject *self, PyObject *args)
else
if
(
size
==
2
)
val
=
(
int
)
*
SHORTP
(
cp
,
size
);
else
if
(
size
==
2
)
val
=
(
int
)
*
SHORTP
(
cp
,
size
);
else
if
(
size
==
4
)
val
=
(
int
)
*
LONGP
(
cp
,
size
);
else
if
(
size
==
4
)
val
=
(
int
)
*
LONGP
(
cp
,
size
);
prevdiff
=
val
-
prevval
;
prevdiff
=
val
-
prevval
;
for
(
i
=
size
;
i
<
len
;
i
+=
size
)
{
for
(
i
=
size
;
i
<
len
;
i
+=
size
)
{
if
(
size
==
1
)
val
=
(
int
)
*
CHARP
(
cp
,
i
);
if
(
size
==
1
)
val
=
(
int
)
*
CHARP
(
cp
,
i
);
else
if
(
size
==
2
)
val
=
(
int
)
*
SHORTP
(
cp
,
i
);
else
if
(
size
==
2
)
val
=
(
int
)
*
SHORTP
(
cp
,
i
);
...
@@ -650,7 +648,7 @@ audioop_avgpp(PyObject *self, PyObject *args)
...
@@ -650,7 +648,7 @@ audioop_avgpp(PyObject *self, PyObject *args)
}
}
prevval
=
val
;
prevval
=
val
;
if
(
diff
!=
0
)
if
(
diff
!=
0
)
prevdiff
=
diff
;
prevdiff
=
diff
;
}
}
if
(
nextreme
==
0
)
if
(
nextreme
==
0
)
val
=
0
;
val
=
0
;
...
@@ -750,7 +748,7 @@ audioop_mul(PyObject *self, PyObject *args)
...
@@ -750,7 +748,7 @@ audioop_mul(PyObject *self, PyObject *args)
if
(
!
PyArg_ParseTuple
(
args
,
"s#id:mul"
,
&
cp
,
&
len
,
&
size
,
&
factor
)
)
if
(
!
PyArg_ParseTuple
(
args
,
"s#id:mul"
,
&
cp
,
&
len
,
&
size
,
&
factor
)
)
return
0
;
return
0
;
if
(
size
==
1
)
maxval
=
(
double
)
0x7f
;
if
(
size
==
1
)
maxval
=
(
double
)
0x7f
;
else
if
(
size
==
2
)
maxval
=
(
double
)
0x7fff
;
else
if
(
size
==
2
)
maxval
=
(
double
)
0x7fff
;
else
if
(
size
==
4
)
maxval
=
(
double
)
0x7fffffff
;
else
if
(
size
==
4
)
maxval
=
(
double
)
0x7fffffff
;
...
@@ -758,13 +756,13 @@ audioop_mul(PyObject *self, PyObject *args)
...
@@ -758,13 +756,13 @@ audioop_mul(PyObject *self, PyObject *args)
PyErr_SetString
(
AudioopError
,
"Size should be 1, 2 or 4"
);
PyErr_SetString
(
AudioopError
,
"Size should be 1, 2 or 4"
);
return
0
;
return
0
;
}
}
rv
=
PyString_FromStringAndSize
(
NULL
,
len
);
rv
=
PyString_FromStringAndSize
(
NULL
,
len
);
if
(
rv
==
0
)
if
(
rv
==
0
)
return
0
;
return
0
;
ncp
=
(
signed
char
*
)
PyString_AsString
(
rv
);
ncp
=
(
signed
char
*
)
PyString_AsString
(
rv
);
for
(
i
=
0
;
i
<
len
;
i
+=
size
)
{
for
(
i
=
0
;
i
<
len
;
i
+=
size
)
{
if
(
size
==
1
)
val
=
(
int
)
*
CHARP
(
cp
,
i
);
if
(
size
==
1
)
val
=
(
int
)
*
CHARP
(
cp
,
i
);
else
if
(
size
==
2
)
val
=
(
int
)
*
SHORTP
(
cp
,
i
);
else
if
(
size
==
2
)
val
=
(
int
)
*
SHORTP
(
cp
,
i
);
...
@@ -792,7 +790,7 @@ audioop_tomono(PyObject *self, PyObject *args)
...
@@ -792,7 +790,7 @@ audioop_tomono(PyObject *self, PyObject *args)
if
(
!
PyArg_ParseTuple
(
args
,
"s#idd:tomono"
,
if
(
!
PyArg_ParseTuple
(
args
,
"s#idd:tomono"
,
&
cp
,
&
len
,
&
size
,
&
fac1
,
&
fac2
)
)
&
cp
,
&
len
,
&
size
,
&
fac1
,
&
fac2
)
)
return
0
;
return
0
;
if
(
size
==
1
)
maxval
=
(
double
)
0x7f
;
if
(
size
==
1
)
maxval
=
(
double
)
0x7f
;
else
if
(
size
==
2
)
maxval
=
(
double
)
0x7fff
;
else
if
(
size
==
2
)
maxval
=
(
double
)
0x7fff
;
else
if
(
size
==
4
)
maxval
=
(
double
)
0x7fffffff
;
else
if
(
size
==
4
)
maxval
=
(
double
)
0x7fffffff
;
...
@@ -800,13 +798,13 @@ audioop_tomono(PyObject *self, PyObject *args)
...
@@ -800,13 +798,13 @@ audioop_tomono(PyObject *self, PyObject *args)
PyErr_SetString
(
AudioopError
,
"Size should be 1, 2 or 4"
);
PyErr_SetString
(
AudioopError
,
"Size should be 1, 2 or 4"
);
return
0
;
return
0
;
}
}
rv
=
PyString_FromStringAndSize
(
NULL
,
len
/
2
);
rv
=
PyString_FromStringAndSize
(
NULL
,
len
/
2
);
if
(
rv
==
0
)
if
(
rv
==
0
)
return
0
;
return
0
;
ncp
=
(
signed
char
*
)
PyString_AsString
(
rv
);
ncp
=
(
signed
char
*
)
PyString_AsString
(
rv
);
for
(
i
=
0
;
i
<
len
;
i
+=
size
*
2
)
{
for
(
i
=
0
;
i
<
len
;
i
+=
size
*
2
)
{
if
(
size
==
1
)
val1
=
(
int
)
*
CHARP
(
cp
,
i
);
if
(
size
==
1
)
val1
=
(
int
)
*
CHARP
(
cp
,
i
);
else
if
(
size
==
2
)
val1
=
(
int
)
*
SHORTP
(
cp
,
i
);
else
if
(
size
==
2
)
val1
=
(
int
)
*
SHORTP
(
cp
,
i
);
...
@@ -837,7 +835,7 @@ audioop_tostereo(PyObject *self, PyObject *args)
...
@@ -837,7 +835,7 @@ audioop_tostereo(PyObject *self, PyObject *args)
if
(
!
PyArg_ParseTuple
(
args
,
"s#idd:tostereo"
,
if
(
!
PyArg_ParseTuple
(
args
,
"s#idd:tostereo"
,
&
cp
,
&
len
,
&
size
,
&
fac1
,
&
fac2
)
)
&
cp
,
&
len
,
&
size
,
&
fac1
,
&
fac2
)
)
return
0
;
return
0
;
if
(
size
==
1
)
maxval
=
(
double
)
0x7f
;
if
(
size
==
1
)
maxval
=
(
double
)
0x7f
;
else
if
(
size
==
2
)
maxval
=
(
double
)
0x7fff
;
else
if
(
size
==
2
)
maxval
=
(
double
)
0x7fff
;
else
if
(
size
==
4
)
maxval
=
(
double
)
0x7fffffff
;
else
if
(
size
==
4
)
maxval
=
(
double
)
0x7fffffff
;
...
@@ -845,7 +843,7 @@ audioop_tostereo(PyObject *self, PyObject *args)
...
@@ -845,7 +843,7 @@ audioop_tostereo(PyObject *self, PyObject *args)
PyErr_SetString
(
AudioopError
,
"Size should be 1, 2 or 4"
);
PyErr_SetString
(
AudioopError
,
"Size should be 1, 2 or 4"
);
return
0
;
return
0
;
}
}
new_len
=
len
*
2
;
new_len
=
len
*
2
;
if
(
new_len
<
0
)
{
if
(
new_len
<
0
)
{
PyErr_SetString
(
PyExc_MemoryError
,
PyErr_SetString
(
PyExc_MemoryError
,
...
@@ -857,8 +855,8 @@ audioop_tostereo(PyObject *self, PyObject *args)
...
@@ -857,8 +855,8 @@ audioop_tostereo(PyObject *self, PyObject *args)
if
(
rv
==
0
)
if
(
rv
==
0
)
return
0
;
return
0
;
ncp
=
(
signed
char
*
)
PyString_AsString
(
rv
);
ncp
=
(
signed
char
*
)
PyString_AsString
(
rv
);
for
(
i
=
0
;
i
<
len
;
i
+=
size
)
{
for
(
i
=
0
;
i
<
len
;
i
+=
size
)
{
if
(
size
==
1
)
val
=
(
int
)
*
CHARP
(
cp
,
i
);
if
(
size
==
1
)
val
=
(
int
)
*
CHARP
(
cp
,
i
);
else
if
(
size
==
2
)
val
=
(
int
)
*
SHORTP
(
cp
,
i
);
else
if
(
size
==
2
)
val
=
(
int
)
*
SHORTP
(
cp
,
i
);
...
@@ -901,7 +899,7 @@ audioop_add(PyObject *self, PyObject *args)
...
@@ -901,7 +899,7 @@ audioop_add(PyObject *self, PyObject *args)
PyErr_SetString
(
AudioopError
,
"Lengths should be the same"
);
PyErr_SetString
(
AudioopError
,
"Lengths should be the same"
);
return
0
;
return
0
;
}
}
if
(
size
==
1
)
maxval
=
0x7f
;
if
(
size
==
1
)
maxval
=
0x7f
;
else
if
(
size
==
2
)
maxval
=
0x7fff
;
else
if
(
size
==
2
)
maxval
=
0x7fff
;
else
if
(
size
==
4
)
maxval
=
0x7fffffff
;
else
if
(
size
==
4
)
maxval
=
0x7fffffff
;
...
@@ -919,7 +917,7 @@ audioop_add(PyObject *self, PyObject *args)
...
@@ -919,7 +917,7 @@ audioop_add(PyObject *self, PyObject *args)
if
(
size
==
1
)
val1
=
(
int
)
*
CHARP
(
cp1
,
i
);
if
(
size
==
1
)
val1
=
(
int
)
*
CHARP
(
cp1
,
i
);
else
if
(
size
==
2
)
val1
=
(
int
)
*
SHORTP
(
cp1
,
i
);
else
if
(
size
==
2
)
val1
=
(
int
)
*
SHORTP
(
cp1
,
i
);
else
if
(
size
==
4
)
val1
=
(
int
)
*
LONGP
(
cp1
,
i
);
else
if
(
size
==
4
)
val1
=
(
int
)
*
LONGP
(
cp1
,
i
);
if
(
size
==
1
)
val2
=
(
int
)
*
CHARP
(
cp2
,
i
);
if
(
size
==
1
)
val2
=
(
int
)
*
CHARP
(
cp2
,
i
);
else
if
(
size
==
2
)
val2
=
(
int
)
*
SHORTP
(
cp2
,
i
);
else
if
(
size
==
2
)
val2
=
(
int
)
*
SHORTP
(
cp2
,
i
);
else
if
(
size
==
4
)
val2
=
(
int
)
*
LONGP
(
cp2
,
i
);
else
if
(
size
==
4
)
val2
=
(
int
)
*
LONGP
(
cp2
,
i
);
...
@@ -955,18 +953,18 @@ audioop_bias(PyObject *self, PyObject *args)
...
@@ -955,18 +953,18 @@ audioop_bias(PyObject *self, PyObject *args)
PyErr_SetString
(
AudioopError
,
"Size should be 1, 2 or 4"
);
PyErr_SetString
(
AudioopError
,
"Size should be 1, 2 or 4"
);
return
0
;
return
0
;
}
}
rv
=
PyString_FromStringAndSize
(
NULL
,
len
);
rv
=
PyString_FromStringAndSize
(
NULL
,
len
);
if
(
rv
==
0
)
if
(
rv
==
0
)
return
0
;
return
0
;
ncp
=
(
signed
char
*
)
PyString_AsString
(
rv
);
ncp
=
(
signed
char
*
)
PyString_AsString
(
rv
);
for
(
i
=
0
;
i
<
len
;
i
+=
size
)
{
for
(
i
=
0
;
i
<
len
;
i
+=
size
)
{
if
(
size
==
1
)
val
=
(
int
)
*
CHARP
(
cp
,
i
);
if
(
size
==
1
)
val
=
(
int
)
*
CHARP
(
cp
,
i
);
else
if
(
size
==
2
)
val
=
(
int
)
*
SHORTP
(
cp
,
i
);
else
if
(
size
==
2
)
val
=
(
int
)
*
SHORTP
(
cp
,
i
);
else
if
(
size
==
4
)
val
=
(
int
)
*
LONGP
(
cp
,
i
);
else
if
(
size
==
4
)
val
=
(
int
)
*
LONGP
(
cp
,
i
);
if
(
size
==
1
)
*
CHARP
(
ncp
,
i
)
=
(
signed
char
)(
val
+
bias
);
if
(
size
==
1
)
*
CHARP
(
ncp
,
i
)
=
(
signed
char
)(
val
+
bias
);
else
if
(
size
==
2
)
*
SHORTP
(
ncp
,
i
)
=
(
short
)(
val
+
bias
);
else
if
(
size
==
2
)
*
SHORTP
(
ncp
,
i
)
=
(
short
)(
val
+
bias
);
else
if
(
size
==
4
)
*
LONGP
(
ncp
,
i
)
=
(
Py_Int32
)(
val
+
bias
);
else
if
(
size
==
4
)
*
LONGP
(
ncp
,
i
)
=
(
Py_Int32
)(
val
+
bias
);
...
@@ -991,19 +989,19 @@ audioop_reverse(PyObject *self, PyObject *args)
...
@@ -991,19 +989,19 @@ audioop_reverse(PyObject *self, PyObject *args)
PyErr_SetString
(
AudioopError
,
"Size should be 1, 2 or 4"
);
PyErr_SetString
(
AudioopError
,
"Size should be 1, 2 or 4"
);
return
0
;
return
0
;
}
}
rv
=
PyString_FromStringAndSize
(
NULL
,
len
);
rv
=
PyString_FromStringAndSize
(
NULL
,
len
);
if
(
rv
==
0
)
if
(
rv
==
0
)
return
0
;
return
0
;
ncp
=
(
unsigned
char
*
)
PyString_AsString
(
rv
);
ncp
=
(
unsigned
char
*
)
PyString_AsString
(
rv
);
for
(
i
=
0
;
i
<
len
;
i
+=
size
)
{
for
(
i
=
0
;
i
<
len
;
i
+=
size
)
{
if
(
size
==
1
)
val
=
((
int
)
*
CHARP
(
cp
,
i
))
<<
8
;
if
(
size
==
1
)
val
=
((
int
)
*
CHARP
(
cp
,
i
))
<<
8
;
else
if
(
size
==
2
)
val
=
(
int
)
*
SHORTP
(
cp
,
i
);
else
if
(
size
==
2
)
val
=
(
int
)
*
SHORTP
(
cp
,
i
);
else
if
(
size
==
4
)
val
=
((
int
)
*
LONGP
(
cp
,
i
))
>>
16
;
else
if
(
size
==
4
)
val
=
((
int
)
*
LONGP
(
cp
,
i
))
>>
16
;
j
=
len
-
i
-
size
;
j
=
len
-
i
-
size
;
if
(
size
==
1
)
*
CHARP
(
ncp
,
j
)
=
(
signed
char
)(
val
>>
8
);
if
(
size
==
1
)
*
CHARP
(
ncp
,
j
)
=
(
signed
char
)(
val
>>
8
);
else
if
(
size
==
2
)
*
SHORTP
(
ncp
,
j
)
=
(
short
)(
val
);
else
if
(
size
==
2
)
*
SHORTP
(
ncp
,
j
)
=
(
short
)(
val
);
else
if
(
size
==
4
)
*
LONGP
(
ncp
,
j
)
=
(
Py_Int32
)(
val
<<
16
);
else
if
(
size
==
4
)
*
LONGP
(
ncp
,
j
)
=
(
Py_Int32
)(
val
<<
16
);
...
@@ -1029,7 +1027,7 @@ audioop_lin2lin(PyObject *self, PyObject *args)
...
@@ -1029,7 +1027,7 @@ audioop_lin2lin(PyObject *self, PyObject *args)
PyErr_SetString
(
AudioopError
,
"Size should be 1, 2 or 4"
);
PyErr_SetString
(
AudioopError
,
"Size should be 1, 2 or 4"
);
return
0
;
return
0
;
}
}
new_len
=
(
len
/
size
)
*
size2
;
new_len
=
(
len
/
size
)
*
size2
;
if
(
new_len
<
0
)
{
if
(
new_len
<
0
)
{
PyErr_SetString
(
PyExc_MemoryError
,
PyErr_SetString
(
PyExc_MemoryError
,
...
@@ -1040,7 +1038,7 @@ audioop_lin2lin(PyObject *self, PyObject *args)
...
@@ -1040,7 +1038,7 @@ audioop_lin2lin(PyObject *self, PyObject *args)
if
(
rv
==
0
)
if
(
rv
==
0
)
return
0
;
return
0
;
ncp
=
(
unsigned
char
*
)
PyString_AsString
(
rv
);
ncp
=
(
unsigned
char
*
)
PyString_AsString
(
rv
);
for
(
i
=
0
,
j
=
0
;
i
<
len
;
i
+=
size
,
j
+=
size2
)
{
for
(
i
=
0
,
j
=
0
;
i
<
len
;
i
+=
size
,
j
+=
size2
)
{
if
(
size
==
1
)
val
=
((
int
)
*
CHARP
(
cp
,
i
))
<<
8
;
if
(
size
==
1
)
val
=
((
int
)
*
CHARP
(
cp
,
i
))
<<
8
;
else
if
(
size
==
2
)
val
=
(
int
)
*
SHORTP
(
cp
,
i
);
else
if
(
size
==
2
)
val
=
(
int
)
*
SHORTP
(
cp
,
i
);
...
@@ -1147,7 +1145,7 @@ audioop_ratecv(PyObject *self, PyObject *args)
...
@@ -1147,7 +1145,7 @@ audioop_ratecv(PyObject *self, PyObject *args)
}
}
for
(
chan
=
0
;
chan
<
nchannels
;
chan
++
)
{
for
(
chan
=
0
;
chan
<
nchannels
;
chan
++
)
{
if
(
!
PyArg_ParseTuple
(
PyTuple_GetItem
(
samps
,
chan
),
if
(
!
PyArg_ParseTuple
(
PyTuple_GetItem
(
samps
,
chan
),
"ii:ratecv"
,
&
prev_i
[
chan
],
"ii:ratecv"
,
&
prev_i
[
chan
],
&
cur_i
[
chan
]))
&
cur_i
[
chan
]))
goto
exit
;
goto
exit
;
}
}
...
@@ -1274,12 +1272,12 @@ audioop_lin2ulaw(PyObject *self, PyObject *args)
...
@@ -1274,12 +1272,12 @@ audioop_lin2ulaw(PyObject *self, PyObject *args)
PyErr_SetString
(
AudioopError
,
"Size should be 1, 2 or 4"
);
PyErr_SetString
(
AudioopError
,
"Size should be 1, 2 or 4"
);
return
0
;
return
0
;
}
}
rv
=
PyString_FromStringAndSize
(
NULL
,
len
/
size
);
rv
=
PyString_FromStringAndSize
(
NULL
,
len
/
size
);
if
(
rv
==
0
)
if
(
rv
==
0
)
return
0
;
return
0
;
ncp
=
(
unsigned
char
*
)
PyString_AsString
(
rv
);
ncp
=
(
unsigned
char
*
)
PyString_AsString
(
rv
);
for
(
i
=
0
;
i
<
len
;
i
+=
size
)
{
for
(
i
=
0
;
i
<
len
;
i
+=
size
)
{
if
(
size
==
1
)
val
=
((
int
)
*
CHARP
(
cp
,
i
))
<<
8
;
if
(
size
==
1
)
val
=
((
int
)
*
CHARP
(
cp
,
i
))
<<
8
;
else
if
(
size
==
2
)
val
=
(
int
)
*
SHORTP
(
cp
,
i
);
else
if
(
size
==
2
)
val
=
(
int
)
*
SHORTP
(
cp
,
i
);
...
@@ -1308,7 +1306,7 @@ audioop_ulaw2lin(PyObject *self, PyObject *args)
...
@@ -1308,7 +1306,7 @@ audioop_ulaw2lin(PyObject *self, PyObject *args)
PyErr_SetString
(
AudioopError
,
"Size should be 1, 2 or 4"
);
PyErr_SetString
(
AudioopError
,
"Size should be 1, 2 or 4"
);
return
0
;
return
0
;
}
}
new_len
=
len
*
size
;
new_len
=
len
*
size
;
if
(
new_len
<
0
)
{
if
(
new_len
<
0
)
{
PyErr_SetString
(
PyExc_MemoryError
,
PyErr_SetString
(
PyExc_MemoryError
,
...
@@ -1319,11 +1317,11 @@ audioop_ulaw2lin(PyObject *self, PyObject *args)
...
@@ -1319,11 +1317,11 @@ audioop_ulaw2lin(PyObject *self, PyObject *args)
if
(
rv
==
0
)
if
(
rv
==
0
)
return
0
;
return
0
;
ncp
=
(
signed
char
*
)
PyString_AsString
(
rv
);
ncp
=
(
signed
char
*
)
PyString_AsString
(
rv
);
for
(
i
=
0
;
i
<
new_len
;
i
+=
size
)
{
for
(
i
=
0
;
i
<
new_len
;
i
+=
size
)
{
cval
=
*
cp
++
;
cval
=
*
cp
++
;
val
=
st_ulaw2linear16
(
cval
);
val
=
st_ulaw2linear16
(
cval
);
if
(
size
==
1
)
*
CHARP
(
ncp
,
i
)
=
(
signed
char
)(
val
>>
8
);
if
(
size
==
1
)
*
CHARP
(
ncp
,
i
)
=
(
signed
char
)(
val
>>
8
);
else
if
(
size
==
2
)
*
SHORTP
(
ncp
,
i
)
=
(
short
)(
val
);
else
if
(
size
==
2
)
*
SHORTP
(
ncp
,
i
)
=
(
short
)(
val
);
else
if
(
size
==
4
)
*
LONGP
(
ncp
,
i
)
=
(
Py_Int32
)(
val
<<
16
);
else
if
(
size
==
4
)
*
LONGP
(
ncp
,
i
)
=
(
Py_Int32
)(
val
<<
16
);
...
@@ -1348,12 +1346,12 @@ audioop_lin2alaw(PyObject *self, PyObject *args)
...
@@ -1348,12 +1346,12 @@ audioop_lin2alaw(PyObject *self, PyObject *args)
PyErr_SetString
(
AudioopError
,
"Size should be 1, 2 or 4"
);
PyErr_SetString
(
AudioopError
,
"Size should be 1, 2 or 4"
);
return
0
;
return
0
;
}
}
rv
=
PyString_FromStringAndSize
(
NULL
,
len
/
size
);
rv
=
PyString_FromStringAndSize
(
NULL
,
len
/
size
);
if
(
rv
==
0
)
if
(
rv
==
0
)
return
0
;
return
0
;
ncp
=
(
unsigned
char
*
)
PyString_AsString
(
rv
);
ncp
=
(
unsigned
char
*
)
PyString_AsString
(
rv
);
for
(
i
=
0
;
i
<
len
;
i
+=
size
)
{
for
(
i
=
0
;
i
<
len
;
i
+=
size
)
{
if
(
size
==
1
)
val
=
((
int
)
*
CHARP
(
cp
,
i
))
<<
8
;
if
(
size
==
1
)
val
=
((
int
)
*
CHARP
(
cp
,
i
))
<<
8
;
else
if
(
size
==
2
)
val
=
(
int
)
*
SHORTP
(
cp
,
i
);
else
if
(
size
==
2
)
val
=
(
int
)
*
SHORTP
(
cp
,
i
);
...
@@ -1382,7 +1380,7 @@ audioop_alaw2lin(PyObject *self, PyObject *args)
...
@@ -1382,7 +1380,7 @@ audioop_alaw2lin(PyObject *self, PyObject *args)
PyErr_SetString
(
AudioopError
,
"Size should be 1, 2 or 4"
);
PyErr_SetString
(
AudioopError
,
"Size should be 1, 2 or 4"
);
return
0
;
return
0
;
}
}
new_len
=
len
*
size
;
new_len
=
len
*
size
;
if
(
new_len
<
0
)
{
if
(
new_len
<
0
)
{
PyErr_SetString
(
PyExc_MemoryError
,
PyErr_SetString
(
PyExc_MemoryError
,
...
@@ -1393,11 +1391,11 @@ audioop_alaw2lin(PyObject *self, PyObject *args)
...
@@ -1393,11 +1391,11 @@ audioop_alaw2lin(PyObject *self, PyObject *args)
if
(
rv
==
0
)
if
(
rv
==
0
)
return
0
;
return
0
;
ncp
=
(
signed
char
*
)
PyString_AsString
(
rv
);
ncp
=
(
signed
char
*
)
PyString_AsString
(
rv
);
for
(
i
=
0
;
i
<
new_len
;
i
+=
size
)
{
for
(
i
=
0
;
i
<
new_len
;
i
+=
size
)
{
cval
=
*
cp
++
;
cval
=
*
cp
++
;
val
=
st_alaw2linear16
(
cval
);
val
=
st_alaw2linear16
(
cval
);
if
(
size
==
1
)
*
CHARP
(
ncp
,
i
)
=
(
signed
char
)(
val
>>
8
);
if
(
size
==
1
)
*
CHARP
(
ncp
,
i
)
=
(
signed
char
)(
val
>>
8
);
else
if
(
size
==
2
)
*
SHORTP
(
ncp
,
i
)
=
(
short
)(
val
);
else
if
(
size
==
2
)
*
SHORTP
(
ncp
,
i
)
=
(
short
)(
val
);
else
if
(
size
==
4
)
*
LONGP
(
ncp
,
i
)
=
(
Py_Int32
)(
val
<<
16
);
else
if
(
size
==
4
)
*
LONGP
(
ncp
,
i
)
=
(
Py_Int32
)(
val
<<
16
);
...
@@ -1418,13 +1416,13 @@ audioop_lin2adpcm(PyObject *self, PyObject *args)
...
@@ -1418,13 +1416,13 @@ audioop_lin2adpcm(PyObject *self, PyObject *args)
if
(
!
PyArg_ParseTuple
(
args
,
"s#iO:lin2adpcm"
,
if
(
!
PyArg_ParseTuple
(
args
,
"s#iO:lin2adpcm"
,
&
cp
,
&
len
,
&
size
,
&
state
)
)
&
cp
,
&
len
,
&
size
,
&
state
)
)
return
0
;
return
0
;
if
(
size
!=
1
&&
size
!=
2
&&
size
!=
4
)
{
if
(
size
!=
1
&&
size
!=
2
&&
size
!=
4
)
{
PyErr_SetString
(
AudioopError
,
"Size should be 1, 2 or 4"
);
PyErr_SetString
(
AudioopError
,
"Size should be 1, 2 or 4"
);
return
0
;
return
0
;
}
}
str
=
PyString_FromStringAndSize
(
NULL
,
len
/
(
size
*
2
));
str
=
PyString_FromStringAndSize
(
NULL
,
len
/
(
size
*
2
));
if
(
str
==
0
)
if
(
str
==
0
)
return
0
;
return
0
;
...
@@ -1434,7 +1432,6 @@ audioop_lin2adpcm(PyObject *self, PyObject *args)
...
@@ -1434,7 +1432,6 @@ audioop_lin2adpcm(PyObject *self, PyObject *args)
if
(
state
==
Py_None
)
{
if
(
state
==
Py_None
)
{
/* First time, it seems. Set defaults */
/* First time, it seems. Set defaults */
valpred
=
0
;
valpred
=
0
;
step
=
7
;
index
=
0
;
index
=
0
;
}
else
if
(
!
PyArg_ParseTuple
(
state
,
"ii"
,
&
valpred
,
&
index
)
)
}
else
if
(
!
PyArg_ParseTuple
(
state
,
"ii"
,
&
valpred
,
&
index
)
)
return
0
;
return
0
;
...
@@ -1463,7 +1460,7 @@ audioop_lin2adpcm(PyObject *self, PyObject *args)
...
@@ -1463,7 +1460,7 @@ audioop_lin2adpcm(PyObject *self, PyObject *args)
*/
*/
delta
=
0
;
delta
=
0
;
vpdiff
=
(
step
>>
3
);
vpdiff
=
(
step
>>
3
);
if
(
diff
>=
step
)
{
if
(
diff
>=
step
)
{
delta
=
4
;
delta
=
4
;
diff
-=
step
;
diff
-=
step
;
...
@@ -1495,7 +1492,7 @@ audioop_lin2adpcm(PyObject *self, PyObject *args)
...
@@ -1495,7 +1492,7 @@ audioop_lin2adpcm(PyObject *self, PyObject *args)
/* Step 5 - Assemble value, update index and step values */
/* Step 5 - Assemble value, update index and step values */
delta
|=
sign
;
delta
|=
sign
;
index
+=
indexTable
[
delta
];
index
+=
indexTable
[
delta
];
if
(
index
<
0
)
index
=
0
;
if
(
index
<
0
)
index
=
0
;
if
(
index
>
88
)
index
=
88
;
if
(
index
>
88
)
index
=
88
;
...
@@ -1531,16 +1528,15 @@ audioop_adpcm2lin(PyObject *self, PyObject *args)
...
@@ -1531,16 +1528,15 @@ audioop_adpcm2lin(PyObject *self, PyObject *args)
PyErr_SetString
(
AudioopError
,
"Size should be 1, 2 or 4"
);
PyErr_SetString
(
AudioopError
,
"Size should be 1, 2 or 4"
);
return
0
;
return
0
;
}
}
/* Decode state, should have (value, step) */
/* Decode state, should have (value, step) */
if
(
state
==
Py_None
)
{
if
(
state
==
Py_None
)
{
/* First time, it seems. Set defaults */
/* First time, it seems. Set defaults */
valpred
=
0
;
valpred
=
0
;
step
=
7
;
index
=
0
;
index
=
0
;
}
else
if
(
!
PyArg_ParseTuple
(
state
,
"ii"
,
&
valpred
,
&
index
)
)
}
else
if
(
!
PyArg_ParseTuple
(
state
,
"ii"
,
&
valpred
,
&
index
)
)
return
0
;
return
0
;
new_len
=
len
*
size
*
2
;
new_len
=
len
*
size
*
2
;
if
(
new_len
<
0
)
{
if
(
new_len
<
0
)
{
PyErr_SetString
(
PyExc_MemoryError
,
PyErr_SetString
(
PyExc_MemoryError
,
...
@@ -1554,7 +1550,7 @@ audioop_adpcm2lin(PyObject *self, PyObject *args)
...
@@ -1554,7 +1550,7 @@ audioop_adpcm2lin(PyObject *self, PyObject *args)
step
=
stepsizeTable
[
index
];
step
=
stepsizeTable
[
index
];
bufferstep
=
0
;
bufferstep
=
0
;
for
(
i
=
0
;
i
<
new_len
;
i
+=
size
)
{
for
(
i
=
0
;
i
<
new_len
;
i
+=
size
)
{
/* Step 1 - get the delta value and compute next index */
/* Step 1 - get the delta value and compute next index */
if
(
bufferstep
)
{
if
(
bufferstep
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment