spandsp 0.0.6

g711.h File Reference

Go to the source code of this file.

## Macros
#define | G711_ALAW_IDLE_OCTET 0x5D
#define | G711_ULAW_IDLE_OCTET 0xFF
#define | G711_ULAW_BIAS 0x84
#define | G711_ALAW_AMI_MASK 0x55

## Typedefs
typedef struct g711_state_s | g711_state_t

## Enumerations
enum | { G711_ALAW = 0 , G711_ULAW }

## Functions
uint8_t | alaw_to_ulaw (uint8_t alaw)
| Transcode from A-law to u-law, using the procedure defined in G.711.
uint8_t | ulaw_to_alaw (uint8_t ulaw)
| Transcode from u-law to A-law, using the procedure defined in G.711.
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.
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.
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.
g711_state_t * | g711_init (g711_state_t *s, int mode)
int | g711_release (g711_state_t *s)
int | g711_free (g711_state_t *s)

## Macro Definition Documentation

## ◆ G711_ALAW_AMI_MASK

#define G711_ALAW_AMI_MASK 0x55

The A-law alternate mark inversion mask

## ◆ G711_ALAW_IDLE_OCTET

#define G711_ALAW_IDLE_OCTET 0x5D

Idle value for A-law channels

## ◆ G711_ULAW_BIAS

#define G711_ULAW_BIAS 0x84

Bias for u-law encoding from linear.

## ◆ G711_ULAW_IDLE_OCTET

#define G711_ULAW_IDLE_OCTET 0xFF

Idle value for u-law channels

## Typedef Documentation

## ◆ g711_state_t

typedef struct g711_state_s g711_state_t

G.711 state

## Function Documentation

## ◆ alaw_to_ulaw()

uint8_t alaw_to_ulaw | ( | uint8_t | alaw | ) |

Transcode from A-law to u-law, using the procedure defined in G.711.

Parameters

  alaw | The A-law sample to transcode.

Returns
  The best matching u-law value.

## ◆ g711_decode()

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.

Parameters

  s | The G.711 context.
  amp | The linear audio buffer.
  g711_data | The G.711 data.
  g711_bytes | The number of G.711 samples to decode.

Returns
  The number of samples of linear audio produced.

References g711_state_s::mode.

## ◆ g711_encode()

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.

Parameters

  s | The G.711 context.
  g711_data | The G.711 data.
  amp | The linear audio buffer.
  len | The number of samples to encode.

Returns
  The number of G.711 samples produced.

References g711_state_s::mode.

## ◆ g711_free()

int g711_free | ( | g711_state_t * | s | ) |

Free a G.711 encode or decode context.

Parameters

  s | The G.711 context.

Returns
  0 for OK.

## ◆ g711_init()

g711_state_t * g711_init | ( | g711_state_t * | s,
|  | int | mode )

Initialise a G.711 encode or decode context.

Parameters

  s | The G.711 context.
  mode | The G.711 mode.

Returns
  A pointer to the G.711 context, or NULL for error.

References g711_state_s::mode.

## ◆ g711_release()

int g711_release | ( | g711_state_t * | s | ) |

Release a G.711 encode or decode context.

Parameters

  s | The G.711 context.

Returns
  0 for OK.

## ◆ g711_transcode()

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.

Parameters

  s | The G.711 context.
  g711_out | The resulting G.711 data.
  g711_in | The original G.711 data.
  g711_bytes | The number of G.711 samples to transcode.

Returns
  The number of G.711 samples produced.

References g711_state_s::mode.

## ◆ ulaw_to_alaw()

uint8_t ulaw_to_alaw | ( | uint8_t | ulaw | ) |

Transcode from u-law to A-law, using the procedure defined in G.711.

Parameters

  ulaw | The u-law sample to transcode.

Returns
  The best matching A-law value.