From 9609b6d4441f0f950da1655f5f1a6817463c3563 Mon Sep 17 00:00:00 2001 From: Christopher Pascoe Date: Thu, 14 Apr 2005 01:24:21 +0000 Subject: Correct signed/unsigned mismatches in compatibility macros and add mono-to-stereo variants for mulaw_to_slinear16 ok dlg@ jason@ mickey@ --- sys/dev/mulaw.c | 32 +++++++++++++++++++++++++++++++- sys/dev/mulaw.h | 16 +++++++++------- 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 $ */ /* @@ -313,6 +313,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) { @@ -328,6 +343,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) { 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 -- cgit v1.2.3