Add Alaw encoding emulation.
This commit is contained in:
parent
1616170859
commit
1bd32f9cad
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: sbdsp.c,v 1.54 1997/05/27 23:37:53 augustss Exp $ */
|
||||
/* $NetBSD: sbdsp.c,v 1.55 1997/05/28 00:07:49 augustss Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1991-1993 Regents of the University of California.
|
||||
|
@ -416,6 +416,12 @@ sbdsp_query_encoding(addr, fp)
|
|||
fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
|
||||
return 0;
|
||||
case 2:
|
||||
strcpy(fp->name, AudioEalaw);
|
||||
fp->encoding = AUDIO_ENCODING_ALAW;
|
||||
fp->precision = 8;
|
||||
fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
|
||||
return 0;
|
||||
case 3:
|
||||
strcpy(fp->name, AudioElinear);
|
||||
fp->encoding = AUDIO_ENCODING_LINEAR;
|
||||
fp->precision = 8;
|
||||
|
@ -426,25 +432,25 @@ sbdsp_query_encoding(addr, fp)
|
|||
return EINVAL;
|
||||
|
||||
switch(fp->index) {
|
||||
case 3:
|
||||
case 4:
|
||||
strcpy(fp->name, AudioElinear_le);
|
||||
fp->encoding = AUDIO_ENCODING_LINEAR_LE;
|
||||
fp->precision = 16;
|
||||
fp->flags = 0;
|
||||
return 0;
|
||||
case 4:
|
||||
case 5:
|
||||
strcpy(fp->name, AudioEulinear_le);
|
||||
fp->encoding = AUDIO_ENCODING_ULINEAR_LE;
|
||||
fp->precision = 16;
|
||||
fp->flags = emul;
|
||||
return 0;
|
||||
case 5:
|
||||
case 6:
|
||||
strcpy(fp->name, AudioElinear_be);
|
||||
fp->encoding = AUDIO_ENCODING_LINEAR_BE;
|
||||
fp->precision = 16;
|
||||
fp->flags = AUDIO_ENCODINGFLAG_EMULATED;
|
||||
return 0;
|
||||
case 6:
|
||||
case 7:
|
||||
strcpy(fp->name, AudioEulinear_be);
|
||||
fp->encoding = AUDIO_ENCODING_ULINEAR_BE;
|
||||
fp->precision = 16;
|
||||
|
@ -501,6 +507,11 @@ sbdsp_set_params(addr, mode, p, q)
|
|||
mulaw_to_ulinear8 : ulinear8_to_mulaw;
|
||||
bmode = 0;
|
||||
break;
|
||||
case AUDIO_ENCODING_ALAW:
|
||||
swcode = mode == AUMODE_PLAY ?
|
||||
alaw_to_ulinear8 : ulinear8_to_alaw;
|
||||
bmode = 0;
|
||||
break;
|
||||
default:
|
||||
return EINVAL;
|
||||
}
|
||||
|
@ -524,6 +535,10 @@ sbdsp_set_params(addr, mode, p, q)
|
|||
swcode = mode == AUMODE_PLAY ?
|
||||
mulaw_to_ulinear8 : ulinear8_to_mulaw;
|
||||
break;
|
||||
case AUDIO_ENCODING_ALAW:
|
||||
swcode = mode == AUMODE_PLAY ?
|
||||
alaw_to_ulinear8 : ulinear8_to_alaw;
|
||||
break;
|
||||
default:
|
||||
return EINVAL;
|
||||
}
|
||||
|
@ -540,6 +555,10 @@ sbdsp_set_params(addr, mode, p, q)
|
|||
swcode = mode == AUMODE_PLAY ?
|
||||
mulaw_to_ulinear8 : ulinear8_to_mulaw;
|
||||
break;
|
||||
case AUDIO_ENCODING_ALAW:
|
||||
swcode = mode == AUMODE_PLAY ?
|
||||
alaw_to_ulinear8 : ulinear8_to_alaw;
|
||||
break;
|
||||
default:
|
||||
return EINVAL;
|
||||
}
|
||||
|
|
|
@ -107,6 +107,76 @@ static u_char lintomulaw[256] = {
|
|||
129, 129, 129, 129, 128, 128, 128, 128,
|
||||
};
|
||||
|
||||
static u_char alawtolin[256] = {
|
||||
107, 108, 105, 106, 111, 112, 109, 110,
|
||||
99, 100, 97, 98, 103, 104, 101, 102,
|
||||
118, 118, 117, 117, 120, 120, 119, 119,
|
||||
114, 114, 113, 113, 116, 116, 115, 115,
|
||||
42, 46, 34, 38, 58, 62, 50, 54,
|
||||
10, 14, 2, 6, 26, 30, 18, 22,
|
||||
85, 87, 81, 83, 93, 95, 89, 91,
|
||||
69, 71, 65, 67, 77, 79, 73, 75,
|
||||
127, 127, 127, 127, 127, 127, 127, 127,
|
||||
127, 127, 127, 127, 127, 127, 127, 127,
|
||||
128, 128, 128, 128, 128, 128, 128, 128,
|
||||
128, 128, 128, 128, 128, 128, 128, 128,
|
||||
123, 123, 123, 123, 124, 124, 124, 124,
|
||||
121, 121, 121, 121, 122, 122, 122, 122,
|
||||
126, 126, 126, 126, 126, 126, 126, 126,
|
||||
125, 125, 125, 125, 125, 125, 125, 125,
|
||||
149, 148, 151, 150, 145, 144, 147, 146,
|
||||
157, 156, 159, 158, 153, 152, 155, 154,
|
||||
138, 138, 139, 139, 136, 136, 137, 137,
|
||||
142, 142, 143, 143, 140, 140, 141, 141,
|
||||
214, 210, 222, 218, 198, 194, 206, 202,
|
||||
246, 242, 254, 250, 230, 226, 238, 234,
|
||||
171, 169, 175, 173, 163, 161, 167, 165,
|
||||
187, 185, 191, 189, 179, 177, 183, 181,
|
||||
129, 129, 129, 129, 129, 129, 129, 129,
|
||||
129, 129, 129, 129, 129, 129, 129, 129,
|
||||
128, 128, 128, 128, 128, 128, 128, 128,
|
||||
128, 128, 128, 128, 128, 128, 128, 128,
|
||||
133, 133, 133, 133, 132, 132, 132, 132,
|
||||
135, 135, 135, 135, 134, 134, 134, 134,
|
||||
130, 130, 130, 130, 130, 130, 130, 130,
|
||||
131, 131, 131, 131, 131, 131, 131, 131,
|
||||
};
|
||||
|
||||
static u_char lintoalaw[256] = {
|
||||
42, 42, 42, 42, 43, 43, 43, 43,
|
||||
40, 40, 40, 40, 41, 41, 41, 41,
|
||||
46, 46, 46, 46, 47, 47, 47, 47,
|
||||
44, 44, 44, 44, 45, 45, 45, 45,
|
||||
34, 34, 34, 34, 35, 35, 35, 35,
|
||||
32, 32, 32, 32, 33, 33, 33, 33,
|
||||
38, 38, 38, 38, 39, 39, 39, 39,
|
||||
36, 36, 36, 36, 37, 37, 37, 37,
|
||||
58, 58, 59, 59, 56, 56, 57, 57,
|
||||
62, 62, 63, 63, 60, 60, 61, 61,
|
||||
50, 50, 51, 51, 48, 48, 49, 49,
|
||||
54, 54, 55, 55, 52, 52, 53, 53,
|
||||
10, 11, 8, 9, 14, 15, 12, 13,
|
||||
2, 3, 0, 1, 6, 7, 4, 5,
|
||||
26, 24, 30, 28, 18, 16, 22, 20,
|
||||
106, 110, 98, 102, 122, 114, 74, 90,
|
||||
213, 197, 245, 253, 229, 225, 237, 233,
|
||||
149, 151, 145, 147, 157, 159, 153, 155,
|
||||
133, 132, 135, 134, 129, 128, 131, 130,
|
||||
141, 140, 143, 142, 137, 136, 139, 138,
|
||||
181, 181, 180, 180, 183, 183, 182, 182,
|
||||
177, 177, 176, 176, 179, 179, 178, 178,
|
||||
189, 189, 188, 188, 191, 191, 190, 190,
|
||||
185, 185, 184, 184, 187, 187, 186, 186,
|
||||
165, 165, 165, 165, 164, 164, 164, 164,
|
||||
167, 167, 167, 167, 166, 166, 166, 166,
|
||||
161, 161, 161, 161, 160, 160, 160, 160,
|
||||
163, 163, 163, 163, 162, 162, 162, 162,
|
||||
173, 173, 173, 173, 172, 172, 172, 172,
|
||||
175, 175, 175, 175, 174, 174, 174, 174,
|
||||
169, 169, 169, 169, 168, 168, 168, 168,
|
||||
171, 171, 171, 171, 170, 170, 170, 170,
|
||||
};
|
||||
|
||||
void
|
||||
mulaw_to_ulinear8(v, p, cc)
|
||||
void *v;
|
||||
|
@ -131,6 +201,30 @@ ulinear8_to_mulaw(v, p, cc)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
alaw_to_ulinear8(v, p, cc)
|
||||
void *v;
|
||||
u_char *p;
|
||||
int cc;
|
||||
{
|
||||
while (--cc >= 0) {
|
||||
*p = alawtolin[*p];
|
||||
++p;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ulinear8_to_alaw(v, p, cc)
|
||||
void *v;
|
||||
u_char *p;
|
||||
int cc;
|
||||
{
|
||||
while (--cc >= 0) {
|
||||
*p = lintoalaw[*p];
|
||||
++p;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
change_sign8(v, p, cc)
|
||||
void *v;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: mulaw.h,v 1.5 1997/05/23 21:20:02 augustss Exp $ */
|
||||
/* $NetBSD: mulaw.h,v 1.6 1997/05/28 00:07:47 augustss Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1996 The NetBSD Foundation, Inc.
|
||||
|
@ -39,6 +39,9 @@
|
|||
/* 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 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 between signed and unsigned. */
|
||||
extern void change_sign8 __P((void *, u_char *buf, int cnt));
|
||||
extern void change_sign16 __P((void *, u_char *buf, int cnt));
|
||||
|
|
Loading…
Reference in New Issue