FFmpeg  4.0
Data Structures | Macros | Enumerations | Functions | Variables
g723_1.h File Reference

G.723.1 types, functions and data tables. More...

#include <stdint.h>
#include "libavutil/log.h"

Go to the source code of this file.

Data Structures

struct  G723_1_Subframe
 G723.1 unpacked data subframe. More...
 
struct  PPFParam
 Pitch postfilter parameters. More...
 
struct  HFParam
 Harmonic filter parameters. More...
 
struct  FCBParam
 Optimized fixed codebook excitation parameters. More...
 
struct  G723_1_Context
 

Macros

#define SUBFRAMES   4
 
#define SUBFRAME_LEN   60
 
#define FRAME_LEN   (SUBFRAME_LEN << 2)
 
#define HALF_FRAME_LEN   (FRAME_LEN / 2)
 
#define LPC_FRAME   (HALF_FRAME_LEN + SUBFRAME_LEN)
 
#define LPC_ORDER   10
 
#define LSP_BANDS   3
 
#define LSP_CB_SIZE   256
 
#define PITCH_MIN   18
 
#define PITCH_MAX   (PITCH_MIN + 127)
 
#define PITCH_ORDER   5
 
#define GRID_SIZE   2
 
#define PULSE_MAX   6
 
#define GAIN_LEVELS   24
 
#define COS_TBL_SIZE   512
 
#define MULL2(a, b)   ((((a) >> 16) * (b) * 2) + (((a) & 0xffff) * (b) >> 15))
 Bitexact implementation of 2ab scaled by 1/2^16. More...
 

Enumerations

enum  FrameType {
  ACTIVE_FRAME, SID_FRAME, UNTRANSMITTED_FRAME, INTRA_FRAME = 0,
  INTER_FRAME, SKIP_FRAME, FIRST_FRAME, INNER_FRAME,
  FINAL_FRAME, LINEAR_MODE, FRAME_NB
}
 G723.1 frame types. More...
 
enum  Rate { RATE_6300, RATE_5300 }
 G723.1 rate values. More...
 

Functions

int ff_g723_1_scale_vector (int16_t *dst, const int16_t *vector, int length)
 Scale vector contents based on the largest of their absolutes. More...
 
int ff_g723_1_normalize_bits (int num, int width)
 Calculate the number of left-shifts required for normalizing the input. More...
 
int ff_g723_1_dot_product (const int16_t *a, const int16_t *b, int length)
 
void ff_g723_1_get_residual (int16_t *residual, int16_t *prev_excitation, int lag)
 Get delayed contribution from the previous excitation vector. More...
 
void ff_g723_1_gen_dirac_train (int16_t *buf, int pitch_lag)
 Generate a train of dirac functions with period as pitch lag. More...
 
void ff_g723_1_gen_acb_excitation (int16_t *vector, int16_t *prev_excitation, int pitch_lag, G723_1_Subframe *subfrm, enum Rate cur_rate)
 Generate adaptive codebook excitation. More...
 
void ff_g723_1_lsp_interpolate (int16_t *lpc, int16_t *cur_lsp, int16_t *prev_lsp)
 Quantize LSP frequencies by interpolation and convert them to the corresponding LPC coefficients. More...
 
void ff_g723_1_inverse_quant (int16_t *cur_lsp, int16_t *prev_lsp, uint8_t *lsp_index, int bad_frame)
 Perform inverse quantization of LSP frequencies. More...
 

Variables

static const uint8_t frame_size [4] = { 24, 20, 4, 1 }
 
static const int16_t ppf_gain_weight [2] = {0x1800, 0x2000}
 Postfilter gain weighting factors scaled by 2^15. More...
 
static const int16_t dc_lsp [LPC_ORDER]
 LSP DC component. More...
 
static const int16_t cos_tab [COS_TBL_SIZE+1]
 
static const int16_t lsp_band0 [LSP_CB_SIZE][3]
 LSP VQ tables. More...
 
static const int16_t lsp_band1 [LSP_CB_SIZE][3]
 
static const int16_t lsp_band2 [LSP_CB_SIZE][4]
 
static const int32_t combinatorial_table [PULSE_MAX][SUBFRAME_LEN/GRID_SIZE]
 Used for the coding/decoding of the pulses positions for the MP-MLQ codebook. More...
 
static const int16_t pitch_contrib [340]
 
static const int8_t pulses [4] = {6, 5, 6, 5}
 Number of non-zero pulses in the MP-MLQ excitation. More...
 
static const int32_t max_pos [4] = {593775, 142506, 593775, 142506}
 Size of the MP-MLQ fixed excitation codebooks. More...
 
static const int16_t fixed_cb_gain [GAIN_LEVELS]
 
static const int16_t adaptive_cb_gain85 [85 *20]
 
static const int16_t adaptive_cb_gain170 [170 *20]
 
static const int16_t postfilter_tbl [2][LPC_ORDER]
 0.65^i (Zero part) and 0.75^i (Pole part) scaled by 2^15 More...
 
static const int16_t hamming_window [LPC_FRAME]
 Hamming window coefficients scaled by 2^15. More...
 
static const int16_t binomial_window [LPC_ORDER]
 Binomial window coefficients scaled by 2^15. More...
 
static const int16_t bandwidth_expand [LPC_ORDER]
 0.994^i scaled by 2^15 More...
 
static const int16_t percept_flt_tbl [2][LPC_ORDER]
 0.5^i scaled by 2^15 More...
 
static const int cng_adaptive_cb_lag [4] = { 1, 0, 1, 3 }
 
static const int cng_filt [4] = { 273, 998, 499, 333 }
 
static const int cng_bseg [3] = { 2048, 18432, 231233 }
 

Detailed Description

G.723.1 types, functions and data tables.

Definition in file g723_1.h.

Macro Definition Documentation

◆ SUBFRAMES

#define SUBFRAMES   4

Definition at line 35 of file g723_1.h.

◆ SUBFRAME_LEN

#define SUBFRAME_LEN   60

◆ FRAME_LEN

#define FRAME_LEN   (SUBFRAME_LEN << 2)

◆ HALF_FRAME_LEN

#define HALF_FRAME_LEN   (FRAME_LEN / 2)

Definition at line 38 of file g723_1.h.

Referenced by estimate_pitch(), and g723_1_encode_frame().

◆ LPC_FRAME

#define LPC_FRAME   (HALF_FRAME_LEN + SUBFRAME_LEN)

Definition at line 39 of file g723_1.h.

Referenced by comp_autocorr().

◆ LPC_ORDER

#define LPC_ORDER   10

◆ LSP_BANDS

#define LSP_BANDS   3

Definition at line 41 of file g723_1.h.

◆ LSP_CB_SIZE

#define LSP_CB_SIZE   256

Definition at line 42 of file g723_1.h.

◆ PITCH_MIN

#define PITCH_MIN   18

◆ PITCH_MAX

#define PITCH_MAX   (PITCH_MIN + 127)

◆ PITCH_ORDER

#define PITCH_ORDER   5

◆ GRID_SIZE

#define GRID_SIZE   2

Definition at line 46 of file g723_1.h.

Referenced by gen_fcb_excitation(), and get_fcb_param().

◆ PULSE_MAX

#define PULSE_MAX   6

Definition at line 47 of file g723_1.h.

◆ GAIN_LEVELS

#define GAIN_LEVELS   24

Definition at line 48 of file g723_1.h.

Referenced by get_fcb_param(), pack_bitstream(), and unpack_bitstream().

◆ COS_TBL_SIZE

#define COS_TBL_SIZE   512

Definition at line 49 of file g723_1.h.

Referenced by lpc2lsp().

◆ MULL2

#define MULL2 (   a,
  b 
)    ((((a) >> 16) * (b) * 2) + (((a) & 0xffff) * (b) >> 15))

Bitexact implementation of 2ab scaled by 1/2^16.

Parameters
a32 bit multiplicand
b16 bit multiplier

Definition at line 57 of file g723_1.h.

Referenced by comp_autocorr(), highpass_filter(), levinson_durbin(), and lsp2lpc().

Enumeration Type Documentation

◆ FrameType

enum FrameType

G723.1 frame types.

Enumerator
ACTIVE_FRAME 

Active speech.

SID_FRAME 

Silence Insertion Descriptor frame.

UNTRANSMITTED_FRAME 
INTRA_FRAME 
INTER_FRAME 
SKIP_FRAME 
FIRST_FRAME 
INNER_FRAME 
FINAL_FRAME 
LINEAR_MODE 
FRAME_NB 

Definition at line 63 of file g723_1.h.

◆ Rate

enum Rate

G723.1 rate values.

Enumerator
RATE_6300 
RATE_5300 

Definition at line 72 of file g723_1.h.

Function Documentation

◆ ff_g723_1_scale_vector()

int ff_g723_1_scale_vector ( int16_t *  dst,
const int16_t *  vector,
int  length 
)

Scale vector contents based on the largest of their absolutes.

Definition at line 32 of file g723_1.c.

Referenced by comp_autocorr(), comp_interp_index(), formant_postfilter(), and g723_1_encode_frame().

◆ ff_g723_1_normalize_bits()

int ff_g723_1_normalize_bits ( int  num,
int  width 
)

Calculate the number of left-shifts required for normalizing the input.

Parameters
numinput number
widthwidth of the input, 16 bits(0) / 32 bits(1)

Definition at line 49 of file g723_1.c.

Referenced by acb_search(), comp_autocorr(), comp_harmonic_coeff(), comp_ppf_coeff(), estimate_pitch(), gain_scale(), get_fcb_param(), lpc2lsp(), and lsp_quantize().

◆ ff_g723_1_dot_product()

int ff_g723_1_dot_product ( const int16_t *  a,
const int16_t *  b,
int  length 
)

◆ ff_g723_1_get_residual()

void ff_g723_1_get_residual ( int16_t *  residual,
int16_t *  prev_excitation,
int  lag 
)

Get delayed contribution from the previous excitation vector.

Definition at line 60 of file g723_1.c.

Referenced by acb_search(), and ff_g723_1_gen_acb_excitation().

◆ ff_g723_1_gen_dirac_train()

void ff_g723_1_gen_dirac_train ( int16_t *  buf,
int  pitch_lag 
)

Generate a train of dirac functions with period as pitch lag.

Definition at line 74 of file g723_1.c.

Referenced by fcb_search(), gen_fcb_excitation(), and get_fcb_param().

◆ ff_g723_1_gen_acb_excitation()

void ff_g723_1_gen_acb_excitation ( int16_t *  vector,
int16_t *  prev_excitation,
int  pitch_lag,
G723_1_Subframe subfrm,
enum Rate  cur_rate 
)

Generate adaptive codebook excitation.

Definition at line 86 of file g723_1.c.

Referenced by g723_1_decode_frame(), g723_1_encode_frame(), and generate_noise().

◆ ff_g723_1_lsp_interpolate()

void ff_g723_1_lsp_interpolate ( int16_t *  lpc,
int16_t *  cur_lsp,
int16_t *  prev_lsp 
)

Quantize LSP frequencies by interpolation and convert them to the corresponding LPC coefficients.

Parameters
lpcbuffer for LPC coefficients
cur_lspthe current LSP vector
prev_lspthe previous LSP vector

Definition at line 180 of file g723_1.c.

Referenced by g723_1_decode_frame(), and g723_1_encode_frame().

◆ ff_g723_1_inverse_quant()

void ff_g723_1_inverse_quant ( int16_t *  cur_lsp,
int16_t *  prev_lsp,
uint8_t lsp_index,
int  bad_frame 
)

Perform inverse quantization of LSP frequencies.

Parameters
cur_lspthe current LSP vector
prev_lspthe previous LSP vector
lsp_indexVQ indices
bad_framebad frame flag

Definition at line 201 of file g723_1.c.

Referenced by g723_1_decode_frame(), and g723_1_encode_frame().

Variable Documentation

◆ frame_size

const uint8_t frame_size[4] = { 24, 20, 4, 1 }
static

Definition at line 219 of file g723_1.h.

◆ ppf_gain_weight

const int16_t ppf_gain_weight[2] = {0x1800, 0x2000}
static

Postfilter gain weighting factors scaled by 2^15.

Definition at line 224 of file g723_1.h.

Referenced by comp_ppf_gains().

◆ dc_lsp

const int16_t dc_lsp[LPC_ORDER]
static
Initial value:
= {
0x0c3b,
0x1271,
0x1e0a,
0x2a36,
0x3630,
0x406f,
0x4d28,
0x56f4,
0x638c,
0x6c46
}

LSP DC component.

Definition at line 229 of file g723_1.h.

Referenced by ff_g723_1_inverse_quant(), g723_1_decode_init(), g723_1_encode_init(), and lsp_quantize().

◆ cos_tab

const int16_t cos_tab[COS_TBL_SIZE+1]
static

Definition at line 243 of file g723_1.h.

◆ lsp_band0

const int16_t lsp_band0[LSP_CB_SIZE][3]
static

LSP VQ tables.

Definition at line 314 of file g723_1.h.

Referenced by ff_g723_1_inverse_quant().

◆ lsp_band1

const int16_t lsp_band1[LSP_CB_SIZE][3]
static

Definition at line 403 of file g723_1.h.

Referenced by ff_g723_1_inverse_quant().

◆ lsp_band2

const int16_t lsp_band2[LSP_CB_SIZE][4]
static

Definition at line 492 of file g723_1.h.

Referenced by ff_g723_1_inverse_quant().

◆ combinatorial_table

const int32_t combinatorial_table[PULSE_MAX][SUBFRAME_LEN/GRID_SIZE]
static

Used for the coding/decoding of the pulses positions for the MP-MLQ codebook.

Definition at line 627 of file g723_1.h.

Referenced by gen_fcb_excitation(), and pack_fcb_param().

◆ pitch_contrib

const int16_t pitch_contrib[340]
static

Definition at line 671 of file g723_1.h.

Referenced by gen_fcb_excitation().

◆ pulses

const int8_t pulses[4] = {6, 5, 6, 5}
static

Number of non-zero pulses in the MP-MLQ excitation.

Definition at line 720 of file g723_1.h.

Referenced by celt_pulses2bits(), fcb_search(), gen_fcb_excitation(), generate_noise(), and synth_block_fcb_acb().

◆ max_pos

const int32_t max_pos[4] = {593775, 142506, 593775, 142506}
static

Size of the MP-MLQ fixed excitation codebooks.

Definition at line 725 of file g723_1.h.

Referenced by gen_fcb_excitation().

◆ fixed_cb_gain

const int16_t fixed_cb_gain[GAIN_LEVELS]
static
Initial value:
= {
1, 2, 3, 4, 6, 9, 13, 18,
26, 38, 55, 80, 115, 166, 240, 348,
502, 726, 1050, 1517, 2193, 3170, 4582, 6623,
}

Definition at line 727 of file g723_1.h.

Referenced by g723_1_decode_frame(), gen_fcb_excitation(), and get_fcb_param().

◆ adaptive_cb_gain85

const int16_t adaptive_cb_gain85[85 *20]
static

Definition at line 733 of file g723_1.h.

Referenced by acb_search(), and ff_g723_1_gen_acb_excitation().

◆ adaptive_cb_gain170

const int16_t adaptive_cb_gain170[170 *20]
static

Definition at line 949 of file g723_1.h.

Referenced by acb_search(), and ff_g723_1_gen_acb_excitation().

◆ postfilter_tbl

const int16_t postfilter_tbl[2][LPC_ORDER]
static
Initial value:
= {
{21299, 13844, 8999, 5849, 3802, 2471, 1606, 1044, 679, 441},
{24576, 18432, 13824, 10368, 7776, 5832, 4374, 3281, 2460, 1845}
}

0.65^i (Zero part) and 0.75^i (Pole part) scaled by 2^15

Definition at line 1380 of file g723_1.h.

Referenced by formant_postfilter().

◆ hamming_window

const int16_t hamming_window[LPC_FRAME]
static
Initial value:
= {
2621, 2631, 2659, 2705, 2770, 2853, 2955, 3074, 3212, 3367,
3541, 3731, 3939, 4164, 4405, 4663, 4937, 5226, 5531, 5851,
6186, 6534, 6897, 7273, 7661, 8062, 8475, 8899, 9334, 9780,
10235, 10699, 11172, 11653, 12141, 12636, 13138, 13645, 14157, 14673,
15193, 15716, 16242, 16769, 17298, 17827, 18356, 18884, 19411, 19935,
20457, 20975, 21489, 21999, 22503, 23002, 23494, 23978, 24455, 24924,
25384, 25834, 26274, 26704, 27122, 27529, 27924, 28306, 28675, 29031,
29373, 29700, 30012, 30310, 30592, 30857, 31107, 31340, 31557, 31756,
31938, 32102, 32249, 32377, 32488, 32580, 32654, 32710, 32747, 32766,
32766, 32747, 32710, 32654, 32580, 32488, 32377, 32249, 32102, 31938,
31756, 31557, 31340, 31107, 30857, 30592, 30310, 30012, 29700, 29373,
29031, 28675, 28306, 27924, 27529, 27122, 26704, 26274, 25834, 25384,
24924, 24455, 23978, 23494, 23002, 22503, 21999, 21489, 20975, 20457,
19935, 19411, 18884, 18356, 17827, 17298, 16769, 16242, 15716, 15193,
14673, 14157, 13645, 13138, 12636, 12141, 11653, 11172, 10699, 10235,
9780, 9334, 8899, 8475, 8062, 7661, 7273, 6897, 6534, 6186,
5851, 5531, 5226, 4937, 4663, 4405, 4164, 3939, 3731, 3541,
3367, 3212, 3074, 2955, 2853, 2770, 2705, 2659, 2631, 2621
}

Hamming window coefficients scaled by 2^15.

Definition at line 1390 of file g723_1.h.

Referenced by comp_autocorr().

◆ binomial_window

const int16_t binomial_window[LPC_ORDER]
static
Initial value:
= {
32749, 32695, 32604, 32477, 32315, 32118, 31887, 31622, 31324, 30995
}

Binomial window coefficients scaled by 2^15.

Definition at line 1414 of file g723_1.h.

Referenced by comp_autocorr().

◆ bandwidth_expand

const int16_t bandwidth_expand[LPC_ORDER]
static
Initial value:
= {
32571, 32376, 32182, 31989, 31797, 31606, 31416, 31228, 31040, 30854
}

0.994^i scaled by 2^15

Definition at line 1421 of file g723_1.h.

Referenced by lpc2lsp().

◆ percept_flt_tbl

const int16_t percept_flt_tbl[2][LPC_ORDER]
static
Initial value:
= {
{29491, 26542, 23888, 21499, 19349, 17414, 15673, 14106, 12695, 11425},
{16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32}
}

0.5^i scaled by 2^15

Definition at line 1428 of file g723_1.h.

Referenced by perceptual_filter().

◆ cng_adaptive_cb_lag

const int cng_adaptive_cb_lag[4] = { 1, 0, 1, 3 }
static

Definition at line 1435 of file g723_1.h.

Referenced by generate_noise().

◆ cng_filt

const int cng_filt[4] = { 273, 998, 499, 333 }
static

Definition at line 1437 of file g723_1.h.

Referenced by estimate_sid_gain().

◆ cng_bseg

const int cng_bseg[3] = { 2048, 18432, 231233 }
static

Definition at line 1439 of file g723_1.h.

Referenced by estimate_sid_gain().