23 #ifndef _ASTERISK_ALAW_H
24 #define _ASTERISK_ALAW_H
32 #define AST_ALAW_BIT_LOSS 4
33 #define AST_ALAW_STEP (1 << AST_ALAW_BIT_LOSS)
34 #define AST_ALAW_TAB_SIZE (32768 / AST_ALAW_STEP + 1)
35 #define AST_ALAW_SIGN_BIT 0x80
36 #define AST_ALAW_AMI_MASK 0x55
40 #ifndef G711_NEW_ALGORITHM
43 extern unsigned char __ast_lin2a[AST_ALAW_TAB_SIZE];
49 #ifndef G711_NEW_ALGORITHM
50 #define AST_LIN2A(a) (__ast_lin2a[((unsigned short)(a)) >> 3])
52 #define AST_LIN2A_LOOKUP(mag) \
53 __ast_lin2a[(mag) >> AST_ALAW_BIT_LOSS]
56 static inline void ast_alaw_get_sign_mag(
short sample,
unsigned *sign,
unsigned *mag)
61 *sign = ((
unsigned short)sample >> 8) & AST_ALAW_SIGN_BIT;
62 #if defined(G711_REDUCED_BRANCHING)
64 unsigned dual_mag = (-sample << 16) | (
unsigned short)sample;
65 *mag = (dual_mag >> (*sign >> 3)) & 0xffffU;
73 *sign ^= AST_ALAW_SIGN_BIT;
76 static inline unsigned char AST_LIN2A(
short sample)
79 ast_alaw_get_sign_mag(sample, &sign, &mag);
80 return (sign | AST_LIN2A_LOOKUP(mag)) ^ AST_ALAW_AMI_MASK;
84 #define AST_ALAW(a) (__ast_alaw[(int)(a)])
unsigned char __ast_lin2a[8192]
converts signed linear to alaw
void ast_alaw_init(void)
To init the alaw to slinear conversion stuff, this needs to be run.