diff options
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/mulaw.c | 105 | ||||
-rw-r--r-- | sys/dev/mulaw.h | 14 |
2 files changed, 109 insertions, 10 deletions
diff --git a/sys/dev/mulaw.c b/sys/dev/mulaw.c index 8747c5e51ae..e1134b6c444 100644 --- a/sys/dev/mulaw.c +++ b/sys/dev/mulaw.c @@ -1,5 +1,5 @@ -/* $OpenBSD: mulaw.c,v 1.3 1998/04/26 21:03:10 provos Exp $ */ -/* $NetBSD: mulaw.c,v 1.8 1997/08/04 09:29:53 augustss Exp $ */ +/* $OpenBSD: mulaw.c,v 1.4 1998/10/28 18:01:01 downsj Exp $ */ +/* $NetBSD: mulaw.c,v 1.12 1998/08/09 21:41:45 mycroft Exp $ */ /* * Copyright (c) 1991-1993 Regents of the University of California. @@ -271,6 +271,19 @@ mulaw_to_ulinear8(v, p, cc) } void +mulaw_to_slinear8(v, p, cc) + void *v; + u_char *p; + int cc; +{ + /* Use the 16 bit table for 8 bits too. */ + while (--cc >= 0) { + *p = mulawtolin16[*p][0] ^ 0x80; + ++p; + } +} + +void mulaw_to_ulinear16(v, p, cc) void *v; u_char *p; @@ -279,10 +292,30 @@ mulaw_to_ulinear16(v, p, cc) u_char *q = p; p += cc; - q += cc * 2; + q += cc << 1; while (--cc >= 0) { - *--q = mulawtolin16[*--p][LO]; - *--q = mulawtolin16[*p ][HI]; + --p; + q -= 2; + q[HI] = mulawtolin16[*p][0]; + q[LO] = mulawtolin16[*p][1]; + } +} + +void +mulaw_to_slinear16(v, p, cc) + void *v; + u_char *p; + int cc; +{ + u_char *q = p; + + p += cc; + q += cc << 1; + while (--cc >= 0) { + --p; + q -= 2; + q[HI] = mulawtolin16[*p][0] ^ 0x80; + q[LO] = mulawtolin16[*p][1]; } } @@ -299,6 +332,18 @@ ulinear8_to_mulaw(v, p, cc) } void +slinear8_to_mulaw(v, p, cc) + void *v; + u_char *p; + int cc; +{ + while (--cc >= 0) { + *p = lintomulaw[*p ^ 0x80]; + ++p; + } +} + +void alaw_to_ulinear8(v, p, cc) void *v; u_char *p; @@ -312,6 +357,19 @@ alaw_to_ulinear8(v, p, cc) } void +alaw_to_slinear8(v, p, cc) + void *v; + u_char *p; + int cc; +{ + /* Use the 16 bit table for 8 bits too. */ + while (--cc >= 0) { + *p = alawtolin16[*p][0] ^ 0x80; + ++p; + } +} + +void alaw_to_ulinear16(v, p, cc) void *v; u_char *p; @@ -320,10 +378,30 @@ alaw_to_ulinear16(v, p, cc) u_char *q = p; p += cc; - q += cc * 2; + q += cc << 1; + while (--cc >= 0) { + --p; + q -= 2; + q[HI] = alawtolin16[*p][0]; + q[LO] = alawtolin16[*p][1]; + } +} + +void +alaw_to_slinear16(v, p, cc) + void *v; + u_char *p; + int cc; +{ + u_char *q = p; + + p += cc; + q += cc << 1; while (--cc >= 0) { - *--q = alawtolin16[*--p][LO]; - *--q = alawtolin16[*p ][HI]; + --p; + q -= 2; + q[HI] = alawtolin16[*p][0] ^ 0x80; + q[LO] = alawtolin16[*p][1]; } } @@ -339,3 +417,14 @@ ulinear8_to_alaw(v, p, cc) } } +void +slinear8_to_alaw(v, p, cc) + void *v; + u_char *p; + int cc; +{ + while (--cc >= 0) { + *p = lintoalaw[*p ^ 0x80]; + ++p; + } +} diff --git a/sys/dev/mulaw.h b/sys/dev/mulaw.h index bf70d089a67..dbe57673682 100644 --- a/sys/dev/mulaw.h +++ b/sys/dev/mulaw.h @@ -1,5 +1,5 @@ -/* $OpenBSD: mulaw.h,v 1.3 1998/04/26 21:03:11 provos Exp $ */ -/* $NetBSD: mulaw.h,v 1.8 1997/10/09 08:11:10 jtc Exp $ */ +/* $OpenBSD: mulaw.h,v 1.4 1998/10/28 18:01:02 downsj Exp $ */ +/* $NetBSD: mulaw.h,v 1.10 1998/08/09 19:22:15 mycroft Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -39,11 +39,21 @@ /* Convert 8-bit mu-law to 16 bit unsigned linear. */ extern void mulaw_to_ulinear16 __P((void *, u_char *buf, int cnt)); +/* Convert 8-bit mu-law to 16 bit signed linear. */ +extern void mulaw_to_slinear16 __P((void *, u_char *buf, int cnt)); /* Convert 8-bit mu-law to/from 8 bit unsigned linear. */ extern void mulaw_to_ulinear8 __P((void *, u_char *buf, int cnt)); extern void ulinear8_to_mulaw __P((void *, u_char *buf, int cnt)); +/* Convert 8-bit mu-law to/from 8 bit signed linear. */ +extern void mulaw_to_slinear8 __P((void *, u_char *buf, int cnt)); +extern void slinear8_to_mulaw __P((void *, u_char *buf, int cnt)); /* Convert 8-bit a-law to 16 bit unsigned linear. */ extern void alaw_to_ulinear16 __P((void *, u_char *buf, int cnt)); +/* Convert 8-bit a-law to 16 bit signed linear. */ +extern void alaw_to_slinear16 __P((void *, u_char *buf, int cnt)); /* Convert 8-bit a-law to/from 8 bit unsigned linear. */ extern void alaw_to_ulinear8 __P((void *, u_char *buf, int cnt)); extern void ulinear8_to_alaw __P((void *, u_char *buf, int cnt)); +/* Convert 8-bit a-law to/from 8 bit signed linear. */ +extern void alaw_to_slinear8 __P((void *, u_char *buf, int cnt)); +extern void slinear8_to_alaw __P((void *, u_char *buf, int cnt)); |