summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Pascoe <pascoe@cvs.openbsd.org>2005-04-14 01:24:21 +0000
committerChristopher Pascoe <pascoe@cvs.openbsd.org>2005-04-14 01:24:21 +0000
commit9609b6d4441f0f950da1655f5f1a6817463c3563 (patch)
treeaaaa4a1babfe41a0fc854e986623d6dc1447a0b4
parent607cde395c115fec3d17b16dcb246f81b79c490e (diff)
Correct signed/unsigned mismatches in compatibility macros and add
mono-to-stereo variants for mulaw_to_slinear16 ok dlg@ jason@ mickey@
-rw-r--r--sys/dev/mulaw.c32
-rw-r--r--sys/dev/mulaw.h16
2 files changed, 40 insertions, 8 deletions
diff --git a/sys/dev/mulaw.c b/sys/dev/mulaw.c
index 0c7f7dcfce9..11d636643d5 100644
--- a/sys/dev/mulaw.c
+++ b/sys/dev/mulaw.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mulaw.c,v 1.11 2004/02/23 23:59:21 deraadt Exp $ */
+/* $OpenBSD: mulaw.c,v 1.12 2005/04/14 01:24:20 pascoe Exp $ */
/* $NetBSD: mulaw.c,v 1.15 2001/01/18 20:28:20 jdolecek Exp $ */
/*
@@ -314,6 +314,21 @@ mulaw_to_slinear16_le(void *v, u_char *p, int cc)
}
void
+mulaw_to_slinear16_le_mts(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] ^ 0x80;
+ q[0] = q[2] = mulawtolin16[*p][1];
+ }
+}
+
+void
mulaw_to_slinear16_be(void *v, u_char *p, int cc)
{
u_char *q = p;
@@ -329,6 +344,21 @@ mulaw_to_slinear16_be(void *v, u_char *p, int cc)
}
void
+mulaw_to_slinear16_be_mts(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] ^ 0x80;
+ q[1] = q[3] = mulawtolin16[*p][1];
+ }
+}
+
+void
slinear16_to_mulaw_le(void *v, u_char* p, int cc)
{
u_char *q = p + 1; /* q points higher byte. */
diff --git a/sys/dev/mulaw.h b/sys/dev/mulaw.h
index d7e5d2f3234..6d2c2d54828 100644
--- a/sys/dev/mulaw.h
+++ b/sys/dev/mulaw.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mulaw.h,v 1.11 2004/02/23 23:59:21 deraadt Exp $ */
+/* $OpenBSD: mulaw.h,v 1.12 2005/04/14 01:24:20 pascoe Exp $ */
/* $NetBSD: mulaw.h,v 1.11 1999/11/01 18:12:19 augustss Exp $ */
/*-
@@ -46,7 +46,9 @@ 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/from 16 bit signed linear. */
extern void mulaw_to_slinear16_le(void *, u_char *, int);
+extern void mulaw_to_slinear16_le_mts(void *, u_char *, int);
extern void mulaw_to_slinear16_be(void *, u_char *, int);
+extern void mulaw_to_slinear16_be_mts(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 *, int);
@@ -76,17 +78,17 @@ void mulaw_to_alaw(void *, u_char *, int);
/* backwards compat for now */
#if BYTE_ORDER == LITTLE_ENDIAN
-#define mulaw_to_ulinear16 mulaw_to_slinear16_le
+#define mulaw_to_ulinear16 mulaw_to_ulinear16_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 mulaw_to_slinear16 mulaw_to_slinear16_le
+#define mulaw_to_slinear16_mts mulaw_to_slinear16_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 mulaw_to_ulinear16 mulaw_to_ulinear16_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 mulaw_to_slinear16 mulaw_to_slinear16_be
+#define mulaw_to_slinear16_mts mulaw_to_slinear16_be_mts
#define alaw_to_slinear16 alaw_to_slinear16_be
#define alaw_to_slinear16_mts alaw_to_slinear16_be_mts
#endif