50 #if !defined(_SPANDSP_G711_H_)
51 #define _SPANDSP_G711_H_
54 #define G711_ALAW_AMI_MASK 0x55
58 #define G711_ALAW_IDLE_OCTET (0x80 ^ G711_ALAW_AMI_MASK)
60 #define G711_ULAW_IDLE_OCTET 0xFF
73 #if defined(__cplusplus)
118 #define G711_ULAW_BIAS 0x84
124 static __inline__ uint8_t linear_to_ulaw(
int linear)
142 seg = top_bit(linear | 0xFF) - 7;
145 u_val = (uint8_t) (0x7F ^ mask);
150 u_val = (uint8_t) (((seg << 4) | ((linear >> (seg + 3)) & 0xF)) ^ mask);
152 #if defined(G711_ULAW_ZEROTRAP)
165 static __inline__ int16_t ulaw_to_linear(uint8_t ulaw)
175 t = (((ulaw & 0x0F) << 3) +
G711_ULAW_BIAS) << (((
int) ulaw & 0x70) >> 4);
202 static __inline__ uint8_t linear_to_alaw(
int linear)
217 linear = -linear - 1;
221 seg = top_bit(linear | 0xFF) - 7;
224 a_val = (uint8_t) (0x7F ^ mask);
229 a_val = (uint8_t) (((seg << 4) | ((linear >> ((seg) ? (seg + 3) : 4)) & 0x0F)) ^ mask);
239 static __inline__ int16_t alaw_to_linear(uint8_t alaw)
245 i = ((alaw & 0x0F) << 4);
246 seg = (((int) alaw & 0x70) >> 4);
248 i = (i + 0x108) << (seg - 1);
251 return (int16_t) ((alaw & 0x80) ? i : -i);
276 const uint8_t g711_data[],
300 const uint8_t g711_in[],
319 #if defined(__cplusplus)
#define G711_ALAW_AMI_MASK
Definition: g711.h:54
uint8_t alaw_to_ulaw(uint8_t alaw)
Transcode from A-law to u-law, using the procedure defined in G.711.
Definition: g711.c:87
#define G711_ULAW_BIAS
Definition: g711.h:118
uint8_t ulaw_to_alaw(uint8_t ulaw)
Transcode from u-law to A-law, using the procedure defined in G.711.
Definition: g711.c:93
int g711_transcode(g711_state_t *s, uint8_t g711_out[], const uint8_t g711_in[], int g711_bytes)
Transcode between u-law and A-law.
Definition: g711.c:147
g711_state_t * g711_init(g711_state_t *s, int mode)
Definition: g711.c:171
int g711_encode(g711_state_t *s, uint8_t g711_data[], const int16_t amp[], int len)
Encode from linear to u-law or A-law.
Definition: g711.c:123
int g711_decode(g711_state_t *s, int16_t amp[], const uint8_t g711_data[], int g711_bytes)
Decode from u-law or A-law to linear.
Definition: g711.c:99
int g711_release(g711_state_t *s)
Definition: g711.c:183
int g711_free(g711_state_t *s)
Definition: g711.c:189
Definition: private/g711.h:33
int mode
Definition: private/g711.h:35