osmo-gmr 0.2.104-2b98
Osmocom GMR-1
|
Files | |
file | ambe.c |
Osmocom GMR-1 AMBE internal API. | |
file | frame.c |
Osmocom GMR-1 AMBE speech parameters to/from frame. | |
file | math.c |
Osmocom GMR-1 AMBE vocoder math functions. | |
file | private.h |
Osmocom GMR-1 AMBE vocoder private header. | |
file | synth.c |
Osmocom GMR-1 AMBE vocoder speech synthesis. | |
file | tables.c |
Osmocom GMR-1 AMBE vocoder tables. | |
file | tone.c |
Osmocom GMR-1 AMBE vocoder tone frames handling. | |
Data Structures | |
struct | ambe_raw_params |
AMBE encoded frame raw parameters. More... | |
struct | ambe_subframe |
AMBE subframe parameters. More... | |
struct | ambe_synth |
AMBE synthesizer state. More... | |
struct | ambe_decoder |
AMBE decoder state. More... | |
struct | tone_desc |
Structure describing a dual-frequency tone. More... | |
Macros | |
#define | AMBE_RATE 8000 |
AMBE sample rate (Hz) | |
#define | M_PIf (3.141592653589793f) |
Value of pi as a float. | |
Enumerations | |
enum | ambe_frame_type { AMBE_SPEECH , AMBE_SILENCE , AMBE_TONE } |
AMBE possible frame types. More... | |
Functions | |
void | ambe_decode_init (struct ambe_decoder *dec) |
Initializes decoder state. More... | |
void | ambe_decode_fini (struct ambe_decoder *dec) |
Release all resources associated with a decoder. More... | |
int | ambe_decode_frame (struct ambe_decoder *dec, int16_t *audio, int N, const uint8_t *frame, int bad) |
Decodes an AMBE frame to audio. More... | |
int | ambe_decode_dtx (struct ambe_decoder *dec, int16_t *audio, int N) |
Generates audio for DTX period. More... | |
void | ambe_frame_unpack_raw (struct ambe_raw_params *rp, const uint8_t *frame) |
Unpack a frame into its raw encoded parameters. More... | |
void | ambe_frame_decode_params (struct ambe_subframe *sf, struct ambe_subframe *sf_prev, struct ambe_raw_params *rp) |
Decodes the speech parameters for both subframes from raw params. More... | |
void | ambe_subframe_expand (struct ambe_subframe *sf) |
Expands the decoded subframe params to prepare for synthesis. More... | |
float | cosf_fast (float angle) |
Fast Cosinus approximation using a simple table. More... | |
float | sinf_fast (float angle) |
Fast Sinus approximation using a simple table. More... | |
void | ambe_fdct (float *out, float *in, int N, int M) |
Forward Discrete Cosine Transform (fDCT) More... | |
void | ambe_idct (float *out, float *in, int N, int M) |
Inverse Discrete Cosine Transform (iDCT) More... | |
void | ambe_fdft_fc (float *out_i, float *out_q, float *in, int N, int M) |
Forward Discrete Fourrier Transform (float->complex) More... | |
void | ambe_idft_cf (float *out, float *in_i, float *in_q, int N, int M) |
Inverse Discret Fourrier Transform (complex->float) More... | |
void | ambe_synth_init (struct ambe_synth *synth) |
Initialized Synthesizer state. More... | |
void | ambe_synth_enhance (struct ambe_synth *synth, struct ambe_subframe *sf) |
Apply the spectral magnitude enhancement on the subframe. More... | |
void | ambe_synth_audio (struct ambe_synth *synth, int16_t *audio, struct ambe_subframe *sf, struct ambe_subframe *sf_prev) |
Generate audio for a given subframe. More... | |
int | ambe_decode_tone (struct ambe_decoder *dec, int16_t *audio, int N, const uint8_t *frame) |
Decodes an AMBE tone frame. More... | |
Variables | |
const uint8_t | ambe_hpg_tbl [48][4] |
Number of harmonics per group for a given L (starts at L=9) | |
const float | ambe_gain_tbl [256][2] |
Gain (subframe 0, subframe 1) | |
const uint16_t | ambe_v_uv_tbl [64] |
V/UV decisions (subframe 0 = low byte. MSBs = low freq) | |
const float | ambe_prba12_tbl [128][2] |
PRBA[1:2]. | |
const float | ambe_prba34_tbl [64][2] |
PRBA[3:4]. | |
const float | ambe_prba57_tbl [128][3] |
PRBA[5:7]. | |
const float | ambe_hoc0_tbl [128][4] |
HOC for 1st frequency block. | |
const float | ambe_hoc1_tbl [64][4] |
HOC for 2nd frequency block. | |
const float | ambe_hoc2_tbl [64][4] |
HOC for 3rd frequency block. | |
const float | ambe_hoc3_tbl [64][4] |
HOC for last frequency block. | |
const float | ambe_sf0_interp_tbl [4] |
Interpolation ratios for subframe 0 magnitude prediction. | |
const float | ambe_sf0_perr14_tbl [64][4] |
Prediction Error [1:4] for subframe 0. | |
const float | ambe_sf0_perr58_tbl [32][4] |
Prediction Error [5:8] for subframe 0. | |
const uint8_t | ambe_hpg_tbl [48][4] |
Number of harmonics per group for a given L (starts at L=9) | |
const float | ambe_gain_tbl [256][2] |
Gain (subframe 0, subframe 1) | |
const uint16_t | ambe_v_uv_tbl [64] |
V/UV decisions (subframe 0 = low byte. MSBs = low freq) More... | |
const float | ambe_prba12_tbl [128][2] |
PRBA[1:2]. | |
const float | ambe_prba34_tbl [64][2] |
PRBA[3:4]. | |
const float | ambe_prba57_tbl [128][3] |
PRBA[5:7]. | |
const float | ambe_hoc0_tbl [128][4] |
HOC for 1st frequency block. | |
const float | ambe_hoc1_tbl [64][4] |
HOC for 2nd frequency block. | |
const float | ambe_hoc2_tbl [64][4] |
HOC for 3rd frequency block. | |
const float | ambe_hoc3_tbl [64][4] |
HOC for last frequency block. | |
const float | ambe_sf0_interp_tbl [4] |
Interpolation ratios for subframe 0 magnitude prediction. More... | |
const float | ambe_sf0_perr14_tbl [64][4] |
Prediction Error [1:4] for subframe 0. | |
const float | ambe_sf0_perr58_tbl [32][4] |
Prediction Error [5:8] for subframe 0. | |
enum ambe_frame_type |
int ambe_decode_dtx | ( | struct ambe_decoder * | dec, |
int16_t * | audio, | ||
int | N | ||
) |
Generates audio for DTX period.
[in] | dec | Decoder state structure |
[out] | audio | Output audio buffer |
[in] | N | number of audio samples to produce (152..168) |
Referenced by gmr1_codec_decode_dtx().
void ambe_decode_fini | ( | struct ambe_decoder * | dec | ) |
Release all resources associated with a decoder.
[in] | dec | Decoder state structure |
Referenced by gmr1_codec_release().
int ambe_decode_frame | ( | struct ambe_decoder * | dec, |
int16_t * | audio, | ||
int | N, | ||
const uint8_t * | frame, | ||
int | bad | ||
) |
Decodes an AMBE frame to audio.
[in] | dec | Decoder state structure |
[out] | audio | Output audio buffer |
[in] | N | number of audio samples to produce (152..168) |
[in] | frame | Frame data (10 bytes = 80 bits) |
[in] | bad | Bad Frame Indicator. Set to 1 if frame is corrupt |
Referenced by gmr1_codec_decode_frame().
void ambe_decode_init | ( | struct ambe_decoder * | dec | ) |
Initializes decoder state.
[in] | dec | Decoder state structure |
References ambe_synth_init(), ambe_subframe::f0, ambe_subframe::L, M_PIf, ambe_decoder::sf_prev, ambe_decoder::synth, and ambe_subframe::w0.
Referenced by gmr1_codec_alloc().
int ambe_decode_tone | ( | struct ambe_decoder * | dec, |
int16_t * | audio, | ||
int | N, | ||
const uint8_t * | frame | ||
) |
Decodes an AMBE tone frame.
[in] | dec | AMBE decoder state |
[out] | audio | Output audio buffer |
[in] | N | number of audio samples to produce (152..168) |
[in] | frame | Frame data (10 bytes = 80 bits). Must be tone frame ! |
void ambe_fdct | ( | float * | out, |
float * | in, | ||
int | N, | ||
int | M | ||
) |
Forward Discrete Cosine Transform (fDCT)
[out] | out | fDCT result buffer (freq domain, M elements) |
[in] | in | fDCT input buffer (time domain, N elements) |
[in] | N | Number of points of the DCT |
[in] | M | Limit to the number of frequency components (M <= N) |
References cosf_fast(), and M_PIf.
void ambe_fdft_fc | ( | float * | out_i, |
float * | out_q, | ||
float * | in, | ||
int | N, | ||
int | M | ||
) |
Forward Discrete Fourrier Transform (float->complex)
[out] | out_i | Real component result buffer (freq domain, N/2+1 elements) |
[out] | out_q | Imag component result buffer (freq domain, N/2+1 elements) |
[in] | in | Input buffer (time domain, M elements) |
[in] | N | Number of points of the DFT |
[in] | M | Limit to to the number of available time domain elements |
Since the input is float, the result is symmetric and so only one side is computed. The output index 0 is DC.
References cosf_fast(), M_PIf, and sinf_fast().
void ambe_frame_decode_params | ( | struct ambe_subframe * | sf, |
struct ambe_subframe * | sf_prev, | ||
struct ambe_raw_params * | rp | ||
) |
Decodes the speech parameters for both subframes from raw params.
[out] | sf | Array of 2 subframes data to fill-in |
[in] | sf_prev | Previous subframe 1 data |
[in] | rp | Encoded frame raw parameters |
References ambe_subframe::f0, ambe_subframe::f0log, and ambe_raw_params::pitch.
void ambe_frame_unpack_raw | ( | struct ambe_raw_params * | rp, |
const uint8_t * | frame | ||
) |
Unpack a frame into its raw encoded parameters.
[out] | rp | Encoded frame raw parameters to unpack into |
[in] | frame | Frame data (10 bytes = 80 bits) |
References ambe_raw_params::pitch.
void ambe_idct | ( | float * | out, |
float * | in, | ||
int | N, | ||
int | M | ||
) |
Inverse Discrete Cosine Transform (iDCT)
[out] | out | iDCT result buffer (time domain, N elements) |
[in] | in | iDCT input buffer (freq domain, M elements) |
[in] | N | Number of points of the DCT |
[in] | M | Limit to the number of frequency components (M <= N) |
References cosf_fast(), and M_PIf.
void ambe_idft_cf | ( | float * | out, |
float * | in_i, | ||
float * | in_q, | ||
int | N, | ||
int | M | ||
) |
Inverse Discret Fourrier Transform (complex->float)
[out] | out | Result buffer (time domain, M |
[in] | in_i | Real component input buffer (freq domain, N/2+1 elements) |
[in] | in_q | Imag component input buffer (freq domain, N/2+1 elements) |
[in] | N | Number of points of the DFT |
[in] | M | Limit to the number of time domain elements to generate |
The input is assumed to be symmetric and so only N/2+1 inputs are needed. DC component must be input index 0.
References cosf_fast(), M_PIf, and sinf_fast().
void ambe_subframe_expand | ( | struct ambe_subframe * | sf | ) |
Expands the decoded subframe params to prepare for synthesis.
[in] | sf | The subframe to expand |
References ambe_subframe::f0, ambe_subframe::L, M_PIf, ambe_subframe::Ml, ambe_subframe::Mlog, ambe_subframe::v_uv, ambe_subframe::Vl, and ambe_subframe::w0.
void ambe_synth_audio | ( | struct ambe_synth * | synth, |
int16_t * | audio, | ||
struct ambe_subframe * | sf, | ||
struct ambe_subframe * | sf_prev | ||
) |
Generate audio for a given subframe.
[in] | synth | Synthesizer state structure |
[out] | audio | Result buffer (80 samples) |
[in] | sf | Expanded subframe data for current subframe |
[in] | sf_prev | Expanded subframe data for prevous subframe |
void ambe_synth_enhance | ( | struct ambe_synth * | synth, |
struct ambe_subframe * | sf | ||
) |
Apply the spectral magnitude enhancement on the subframe.
[in] | synth | Synthesizer state structure |
[in] | sf | Expanded subframe data for subframe to enhance |
References cosf_fast(), ambe_subframe::L, M_PIf, ambe_subframe::Ml, ambe_synth::SE, and ambe_subframe::w0.
void ambe_synth_init | ( | struct ambe_synth * | synth | ) |
Initialized Synthesizer state.
[out] | synth | The structure to reset |
References ambe_synth::u_prev.
Referenced by ambe_decode_init().
float cosf_fast | ( | float | angle | ) |
Fast Cosinus approximation using a simple table.
[in] | angle | The angle value |
References M_PIf.
Referenced by ambe_fdct(), ambe_fdft_fc(), ambe_idct(), ambe_idft_cf(), and ambe_synth_enhance().
float sinf_fast | ( | float | angle | ) |
Fast Sinus approximation using a simple table.
[in] | angle | The angle value |
References M_PIf.
Referenced by ambe_fdft_fc(), and ambe_idft_cf().
const float ambe_sf0_interp_tbl[4] |
Interpolation ratios for subframe 0 magnitude prediction.
const uint16_t ambe_v_uv_tbl[64] |
V/UV decisions (subframe 0 = low byte. MSBs = low freq)