summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2004-02-23 23:59:22 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2004-02-23 23:59:22 +0000
commit345124bb1dcb085c967c6fdb5aea344542dc38f3 (patch)
tree1568d5fdb0673e4c97b2bc13d09534ab924aeb9b
parentc3dd54778b9a6ace1f2623d40984fdb318a44190 (diff)
slinear to alaw converters; from netbsd, via jakemsr@jakemsr.com
-rw-r--r--sys/dev/mulaw.c29
-rw-r--r--sys/dev/mulaw.h8
2 files changed, 32 insertions, 5 deletions
diff --git a/sys/dev/mulaw.c b/sys/dev/mulaw.c
index 3d9496b3a4f..0c7f7dcfce9 100644
--- a/sys/dev/mulaw.c
+++ b/sys/dev/mulaw.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mulaw.c,v 1.10 2003/06/27 00:23:43 jason Exp $ */
+/* $OpenBSD: mulaw.c,v 1.11 2004/02/23 23:59:21 deraadt Exp $ */
/* $NetBSD: mulaw.c,v 1.15 2001/01/18 20:28:20 jdolecek Exp $ */
/*
@@ -40,7 +40,7 @@
#include <dev/mulaw.h>
/*
- * This table converts a (8 bit) mulaw value two a 16 bit value.
+ * This table converts a (8 bit) mu-law value two a 16 bit value.
* The 16 bits are represented as an array of two bytes for easier access
* to the individual bytes.
*/
@@ -455,6 +455,31 @@ slinear8_to_alaw(void *v, u_char *p, int cc)
}
}
+void
+slinear16_to_alaw_le(void *v, u_char *p, int cc)
+{
+ u_char *q = p;
+
+ while (--cc >= 0) {
+ *p = lintoalaw[q[1] ^ 0x80];
+ ++p;
+ q += 2;
+ }
+}
+
+
+void
+slinear16_to_alaw_be(void *v, u_char *p, int cc)
+{
+ u_char *q = p;
+
+ while (--cc >= 0) {
+ *p = lintoalaw[q[0] ^ 0x80];
+ ++p;
+ q += 2;
+ }
+}
+
/*
* same as mulaw_to_ulinear16_le(), plus expand mono to stereo
*/
diff --git a/sys/dev/mulaw.h b/sys/dev/mulaw.h
index c47f7ea8b70..d7e5d2f3234 100644
--- a/sys/dev/mulaw.h
+++ b/sys/dev/mulaw.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mulaw.h,v 1.10 2003/06/27 00:23:43 jason Exp $ */
+/* $OpenBSD: mulaw.h,v 1.11 2004/02/23 23:59:21 deraadt Exp $ */
/* $NetBSD: mulaw.h,v 1.11 1999/11/01 18:12:19 augustss Exp $ */
/*-
@@ -44,7 +44,7 @@ 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. */
+/* Convert 8-bit mu-law to/from 16 bit signed linear. */
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);
@@ -57,11 +57,13 @@ 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 *, int);
extern void alaw_to_ulinear16_be(void *, u_char *, int);
-/* Convert 8-bit a-law to 16 bit signed linear. */
+/* Convert 8-bit a-law to/from 16 bit signed linear. */
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);
+extern void slinear16_to_alaw_le(void *, u_char *, int);
+extern void slinear16_to_alaw_be(void *, u_char *, int);
/* Convert 8-bit a-law to/from 8 bit unsigned linear. */
extern void alaw_to_ulinear8(void *, u_char *, int);
extern void ulinear8_to_alaw(void *, u_char *, int);