summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorJason Wright <jason@cvs.openbsd.org>2003-06-27 00:23:44 +0000
committerJason Wright <jason@cvs.openbsd.org>2003-06-27 00:23:44 +0000
commit31af9665ac30b0fc09f3b708812787f9fd12036b (patch)
tree2c68e9510545ba4d55d7368705d1ef725546431c /sys/dev
parent219c3e12081b47fab05630ca3272f301df6aecca (diff)
ansify and add an alaw <-> mulaw conversion
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/auconv.c122
-rw-r--r--sys/dev/mulaw.c120
-rw-r--r--sys/dev/mulaw.h47
3 files changed, 89 insertions, 200 deletions
diff --git a/sys/dev/auconv.c b/sys/dev/auconv.c
index c1e5c3c0987..fdacfd764b4 100644
--- a/sys/dev/auconv.c
+++ b/sys/dev/auconv.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: auconv.c,v 1.5 2002/05/06 02:34:57 nate Exp $ */
+/* $OpenBSD: auconv.c,v 1.6 2003/06/27 00:23:43 jason Exp $ */
/* $NetBSD: auconv.c,v 1.3 1999/11/01 18:12:19 augustss Exp $ */
/*
@@ -40,10 +40,7 @@
#include <dev/auconv.h>
void
-change_sign8(v, p, cc)
- void *v;
- u_char *p;
- int cc;
+change_sign8(void *v, u_char *p, int cc)
{
while (--cc >= 0) {
*p ^= 0x80;
@@ -52,10 +49,7 @@ change_sign8(v, p, cc)
}
void
-change_sign16_le(v, p, cc)
- void *v;
- u_char *p;
- int cc;
+change_sign16_le(void *v, u_char *p, int cc)
{
while ((cc -= 2) >= 0) {
p[1] ^= 0x80;
@@ -64,10 +58,7 @@ change_sign16_le(v, p, cc)
}
void
-change_sign16_be(v, p, cc)
- void *v;
- u_char *p;
- int cc;
+change_sign16_be(void *v, u_char *p, int cc)
{
while ((cc -= 2) >= 0) {
p[0] ^= 0x80;
@@ -76,10 +67,7 @@ change_sign16_be(v, p, cc)
}
void
-swap_bytes(v, p, cc)
- void *v;
- u_char *p;
- int cc;
+swap_bytes(void *v, u_char *p, int cc)
{
u_char t;
@@ -92,10 +80,7 @@ swap_bytes(v, p, cc)
}
void
-swap_bytes_change_sign16_le(v, p, cc)
- void *v;
- u_char *p;
- int cc;
+swap_bytes_change_sign16_le(void *v, u_char *p, int cc)
{
u_char t;
@@ -108,10 +93,7 @@ swap_bytes_change_sign16_le(v, p, cc)
}
void
-swap_bytes_change_sign16_be(v, p, cc)
- void *v;
- u_char *p;
- int cc;
+swap_bytes_change_sign16_be(void *v, u_char *p, int cc)
{
u_char t;
@@ -124,28 +106,19 @@ swap_bytes_change_sign16_be(v, p, cc)
}
void
-change_sign16_swap_bytes_le(v, p, cc)
- void *v;
- u_char *p;
- int cc;
+change_sign16_swap_bytes_le(void *v, u_char *p, int cc)
{
swap_bytes_change_sign16_be(v, p, cc);
}
void
-change_sign16_swap_bytes_be(v, p, cc)
- void *v;
- u_char *p;
- int cc;
+change_sign16_swap_bytes_be(void *v, u_char *p, int cc)
{
swap_bytes_change_sign16_le(v, p, cc);
}
void
-linear8_to_linear16_le(v, p, cc)
- void *v;
- u_char *p;
- int cc;
+linear8_to_linear16_le(void *v, u_char *p, int cc)
{
u_char *q = p;
@@ -159,10 +132,7 @@ linear8_to_linear16_le(v, p, cc)
}
void
-linear8_to_linear16_be(v, p, cc)
- void *v;
- u_char *p;
- int cc;
+linear8_to_linear16_be(void *v, u_char *p, int cc)
{
u_char *q = p;
@@ -176,10 +146,7 @@ linear8_to_linear16_be(v, p, cc)
}
void
-linear16_to_linear8_le(v, p, cc)
- void *v;
- u_char *p;
- int cc;
+linear16_to_linear8_le(void *v, u_char *p, int cc)
{
u_char *q = p;
@@ -190,10 +157,7 @@ linear16_to_linear8_le(v, p, cc)
}
void
-linear16_to_linear8_be(v, p, cc)
- void *v;
- u_char *p;
- int cc;
+linear16_to_linear8_be(void *v, u_char *p, int cc)
{
u_char *q = p;
@@ -204,10 +168,7 @@ linear16_to_linear8_be(v, p, cc)
}
void
-ulinear8_to_linear16_le(v, p, cc)
- void *v;
- u_char *p;
- int cc;
+ulinear8_to_linear16_le(void *v, u_char *p, int cc)
{
u_char *q = p;
@@ -221,10 +182,7 @@ ulinear8_to_linear16_le(v, p, cc)
}
void
-ulinear8_to_linear16_be(v, p, cc)
- void *v;
- u_char *p;
- int cc;
+ulinear8_to_linear16_be(void *v, u_char *p, int cc)
{
u_char *q = p;
@@ -263,10 +221,7 @@ linear16_to_ulinear8_be(void *v, u_char *p, int cc)
* just expand mono to stereo, no other conversions
*/
void
-noswap_bytes_mts(v, p, cc)
- void *v;
- u_char *p;
- int cc;
+noswap_bytes_mts(void *v, u_char *p, int cc)
{
u_char *q = p;
@@ -283,10 +238,7 @@ noswap_bytes_mts(v, p, cc)
* same as swap_bytes(), just expand mono to stereo
*/
void
-swap_bytes_mts(v, p, cc)
- void *v;
- u_char *p;
- int cc;
+swap_bytes_mts(void *v, u_char *p, int cc)
{
u_char *q = p;
@@ -303,10 +255,7 @@ swap_bytes_mts(v, p, cc)
* same as linear8_to_linear16_le(), plus expand mono to stereo
*/
void
-linear8_to_linear16_le_mts(v, p, cc)
- void *v;
- u_char *p;
- int cc;
+linear8_to_linear16_le_mts(void *v, u_char *p, int cc)
{
u_char *q = p;
@@ -323,10 +272,7 @@ linear8_to_linear16_le_mts(v, p, cc)
* same as linear8_to_linear16_be(), plus expand mono to stereo
*/
void
-linear8_to_linear16_be_mts(v, p, cc)
- void *v;
- u_char *p;
- int cc;
+linear8_to_linear16_be_mts(void *v, u_char *p, int cc)
{
u_char *q = p;
@@ -343,10 +289,7 @@ linear8_to_linear16_be_mts(v, p, cc)
* same as ulinear8_to_linear16_le(), plus expand mono to stereo
*/
void
-ulinear8_to_linear16_le_mts(v, p, cc)
- void *v;
- u_char *p;
- int cc;
+ulinear8_to_linear16_le_mts(void *v, u_char *p, int cc)
{
u_char *q = p;
@@ -363,10 +306,7 @@ ulinear8_to_linear16_le_mts(v, p, cc)
* same as ulinear8_to_linear16_be(), plus expand mono to stereo
*/
void
-ulinear8_to_linear16_be_mts(v, p, cc)
- void *v;
- u_char *p;
- int cc;
+ulinear8_to_linear16_be_mts(void *v, u_char *p, int cc)
{
u_char *q = p;
@@ -383,10 +323,7 @@ ulinear8_to_linear16_be_mts(v, p, cc)
* same as change_sign16_le(), plus expand mono to stereo
*/
void
-change_sign16_le_mts(v, p, cc)
- void *v;
- u_char *p;
- int cc;
+change_sign16_le_mts(void *v, u_char *p, int cc)
{
u_char *q = p;
@@ -403,10 +340,7 @@ change_sign16_le_mts(v, p, cc)
* same as change_sign16_be(), plus expand mono to stereo
*/
void
-change_sign16_be_mts(v, p, cc)
- void *v;
- u_char *p;
- int cc;
+change_sign16_be_mts(void *v, u_char *p, int cc)
{
u_char *q = p;
@@ -423,10 +357,7 @@ change_sign16_be_mts(v, p, cc)
* same as change_sign16_swap_bytes_le(), plus expand mono to stereo
*/
void
-change_sign16_swap_bytes_le_mts(v, p, cc)
- void *v;
- u_char *p;
- int cc;
+change_sign16_swap_bytes_le_mts(void *v, u_char *p, int cc)
{
change_sign16_be_mts(v, p, cc);
}
@@ -435,10 +366,7 @@ change_sign16_swap_bytes_le_mts(v, p, cc)
* same as change_sign16_swap_bytes_be(), plus expand mono to stereo
*/
void
-change_sign16_swap_bytes_be_mts(v, p, cc)
- void *v;
- u_char *p;
- int cc;
+change_sign16_swap_bytes_be_mts(void *v, u_char *p, int cc)
{
change_sign16_le_mts(v, p, cc);
}
diff --git a/sys/dev/mulaw.c b/sys/dev/mulaw.c
index ed48659fe39..3d9496b3a4f 100644
--- a/sys/dev/mulaw.c
+++ b/sys/dev/mulaw.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mulaw.c,v 1.9 2002/05/06 02:34:57 nate Exp $ */
+/* $OpenBSD: mulaw.c,v 1.10 2003/06/27 00:23:43 jason Exp $ */
/* $NetBSD: mulaw.c,v 1.15 2001/01/18 20:28:20 jdolecek Exp $ */
/*
@@ -249,10 +249,7 @@ static const u_char lintoalaw[256] = {
};
void
-mulaw_to_ulinear8(v, p, cc)
- void *v;
- u_char *p;
- int cc;
+mulaw_to_ulinear8(void *v, u_char *p, int cc)
{
/* Use the 16 bit table for 8 bits too. */
while (--cc >= 0) {
@@ -262,10 +259,7 @@ mulaw_to_ulinear8(v, p, cc)
}
void
-mulaw_to_slinear8(v, p, cc)
- void *v;
- u_char *p;
- int cc;
+mulaw_to_slinear8(void *v, u_char *p, int cc)
{
/* Use the 16 bit table for 8 bits too. */
while (--cc >= 0) {
@@ -275,10 +269,7 @@ mulaw_to_slinear8(v, p, cc)
}
void
-mulaw_to_ulinear16_le(v, p, cc)
- void *v;
- u_char *p;
- int cc;
+mulaw_to_ulinear16_le(void *v, u_char *p, int cc)
{
u_char *q = p;
@@ -293,10 +284,7 @@ mulaw_to_ulinear16_le(v, p, cc)
}
void
-mulaw_to_ulinear16_be(v, p, cc)
- void *v;
- u_char *p;
- int cc;
+mulaw_to_ulinear16_be(void *v, u_char *p, int cc)
{
u_char *q = p;
@@ -311,10 +299,7 @@ mulaw_to_ulinear16_be(v, p, cc)
}
void
-mulaw_to_slinear16_le(v, p, cc)
- void *v;
- u_char *p;
- int cc;
+mulaw_to_slinear16_le(void *v, u_char *p, int cc)
{
u_char *q = p;
@@ -329,10 +314,7 @@ mulaw_to_slinear16_le(v, p, cc)
}
void
-mulaw_to_slinear16_be(v, p, cc)
- void *v;
- u_char *p;
- int cc;
+mulaw_to_slinear16_be(void *v, u_char *p, int cc)
{
u_char *q = p;
@@ -358,10 +340,7 @@ slinear16_to_mulaw_le(void *v, u_char* p, int cc)
}
void
-ulinear8_to_mulaw(v, p, cc)
- void *v;
- u_char *p;
- int cc;
+ulinear8_to_mulaw(void *v, u_char *p, int cc)
{
while (--cc >= 0) {
*p = lintomulaw[*p];
@@ -370,10 +349,7 @@ ulinear8_to_mulaw(v, p, cc)
}
void
-slinear8_to_mulaw(v, p, cc)
- void *v;
- u_char *p;
- int cc;
+slinear8_to_mulaw(void *v, u_char *p, int cc)
{
while (--cc >= 0) {
*p = lintomulaw[*p ^ 0x80];
@@ -382,10 +358,7 @@ slinear8_to_mulaw(v, p, cc)
}
void
-alaw_to_ulinear8(v, p, cc)
- void *v;
- u_char *p;
- int cc;
+alaw_to_ulinear8(void *v, u_char *p, int cc)
{
/* Use the 16 bit table for 8 bits too. */
while (--cc >= 0) {
@@ -395,10 +368,7 @@ alaw_to_ulinear8(v, p, cc)
}
void
-alaw_to_slinear8(v, p, cc)
- void *v;
- u_char *p;
- int cc;
+alaw_to_slinear8(void *v, u_char *p, int cc)
{
/* Use the 16 bit table for 8 bits too. */
while (--cc >= 0) {
@@ -408,10 +378,7 @@ alaw_to_slinear8(v, p, cc)
}
void
-alaw_to_ulinear16_le(v, p, cc)
- void *v;
- u_char *p;
- int cc;
+alaw_to_ulinear16_le(void *v, u_char *p, int cc)
{
u_char *q = p;
@@ -426,10 +393,7 @@ alaw_to_ulinear16_le(v, p, cc)
}
void
-alaw_to_ulinear16_be(v, p, cc)
- void *v;
- u_char *p;
- int cc;
+alaw_to_ulinear16_be(void *v, u_char *p, int cc)
{
u_char *q = p;
@@ -444,10 +408,7 @@ alaw_to_ulinear16_be(v, p, cc)
}
void
-alaw_to_slinear16_le(v, p, cc)
- void *v;
- u_char *p;
- int cc;
+alaw_to_slinear16_le(void *v, u_char *p, int cc)
{
u_char *q = p;
@@ -462,10 +423,7 @@ alaw_to_slinear16_le(v, p, cc)
}
void
-alaw_to_slinear16_be(v, p, cc)
- void *v;
- u_char *p;
- int cc;
+alaw_to_slinear16_be(void *v, u_char *p, int cc)
{
u_char *q = p;
@@ -480,10 +438,7 @@ alaw_to_slinear16_be(v, p, cc)
}
void
-ulinear8_to_alaw(v, p, cc)
- void *v;
- u_char *p;
- int cc;
+ulinear8_to_alaw(void *v, u_char *p, int cc)
{
while (--cc >= 0) {
*p = lintoalaw[*p];
@@ -492,10 +447,7 @@ ulinear8_to_alaw(v, p, cc)
}
void
-slinear8_to_alaw(v, p, cc)
- void *v;
- u_char *p;
- int cc;
+slinear8_to_alaw(void *v, u_char *p, int cc)
{
while (--cc >= 0) {
*p = lintoalaw[*p ^ 0x80];
@@ -507,10 +459,7 @@ slinear8_to_alaw(v, p, cc)
* same as mulaw_to_ulinear16_le(), plus expand mono to stereo
*/
void
-mulaw_to_ulinear16_le_mts(v, p, cc)
- void *v;
- u_char *p;
- int cc;
+mulaw_to_ulinear16_le_mts(void *v, u_char *p, int cc)
{
u_char *q = p;
@@ -528,10 +477,7 @@ mulaw_to_ulinear16_le_mts(v, p, cc)
* same as mulaw_to_ulinear16_be(), plus expand mono to stereo
*/
void
-mulaw_to_ulinear16_be_mts(v, p, cc)
- void *v;
- u_char *p;
- int cc;
+mulaw_to_ulinear16_be_mts(void *v, u_char *p, int cc)
{
u_char *q = p;
@@ -549,10 +495,7 @@ mulaw_to_ulinear16_be_mts(v, p, cc)
* same as alaw_to_slinear16_le(), plus expand mono to stereo
*/
void
-alaw_to_slinear16_le_mts(v, p, cc)
- void *v;
- u_char *p;
- int cc;
+alaw_to_slinear16_le_mts(void *v, u_char *p, int cc)
{
u_char *q = p;
@@ -570,10 +513,7 @@ alaw_to_slinear16_le_mts(v, p, cc)
* same as alaw_to_slinear16_be(), plus expand mono to stereo
*/
void
-alaw_to_slinear16_be_mts(v, p, cc)
- void *v;
- u_char *p;
- int cc;
+alaw_to_slinear16_be_mts(void *v, u_char *p, int cc)
{
u_char *q = p;
@@ -586,3 +526,21 @@ alaw_to_slinear16_be_mts(v, p, cc)
q[1] = q[3] = alawtolin16[*p][1];
}
}
+
+void
+alaw_to_mulaw(void *v, u_char *p, int cc)
+{
+ while (--cc >= 0) {
+ *p = lintomulaw[alawtolin16[*p][0]];
+ ++p;
+ }
+}
+
+void
+mulaw_to_alaw(void *v, u_char *p, int cc)
+{
+ while (--cc >= 0) {
+ *p = lintoalaw[mulawtolin16[*p][0]];
+ ++p;
+ }
+}
diff --git a/sys/dev/mulaw.h b/sys/dev/mulaw.h
index ac485b2edb3..c47f7ea8b70 100644
--- a/sys/dev/mulaw.h
+++ b/sys/dev/mulaw.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mulaw.h,v 1.9 2002/05/06 02:34:57 nate Exp $ */
+/* $OpenBSD: mulaw.h,v 1.10 2003/06/27 00:23:43 jason Exp $ */
/* $NetBSD: mulaw.h,v 1.11 1999/11/01 18:12:19 augustss Exp $ */
/*-
@@ -40,34 +40,37 @@
/* *_mts versions convert mono to stereo, in addition */
/* Convert 8-bit mu-law to 16 bit unsigned linear. */
-extern void mulaw_to_ulinear16_le(void *, u_char *buf, int cnt);
-extern void mulaw_to_ulinear16_le_mts(void *, u_char *buf, int cnt);
-extern void mulaw_to_ulinear16_be(void *, u_char *buf, int cnt);
-extern void mulaw_to_ulinear16_be_mts(void *, u_char *buf, int cnt);
+extern void mulaw_to_ulinear16_le(void *, u_char *, int);
+extern void mulaw_to_ulinear16_le_mts(void *, u_char *, int);
+extern void mulaw_to_ulinear16_be(void *, u_char *, int);
+extern void mulaw_to_ulinear16_be_mts(void *, u_char *, int);
/* Convert 8-bit mu-law to 16 bit signed linear. */
-extern void mulaw_to_slinear16_le(void *, u_char *buf, int cnt);
-extern void mulaw_to_slinear16_be(void *, u_char *buf, int cnt);
-extern void slinear16_to_mulaw_le(void *, u_char *buf, int cnt);
+extern void mulaw_to_slinear16_le(void *, u_char *, int);
+extern void mulaw_to_slinear16_be(void *, u_char *, int);
+extern void slinear16_to_mulaw_le(void *, u_char *, int);
/* Convert 8-bit mu-law to/from 8 bit unsigned linear. */
-extern void mulaw_to_ulinear8(void *, u_char *buf, int cnt);
-extern void ulinear8_to_mulaw(void *, u_char *buf, int cnt);
+extern void mulaw_to_ulinear8(void *, u_char *, int);
+extern void ulinear8_to_mulaw(void *, u_char *, int);
/* Convert 8-bit mu-law to/from 8 bit signed linear. */
-extern void mulaw_to_slinear8(void *, u_char *buf, int cnt);
-extern void slinear8_to_mulaw(void *, u_char *buf, int cnt);
+extern void mulaw_to_slinear8(void *, u_char *, int);
+extern void slinear8_to_mulaw(void *, u_char *, int);
/* Convert 8-bit a-law to 16 bit unsigned linear. */
-extern void alaw_to_ulinear16_le(void *, u_char *buf, int cnt);
-extern void alaw_to_ulinear16_be(void *, u_char *buf, int cnt);
+extern void alaw_to_ulinear16_le(void *, u_char *, int);
+extern void alaw_to_ulinear16_be(void *, u_char *, int);
/* Convert 8-bit a-law to 16 bit signed linear. */
-extern void alaw_to_slinear16_le(void *, u_char *buf, int cnt);
-extern void alaw_to_slinear16_le_mts(void *, u_char *buf, int cnt);
-extern void alaw_to_slinear16_be(void *, u_char *buf, int cnt);
-extern void alaw_to_slinear16_be_mts(void *, u_char *buf, int cnt);
+extern void alaw_to_slinear16_le(void *, u_char *, int);
+extern void alaw_to_slinear16_le_mts(void *, u_char *, int);
+extern void alaw_to_slinear16_be(void *, u_char *, int);
+extern void alaw_to_slinear16_be_mts(void *, u_char *, int);
/* Convert 8-bit a-law to/from 8 bit unsigned linear. */
-extern void alaw_to_ulinear8(void *, u_char *buf, int cnt);
-extern void ulinear8_to_alaw(void *, u_char *buf, int cnt);
+extern void alaw_to_ulinear8(void *, u_char *, int);
+extern void ulinear8_to_alaw(void *, u_char *, int);
/* Convert 8-bit a-law to/from 8 bit signed linear. */
-extern void alaw_to_slinear8(void *, u_char *buf, int cnt);
-extern void slinear8_to_alaw(void *, u_char *buf, int cnt);
+extern void alaw_to_slinear8(void *, u_char *, int);
+extern void slinear8_to_alaw(void *, u_char *, int);
+/* Convert 8-bit a-law to/from mulaw */
+void alaw_to_mulaw(void *, u_char *, int);
+void mulaw_to_alaw(void *, u_char *, int);
/* backwards compat for now */
#if BYTE_ORDER == LITTLE_ENDIAN