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
8e7a0f02
Kaydet (Commit)
8e7a0f02
authored
Haz 23, 1992
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Added adpcm2lin and lin2adpcm.
üst
9d479927
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
135 additions
and
0 deletions
+135
-0
audioop.c
Modules/audioop.c
+135
-0
No files found.
Modules/audioop.c
Dosyayı görüntüle @
8e7a0f02
...
@@ -130,6 +130,9 @@ int sample;
...
@@ -130,6 +130,9 @@ int sample;
}
}
/* End of code taken from sox */
/* End of code taken from sox */
/* ADPCM step variation table */
static
float
newstep
[
5
]
=
{
0
.
8
,
0
.
9
,
1
.
0
,
1
.
75
,
1
.
75
};
#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) ((long *)(cp+i))
#define LONGP(cp, i) ((long *)(cp+i))
...
@@ -546,6 +549,136 @@ audioop_ulaw2lin(self, args)
...
@@ -546,6 +549,136 @@ audioop_ulaw2lin(self, args)
return
rv
;
return
rv
;
}
}
static
object
*
audioop_lin2adpcm
(
self
,
args
)
object
*
self
;
object
*
args
;
{
signed
char
*
cp
;
signed
char
*
ncp
;
int
len
,
size
,
val
,
step
,
valprev
,
delta
;
object
*
rv
,
*
state
,
*
str
;
int
i
;
if
(
!
getargs
(
args
,
"(s#iO)"
,
&
cp
,
&
len
,
&
size
,
&
state
)
)
return
0
;
if
(
size
!=
1
&&
size
!=
2
&&
size
!=
4
)
{
err_setstr
(
AudioopError
,
"Size should be 1, 2 or 4"
);
return
0
;
}
str
=
newsizedstringobject
(
NULL
,
len
/
size
);
if
(
str
==
0
)
return
0
;
ncp
=
(
signed
char
*
)
getstringvalue
(
str
);
/* Decode state, should have (value, step) */
if
(
state
==
None
)
{
/* First time, it seems. Set defaults */
valprev
=
0
;
step
=
4
;
/* The '4' is magic. Dunno it's significance */
}
else
if
(
!
getargs
(
state
,
"(ii)"
,
&
valprev
,
&
step
)
)
return
0
;
for
(
i
=
0
;
i
<
len
;
i
+=
size
)
{
if
(
size
==
1
)
val
=
((
int
)
*
CHARP
(
cp
,
i
))
<<
8
;
else
if
(
size
==
2
)
val
=
(
int
)
*
SHORTP
(
cp
,
i
);
else
if
(
size
==
4
)
val
=
((
int
)
*
LONGP
(
cp
,
i
))
>>
16
;
/* Step 1 - compute difference with previous value */
delta
=
(
val
-
valprev
)
/
step
;
/* Step 2 - Clamp */
if
(
delta
<
-
4
)
delta
=
-
4
;
else
if
(
delta
>
3
)
delta
=
3
;
/* Step 3 - Update previous value */
valprev
+=
delta
*
step
;
/* Step 4 - Clamp previous value to 16 bits */
if
(
valprev
>
32767
)
valprev
=
32767
;
else
if
(
valprev
<
-
32768
)
valprev
=
-
32768
;
/* Step 5 - Update step value */
step
=
step
*
newstep
[
abs
(
delta
)];
step
++
;
/* Don't understand this. */
/* Step 6 - Output value (as a whole byte, currently) */
*
ncp
++
=
delta
;
}
rv
=
mkvalue
(
"(O(ii))"
,
str
,
valprev
,
step
);
DECREF
(
str
);
return
rv
;
}
static
object
*
audioop_adpcm2lin
(
self
,
args
)
object
*
self
;
object
*
args
;
{
signed
char
*
cp
;
signed
char
*
ncp
;
int
len
,
size
,
val
,
valprev
,
step
,
delta
;
object
*
rv
,
*
str
,
*
state
;
int
i
;
if
(
!
getargs
(
args
,
"(s#iO)"
,
&
cp
,
&
len
,
&
size
,
&
state
)
)
return
0
;
if
(
size
!=
1
&&
size
!=
2
&&
size
!=
4
)
{
err_setstr
(
AudioopError
,
"Size should be 1, 2 or 4"
);
return
0
;
}
/* Decode state, should have (value, step) */
if
(
state
==
None
)
{
/* First time, it seems. Set defaults */
valprev
=
0
;
step
=
4
;
/* The '4' is magic. Dunno it's significance */
}
else
if
(
!
getargs
(
state
,
"(ii)"
,
&
valprev
,
&
step
)
)
return
0
;
str
=
newsizedstringobject
(
NULL
,
len
*
size
);
if
(
str
==
0
)
return
0
;
ncp
=
(
signed
char
*
)
getstringvalue
(
str
);
for
(
i
=
0
;
i
<
len
*
size
;
i
+=
size
)
{
/* Step 1 - get the delta value */
delta
=
*
cp
++
;
/* Step 2 - update output value */
valprev
=
valprev
+
delta
*
step
;
/* Step 3 - clamp output value */
if
(
valprev
>
32767
)
valprev
=
32767
;
else
if
(
valprev
<
-
32768
)
valprev
=
-
32768
;
/* Step 4 - Update step value */
step
=
step
*
newstep
[
abs
(
delta
)];
step
++
;
/* Step 5 - Output value */
if
(
size
==
1
)
*
CHARP
(
ncp
,
i
)
=
(
signed
char
)(
valprev
>>
8
);
else
if
(
size
==
2
)
*
SHORTP
(
ncp
,
i
)
=
(
short
)(
valprev
);
else
if
(
size
==
4
)
*
LONGP
(
ncp
,
i
)
=
(
long
)(
valprev
<<
16
);
}
rv
=
mkvalue
(
"(O(ii))"
,
str
,
valprev
,
step
);
DECREF
(
str
);
return
rv
;
}
static
struct
methodlist
audioop_methods
[]
=
{
static
struct
methodlist
audioop_methods
[]
=
{
{
"max"
,
audioop_max
},
{
"max"
,
audioop_max
},
{
"avg"
,
audioop_avg
},
{
"avg"
,
audioop_avg
},
...
@@ -555,6 +688,8 @@ static struct methodlist audioop_methods[] = {
...
@@ -555,6 +688,8 @@ static struct methodlist audioop_methods[] = {
{
"bias"
,
audioop_bias
},
{
"bias"
,
audioop_bias
},
{
"ulaw2lin"
,
audioop_ulaw2lin
},
{
"ulaw2lin"
,
audioop_ulaw2lin
},
{
"lin2ulaw"
,
audioop_lin2ulaw
},
{
"lin2ulaw"
,
audioop_lin2ulaw
},
{
"adpcm2lin"
,
audioop_adpcm2lin
},
{
"lin2adpcm"
,
audioop_lin2adpcm
},
{
"tomono"
,
audioop_tomono
},
{
"tomono"
,
audioop_tomono
},
{
"tostereo"
,
audioop_tostereo
},
{
"tostereo"
,
audioop_tostereo
},
{
"getsample"
,
audioop_getsample
},
{
"getsample"
,
audioop_getsample
},
...
...
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