50 #if !defined(_SPANDSP_G711_H_) 51 #define _SPANDSP_G711_H_ 55 #define G711_ALAW_IDLE_OCTET 0x5D 57 #define G711_ULAW_IDLE_OCTET 0xFF 70 #if defined(__cplusplus) 115 #define G711_ULAW_BIAS 0x84 121 static __inline__ uint8_t linear_to_ulaw(
int linear)
139 seg = top_bit(linear | 0xFF) - 7;
146 u_val = (uint8_t) (0x7F ^ mask);
148 u_val = (uint8_t) (((seg << 4) | ((linear >> (seg + 3)) & 0xF)) ^ mask);
149 #if defined(G711_ULAW_ZEROTRAP) 162 static __inline__ int16_t ulaw_to_linear(uint8_t ulaw)
172 t = (((ulaw & 0x0F) << 3) +
G711_ULAW_BIAS) << (((
int) ulaw & 0x70) >> 4);
196 #define G711_ALAW_AMI_MASK 0x55 202 static __inline__ uint8_t linear_to_alaw(
int linear)
216 linear = -linear - 1;
220 seg = top_bit(linear | 0xFF) - 7;
226 return (uint8_t) (0x7F ^ mask);
229 return (uint8_t) (0x00 ^ mask);
232 return (uint8_t) (((seg << 4) | ((linear >> ((seg) ? (seg + 3) : 4)) & 0x0F)) ^ mask);
240 static __inline__ int16_t alaw_to_linear(uint8_t alaw)
246 i = ((alaw & 0x0F) << 4);
247 seg = (((int) alaw & 0x70) >> 4);
249 i = (i + 0x108) << (seg - 1);
252 return (int16_t) ((alaw & 0x80) ? i : -i);
277 const uint8_t g711_data[],
301 const uint8_t g711_in[],
320 #if defined(__cplusplus) 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:92
int g711_release(g711_state_t *s)
Definition: g711.c:182
int g711_free(g711_state_t *s)
Definition: g711.c:188
g711_state_t * g711_init(g711_state_t *s, int mode)
Definition: g711.c:170
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:86
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:122
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:146
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:98
#define G711_ALAW_AMI_MASK
Definition: g711.h:196
Definition: private/g711.h:32
int mode
Definition: private/g711.h:35
#define G711_ULAW_BIAS
Definition: g711.h:115