summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/auconv.c220
-rw-r--r--sys/dev/auconv.h25
-rw-r--r--sys/dev/mulaw.c86
-rw-r--r--sys/dev/mulaw.h12
4 files changed, 339 insertions, 4 deletions
diff --git a/sys/dev/auconv.c b/sys/dev/auconv.c
index 796ef5a7a79..78b913844a0 100644
--- a/sys/dev/auconv.c
+++ b/sys/dev/auconv.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: auconv.c,v 1.3 2001/05/01 01:49:48 aaron Exp $ */
+/* $OpenBSD: auconv.c,v 1.4 2001/12/31 04:14:00 mickey Exp $ */
/* $NetBSD: auconv.c,v 1.3 1999/11/01 18:12:19 augustss Exp $ */
/*
@@ -202,3 +202,221 @@ linear16_to_linear8_be(v, p, cc)
p += 2;
}
}
+
+void
+ulinear8_to_linear16_le(v, p, cc)
+ void *v;
+ u_char *p;
+ int cc;
+{
+ u_char *q = p;
+
+ p += cc;
+ q += cc * 2;
+ while (--cc >= 0) {
+ q -= 2;
+ q[1] = (*--p) ^ 0x80;
+ q[0] = 0;
+ }
+}
+
+/*
+ * just expand mono to stereo, no other conversions
+ */
+void
+noswap_bytes_mts(v, p, cc)
+ void *v;
+ u_char *p;
+ int cc;
+{
+ u_char *q = p;
+
+ p += cc;
+ q += cc * 2;
+ while ((cc -= 2) >= 0) {
+ q -= 4;
+ q[1] = q[3] = *--p;
+ q[0] = q[2] = *--p;
+ }
+}
+
+/*
+ * same as swap_bytes(), just expand mono to stereo
+ */
+void
+swap_bytes_mts(v, p, cc)
+ void *v;
+ u_char *p;
+ int cc;
+{
+ u_char *q = p;
+
+ p += cc;
+ q += cc * 2;
+ while ((cc -= 2) >= 0) {
+ q -= 4;
+ q[0] = q[2] = *--p;
+ q[1] = q[3] = *--p;
+ }
+}
+
+/*
+ * 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;
+{
+ u_char *q = p;
+
+ p += cc;
+ q += cc * 4;
+ while (--cc >= 0) {
+ q -= 4;
+ q[1] = q[3] = *--p;
+ q[0] = q[2] = 0;
+ }
+}
+
+/*
+ * 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;
+{
+ u_char *q = p;
+
+ p += cc;
+ q += cc * 4;
+ while (--cc >= 0) {
+ q -= 4;
+ q[0] = q[2] = *--p;
+ q[1] = q[3] = 0;
+ }
+}
+
+void
+ulinear8_to_linear16_be(v, p, cc)
+ void *v;
+ u_char *p;
+ int cc;
+{
+ u_char *q = p;
+
+ p += cc;
+ q += cc * 2;
+ while (--cc >= 0) {
+ q -= 2;
+ q[0] = (*--p) ^ 0x80;
+ q[1] = 0;
+ }
+}
+
+/*
+ * 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;
+{
+ u_char *q = p;
+
+ p += cc;
+ q += cc * 4;
+ while (--cc >= 0) {
+ q -= 4;
+ q[1] = q[3] = (*--p) ^ 0x80;
+ q[0] = q[2] = 0;
+ }
+}
+
+/*
+ * 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;
+{
+ u_char *q = p;
+
+ p += cc;
+ q += cc * 4;
+ while (--cc >= 0) {
+ q -= 4;
+ q[0] = q[2] = (*--p) ^ 0x80;
+ q[1] = q[3] = 0;
+ }
+}
+
+/*
+ * 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;
+{
+ u_char *q = p;
+
+ p += cc;
+ q += cc * 2;
+ while ((cc -= 2) >= 0) {
+ q -= 4;
+ q[1] = q[3] = (*--p) ^ 0x80;
+ q[0] = q[2] = *--p;
+ }
+}
+
+/*
+ * 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;
+{
+ u_char *q = p;
+
+ p += cc;
+ q += cc * 2;
+ while ((cc -= 2) >= 0) {
+ q -= 4;
+ q[0] = q[2] = (*--p) ^ 0x80;
+ q[1] = q[3] = *--p;
+ }
+}
+
+/*
+ * 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_be_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_le_mts(v, p, cc);
+}
diff --git a/sys/dev/auconv.h b/sys/dev/auconv.h
index 82b6049934c..20380291a84 100644
--- a/sys/dev/auconv.h
+++ b/sys/dev/auconv.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: auconv.h,v 1.3 2001/05/01 01:49:48 aaron Exp $ */
+/* $OpenBSD: auconv.h,v 1.4 2001/12/31 04:14:00 mickey Exp $ */
/* $NetBSD: auconv.h,v 1.5 1999/11/01 18:12:19 augustss Exp $ */
/*-
@@ -52,6 +52,19 @@ extern void linear8_to_linear16_le __P((void *, u_char *, int));
extern void linear8_to_linear16_be __P((void *, u_char *, int));
extern void linear16_to_linear8_le __P((void *, u_char *, int));
extern void linear16_to_linear8_be __P((void *, u_char *, int));
+extern void ulinear8_to_linear16_le __P((void *, u_char *, int));
+extern void ulinear8_to_linear16_be __P((void *, u_char *, int));
+/* same as above, plus converting mono to stereo */
+extern void noswap_bytes_mts __P((void *, u_char *, int));
+extern void swap_bytes_mts __P((void *, u_char *, int));
+extern void linear8_to_linear16_le_mts __P((void *, u_char *, int));
+extern void linear8_to_linear16_be_mts __P((void *, u_char *, int));
+extern void ulinear8_to_linear16_le_mts __P((void *, u_char *, int));
+extern void ulinear8_to_linear16_be_mts __P((void *, u_char *, int));
+extern void change_sign16_le_mts __P((void *, u_char *, int));
+extern void change_sign16_be_mts __P((void *, u_char *, int));
+extern void change_sign16_swap_bytes_le_mts __P((void *, u_char *, int));
+extern void change_sign16_swap_bytes_be_mts __P((void *, u_char *, int));
/* backwards compat for now */
#if BYTE_ORDER == LITTLE_ENDIAN
@@ -59,9 +72,19 @@ extern void linear16_to_linear8_be __P((void *, u_char *, int));
#define change_sign16_swap_bytes swap_bytes_change_sign16_le
#define swap_bytes_change_sign16 swap_bytes_change_sign16_le
#define linear8_to_linear16 linear8_to_linear16_le
+#define ulinear8_to_linear16 ulinear8_to_linear16_le
+#define linear8_to_linear16_mts linear8_to_linear16_le_mts
+#define ulinear8_to_linear16_mts ulinear8_to_linear16_le_mts
+#define change_sign16_mts change_sign16_le_mts
+#define change_sign16_swap_bytes_mts change_sign16_swap_bytes_le_mts
#else
#define change_sign16 change_sign16_be
#define change_sign16_swap_bytes swap_bytes_change_sign16_be
#define swap_bytes_change_sign16 swap_bytes_change_sign16_be
#define linear8_to_linear16 linear8_to_linear16_be
+#define ulinear8_to_linear16 ulinear8_to_linear16_be
+#define linear8_to_linear16_mts linear8_to_linear16_be_mts
+#define ulinear8_to_linear16_mts ulinear8_to_linear16_be_mts
+#define change_sign16_mts change_sign16_be_mts
+#define change_sign16_swap_bytes_mts change_sign16_swap_bytes_be_mts
#endif
diff --git a/sys/dev/mulaw.c b/sys/dev/mulaw.c
index d34f0294de8..e049f3e571b 100644
--- a/sys/dev/mulaw.c
+++ b/sys/dev/mulaw.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mulaw.c,v 1.7 2001/05/01 01:54:43 aaron Exp $ */
+/* $OpenBSD: mulaw.c,v 1.8 2001/12/31 04:14:00 mickey Exp $ */
/* $NetBSD: mulaw.c,v 1.15 2001/01/18 20:28:20 jdolecek Exp $ */
/*
@@ -491,3 +491,87 @@ slinear8_to_alaw(v, p, cc)
++p;
}
}
+
+/*
+ * 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;
+{
+ u_char *q = p;
+
+ p += cc;
+ q += cc * 4;
+ while (--cc >= 0) {
+ --p;
+ q -= 4;
+ q[1] = q[3] = mulawtolin16[*p][0];
+ q[0] = q[2] = mulawtolin16[*p][1];
+ }
+}
+
+/*
+ * 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;
+{
+ u_char *q = p;
+
+ p += cc;
+ q += cc * 4;
+ while (--cc >= 0) {
+ --p;
+ q -= 4;
+ q[0] = q[2] = mulawtolin16[*p][0];
+ q[1] = q[3] = mulawtolin16[*p][1];
+ }
+}
+
+/*
+ * 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;
+{
+ u_char *q = p;
+
+ p += cc;
+ q += cc * 4;
+ while (--cc >= 0) {
+ --p;
+ q -= 4;
+ q[1] = q[3] = alawtolin16[*p][0] ^ 0x80;
+ q[0] = q[2] = alawtolin16[*p][1];
+ }
+}
+
+/*
+ * 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;
+{
+ u_char *q = p;
+
+ p += cc;
+ q += cc * 4;
+ while (--cc >= 0) {
+ --p;
+ q -= 4;
+ q[0] = q[2] = alawtolin16[*p][0] ^ 0x80;
+ q[1] = q[3] = alawtolin16[*p][1];
+ }
+}
diff --git a/sys/dev/mulaw.h b/sys/dev/mulaw.h
index b8ae3892a23..968e939e4b5 100644
--- a/sys/dev/mulaw.h
+++ b/sys/dev/mulaw.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mulaw.h,v 1.6 2001/05/01 01:49:48 aaron Exp $ */
+/* $OpenBSD: mulaw.h,v 1.7 2001/12/31 04:14:00 mickey Exp $ */
/* $NetBSD: mulaw.h,v 1.11 1999/11/01 18:12:19 augustss Exp $ */
/*-
@@ -37,9 +37,13 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
+/* *_mts versions convert mono to stereo, in addition */
+
/* Convert 8-bit mu-law to 16 bit unsigned linear. */
extern void mulaw_to_ulinear16_le __P((void *, u_char *buf, int cnt));
+extern void mulaw_to_ulinear16_le_mts __P((void *, u_char *buf, int cnt));
extern void mulaw_to_ulinear16_be __P((void *, u_char *buf, int cnt));
+extern void mulaw_to_ulinear16_be_mts __P((void *, u_char *buf, int cnt));
/* Convert 8-bit mu-law to 16 bit signed linear. */
extern void mulaw_to_slinear16_le __P((void *, u_char *buf, int cnt));
extern void mulaw_to_slinear16_be __P((void *, u_char *buf, int cnt));
@@ -54,7 +58,9 @@ extern void alaw_to_ulinear16_le __P((void *, u_char *buf, int cnt));
extern void alaw_to_ulinear16_be __P((void *, u_char *buf, int cnt));
/* Convert 8-bit a-law to 16 bit signed linear. */
extern void alaw_to_slinear16_le __P((void *, u_char *buf, int cnt));
+extern void alaw_to_slinear16_le_mts __P((void *, u_char *buf, int cnt));
extern void alaw_to_slinear16_be __P((void *, u_char *buf, int cnt));
+extern void alaw_to_slinear16_be_mts __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));
@@ -67,10 +73,14 @@ extern void slinear8_to_alaw __P((void *, u_char *buf, int cnt));
#define mulaw_to_ulinear16 mulaw_to_slinear16_le
#define alaw_to_ulinear16 alaw_to_ulinear16_le
#define mulaw_to_slinear16 mulaw_to_ulinear16_le
+#define mulaw_to_slinear16_mts mulaw_to_ulinear16_le_mts
#define alaw_to_slinear16 alaw_to_slinear16_le
+#define alaw_to_slinear16_mts alaw_to_slinear16_le_mts
#else
#define mulaw_to_ulinear16 mulaw_to_slinear16_be
#define alaw_to_ulinear16 alaw_to_ulinear16_be
#define mulaw_to_slinear16 mulaw_to_ulinear16_be
+#define mulaw_to_slinear16_mts mulaw_to_ulinear16_be_mts
#define alaw_to_slinear16 alaw_to_slinear16_be
+#define alaw_to_slinear16_mts alaw_to_slinear16_be_mts
#endif