spandsp 0.0.6
ima_adpcm.c File Reference
#include <stdlib.h>
#include <inttypes.h>
#include <string.h>
#include "floating_fudge.h"
#include "spandsp/telephony.h"
#include "spandsp/fast_convert.h"
#include "spandsp/saturated.h"
#include "spandsp/ima_adpcm.h"
#include "spandsp/private/ima_adpcm.h"

Macros

#define STEP_MAX   88

Functions

ima_adpcm_state_tima_adpcm_init (ima_adpcm_state_t *s, int variant, int chunk_size)
int ima_adpcm_release (ima_adpcm_state_t *s)
int ima_adpcm_free (ima_adpcm_state_t *s)
int ima_adpcm_decode (ima_adpcm_state_t *s, int16_t amp[], const uint8_t ima_data[], int ima_bytes)
int ima_adpcm_encode (ima_adpcm_state_t *s, uint8_t ima_data[], const int16_t amp[], int len)

Macro Definition Documentation

◆ STEP_MAX

#define STEP_MAX   88

The number of ADPCM step sizes

Function Documentation

◆ ima_adpcm_decode()

int ima_adpcm_decode ( ima_adpcm_state_t * s,
int16_t amp[],
const uint8_t ima_data[],
int ima_bytes )

Decode a buffer of IMA ADPCM data to linear PCM.

Parameters
sThe IMA ADPCM context.
ampThe audio sample buffer.
ima_dataThe IMA ADPCM data
ima_bytesThe number of bytes of IMA ADPCM data
Returns
The number of samples returned.

References ima_adpcm_state_s::chunk_size, IMA_ADPCM_DVI4, IMA_ADPCM_IMA4, IMA_ADPCM_VDVI, ima_adpcm_state_s::last, and ima_adpcm_state_s::step_index.

◆ ima_adpcm_encode()

int ima_adpcm_encode ( ima_adpcm_state_t * s,
uint8_t ima_data[],
const int16_t amp[],
int len )

Encode a buffer of linear PCM data to IMA ADPCM.

Parameters
sThe IMA ADPCM context.
ima_dataThe IMA ADPCM data produced.
ampThe audio sample buffer.
lenThe number of samples in the buffer.
Returns
The number of bytes of IMA ADPCM data produced.

References ima_adpcm_state_s::chunk_size, IMA_ADPCM_DVI4, IMA_ADPCM_IMA4, IMA_ADPCM_VDVI, ima_adpcm_state_s::ima_byte, ima_adpcm_state_s::last, and ima_adpcm_state_s::step_index.

◆ ima_adpcm_free()

int ima_adpcm_free ( ima_adpcm_state_t * s)

Free an IMA ADPCM encode or decode context.

Parameters
sThe IMA ADPCM context.
Returns
0 for OK.

◆ ima_adpcm_init()

ima_adpcm_state_t * ima_adpcm_init ( ima_adpcm_state_t * s,
int variant,
int chunk_size )

Initialise an IMA ADPCM encode or decode context.

Parameters
sThe IMA ADPCM context.
variantIMA_ADPCM_IMA4, IMA_ADPCM_DVI4, or IMA_ADPCM_VDVI.
chunk_sizeThe size of a chunk, in samples. A chunk size of zero sample samples means treat each encode or decode operation as a chunk.
Returns
A pointer to the IMA ADPCM context, or NULL for error.

References ima_adpcm_state_s::chunk_size.

◆ ima_adpcm_release()

int ima_adpcm_release ( ima_adpcm_state_t * s)

Release an IMA ADPCM encode or decode context.

Parameters
sThe IMA ADPCM context.
Returns
0 for OK.