📄 sp_enc.h
字号:
/*************************************************************************/
/* */
/* Copyright (c) 2000-2004 Linuos Design */
/* 领驰设计中心 版权所有 2000-2004 */
/* */
/* PROPRIETARY RIGHTS of Linuos Design are involved in the subject */
/* matter of this material. All manufacturing, reproduction, use, and */
/* sales rights pertaining to this subject matter are governed by the */
/* license agreement. The recipient of this software implicitly accepts */
/* the terms of the license. */
/* 本软件文档资料是领驰设计中心的资产,任何人士阅读和使用本资料必须获得 */
/* 相应的书面授权,承担保密责任和接受相应的法律约束. */
/* */
/*************************************************************************/
/*
* ===================================================================
* TS 26.104
* REL-5 V5.4.0 2004-03
* REL-6 V6.1.0 2004-03
* 3GPP AMR Floating-point Speech Codec
* ===================================================================
*
*/
/*
* sp_enc.h
*
*
* Project:
* AMR Floating-Point Codec
*
* Contains:
* Defines interface to AMR encoder
*
*/
#ifndef _SP_ENC_H
#define _SP_ENC_H
/*
* include files
*/
//#include "typedef.h"
#include "rom_enc.h"
#define ABSTOR( x ) ( ( INT32 )( ( (x)>0 ) ? (x) : -(x) ) )
#define LABSTOR( x ) ( ( INT32 )( ( (x)>0 ) ? (x) : -(x) ) )
/*
* Definition of structures used in encoding process
*/
typedef struct
{
float y2;
float y1;
float x0;
float x1;
}Pre_ProcessState;
typedef struct
{
float bckr_est[NB_SUBBDS_VAD]; /* background noise estimate */
float ave_level[NB_SUBBDS_VAD];
/* averaged input components for stationary estimation */
float old_level[NB_SUBBDS_VAD]; /* input levels of the previous frame */
float sub_level[NB_SUBBDS_VAD];
/* input levels calculated at the end of a frame (lookahead) */
float a_data5[3][2]; /* memory for the filter bank */
float a_data3[5]; /* memory for the filter bank */
float best_corr_hp; /* FIP filtered value */
/* counts length of a speech burst incl HO addition */
float corr_hp_fast; /* filtered value */
INT32 vadreg; /* flags for intermediate VAD decisions */
INT32 pitch; /* flags for pitch detection */
INT32 oldlag_count;
INT32 oldlag; /* variables for pitch detection */
INT32 complex_high; /* flags for complex detection */
INT32 complex_low; /* flags for complex detection */
INT32 complex_warning; /* complex background warning */
INT32 tone; /* flags for tone detection */
INT16 burst_count; /* counts length of a speech burst */
INT16 hang_count; /* hangover counter */
INT16 stat_count; /* stationary counter */
INT16 complex_hang_count; /* complex hangover counter, used by VAD */
INT16 complex_hang_timer; /* hangover initiator, used by CAD */
INT16 speech_vad_decision; /* final decision */
INT16 sp_burst_count;
}vadState;
//#endif
#define DTX_HIST_SIZE 8
#define DTX_ELAPSED_FRAMES_THRESH (24 + 7 -1)
#define DTX_HANG_CONST 7 /* yields eight frames of SP HANGOVER */
typedef struct
{
float lsp_hist[LP_ORDER * DTX_HIST_SIZE];
float log_en_hist[DTX_HIST_SIZE];
INT32 init_lsf_vq_index;
INT16 hist_ptr;
INT16 log_en_index;
INT16 lsp_index[3];
/* DTX handler stuff */
INT16 dtxHangoverCount;
INT16 decAnaElapsedCount;
}dtx_encState;
typedef struct
{
/* gain history */
float gp[AVG_PITGAN];
/* counters */
INT16 count;
}tonStabState;
typedef struct
{
INT32 past_qua_en[4];
/* normal MA predictor memory, (contains 20*log10(qua_err)) */
}gc_predState;
typedef struct
{
float prev_alpha; /* previous adaptor output, */
float prev_gc; /* previous code gain, */
float ltpg_mem[LTPG_MEM_SIZE]; /* LTP coding gain history, */
INT16 onset; /* onset state, */
/* (ltpg_mem[0] not used for history) */
}gain_adaptState;
typedef struct
{
float sf0_target_en;
float sf0_coeff[5];
INT32 sf0_gcode0_exp;
INT32 sf0_gcode0_fra;
INT16 *gain_idx_ptr;
gc_predState gc_predSt;
gc_predState gc_predUncSt;
gain_adaptState adaptSt;
}gainQuantState;
typedef struct
{
INT32 T0_prev_subframe; /* integer pitch lag of previous sub-frame */
}Pitch_frState;
typedef struct
{
Pitch_frState pitchSt;
}clLtpState;
typedef struct
{
float ada_w;
INT32 old_T0_med;
INT16 wght_flg;
}pitchOLWghtState;
typedef struct
{
float past_rq[LP_ORDER]; /* Past quantized prediction error */
}Q_plsfState;
typedef struct
{
/* Past LSPs */
float lsp_old[LP_ORDER];
float lsp_old_q[LP_ORDER];
/* Quantization state */
Q_plsfState qSt;
}lspState;
typedef struct
{
float old_A[LP_ORDER + 1]; /* Last A(z) for case of unstable filter */
}LevinsonState;
typedef struct
{
LevinsonState LevinsonSt;
}lpcState;
typedef struct
{
/* Speech vector */
float old_speech[SPCH_BUF_SIZE];
float *speech;
float *p_window;
float *p_window_12k2;
float *new_speech; /* Global variable */
/* Weight speech vector */
float old_wsp[FRAME_SIZE + PIT_MAX];
float *wsp;
/* OL LTP states */
INT32 old_lags[5];
float ol_gain_flg[2];
/* Excitation vector */
float old_exc[FRAME_SIZE + PIT_MAX + INTERPOL_LEN];
float *exc;
/* Zero vector */
float ai_zero[SUBFRM_SIZE + LP_ORDER_PLUS];
float *zero;
/* Impulse response vector */
float *h1;
float hvec[SUBFRM_SIZE * 2];
/* Substates */
lpcState lpcSt;
lspState lspSt;
clLtpState clLtpSt;
gainQuantState gainQuantSt;
pitchOLWghtState pitchOLWghtSt;
tonStabState tonStabSt;
vadState vadSt;
INT32 dtx;
dtx_encState dtxEncSt;
/* Filter's memory */
float mem_syn[LP_ORDER];
float mem_w0[LP_ORDER];
float mem_w[LP_ORDER];
float mem_err[LP_ORDER + SUBFRM_SIZE];
float *error;
float sharp;
}cod_amrState;
typedef struct
{
cod_amrState cod_amr_state;
Pre_ProcessState pre_state;
INT32 dtx;
}Speech_Encode_FrameState;
/*
* definition of modes for encoder
*/
enum Mode { MR475 = 0,
MR515,
MR59,
MR67,
MR74,
MR795,
MR102,
MR122,
MRDTX
};
/*
* Function prototypes
*/
/*
* initialize one instance of the speech encoder
* Stores pointer to filter status struct in *st. This pointer has to
* be passed to Speech_Encode_Frame in each call.
* returns 0 on success
*/
void *Speech_Encode_Frame_init (INT32 dtx);
/*
* reset speech encoder (i.e. set state memory to zero)
* returns 0 on success
*/
INT32 Speech_Encode_Frame_reset(void *st, INT32 dtx);
/*
* de-initialize speech encoder (i.e. mcFree status struct)
* stores NULL in *st
*/
//void Speech_Encode_Frame_exit (void **st);
/*
* Encodes one speech frame
* Returns analysis parameters
*/
void Speech_Encode_Frame (void *st, enum Mode mode, INT16 *newSpeech,
INT16 *prm, enum Mode *usedMode);
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -