|
|
@ -42,21 +42,17 @@ static inline unsigned char linear2alaw (short int linear)
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
pcm_val = linear;
|
|
|
|
pcm_val = linear;
|
|
|
|
if (pcm_val >= 0)
|
|
|
|
if (pcm_val >= 0) {
|
|
|
|
{
|
|
|
|
|
|
|
|
/* Sign (7th) bit = 1 */
|
|
|
|
/* Sign (7th) bit = 1 */
|
|
|
|
mask = AMI_MASK | 0x80;
|
|
|
|
mask = AMI_MASK | 0x80;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
/* Sign bit = 0 */
|
|
|
|
/* Sign bit = 0 */
|
|
|
|
mask = AMI_MASK;
|
|
|
|
mask = AMI_MASK;
|
|
|
|
pcm_val = -pcm_val;
|
|
|
|
pcm_val = -pcm_val;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Convert the scaled magnitude to segment number. */
|
|
|
|
/* Convert the scaled magnitude to segment number. */
|
|
|
|
for (seg = 0; seg < 8; seg++)
|
|
|
|
for (seg = 0; seg < 8; seg++) {
|
|
|
|
{
|
|
|
|
|
|
|
|
if (pcm_val <= seg_end[seg])
|
|
|
|
if (pcm_val <= seg_end[seg])
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -87,13 +83,11 @@ void ast_alaw_init(void)
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Set up mu-law conversion table
|
|
|
|
* Set up mu-law conversion table
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
for(i = 0;i < 256;i++)
|
|
|
|
for (i = 0; i < 256; i++) {
|
|
|
|
{
|
|
|
|
|
|
|
|
__ast_alaw[i] = alaw2linear(i);
|
|
|
|
__ast_alaw[i] = alaw2linear(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* set up the reverse (mu-law) conversion table */
|
|
|
|
/* set up the reverse (mu-law) conversion table */
|
|
|
|
for(i = -32768; i < 32768; i++)
|
|
|
|
for (i = -32768; i < 32768; i++) {
|
|
|
|
{
|
|
|
|
|
|
|
|
__ast_lin2a[((unsigned short)i) >> 3] = linear2alaw(i);
|
|
|
|
__ast_lin2a[((unsigned short)i) >> 3] = linear2alaw(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|