www.pudn.com > SMV_Code.rar > const.h
/*=========================================================================*/
/* Each of the companies; Ericsson, Lucent, Mindspeed, Motorola, Nokia, */
/* Nortel Networks, and Qualcomm (hereinafter referred to individually as */
/* “Source” or collectively as “Sources”) do hereby state: */
/* */
/* To the extent to which the Source(s) may legally and freely do so, */
/* the Source(s), upon submission of a Contribution, grant(s) a free, */
/* irrevocable, non-exclusive, license to the Third Generation Partnership */
/* Project 2 (3GPP2) and its Organizational Partners: ARIB, CCSA, TIA, */
/* TTA, and TTC, under the Source’s copyright or copyright license rights */
/* in the Contribution, to, in whole or in part, copy, make derivative */
/* works, perform, display and distribute the Contribution and derivative */
/* works thereof consistent with 3GPP2’s and each Organizational Partner’s */
/* policies and procedures, with the right to (i) sublicense the foregoing */
/* rights consistent with 3GPP2’s and each Organizational Partner’s */
/* policies and procedures and (ii) copyright and sell, if applicable) in */
/* 3GPP2's name or each Organizational Partner’s name any 3GPP2 or */
/* transposed Publication even though this Publication may contain the */
/* Contribution or a derivative work thereof. The Contribution shall */
/* disclose any known limitations on the Source’s rights to license as */
/* herein provided. */
/* */
/* When a Contribution is submitted by the Source(s) to assist the */
/* formulating groups of 3GPP2 or any of its Organizational Partners, */
/* it is proposed to the Committee as a basis for discussion and is not */
/* to be construed as a binding proposal on the Source(s). The Source(s) */
/* specifically reserve(s) the right to amend or modify the material */
/* contained in the Contribution. Nothing contained in the Contribution */
/* shall, except as herein expressly provided, be construed as conferring */
/* by implication, estoppel or otherwise, any license or right under */
/* (i) any existing or later issuing patent, whether or not the use of */
/* information in the document necessarily employs an invention of any */
/* existing or later issued patent, (ii) any copyright, (iii) any */
/* trademark, or (iv) any other intellectual property right. */
/* */
/* With respect to the Software necessary for the practice of any or all */
/* Normative portions of the Selectable Mode Vocoder (SMV) as it exists on */
/* the date of submittal of this form, should the SMV be approved as a */
/* Specification or Report by 3GPP2, or as a transposed Standard by any of */
/* the 3GPP2’s Organizational Partners, the Source(s) state(s) that a */
/* worldwide license to reproduce, use and distribute the Software, the */
/* license rights to which are held by the Source(s), will be made */
/* available to applicants under terms and conditions that are reasonable */
/* and non-discriminatory, which may include monetary compensation, */
/* and only to the extent necessary for the practice of any or all of the */
/* Normative portions of the SMV or the field of use of practice of the */
/* SMV Specification, Report, or Standard. The statement contained above */
/* is irrevocable and shall be binding upon the Source(s). In the event */
/* the rights of the Source(s) in and to copyright or copyright license */
/* rights subject to such commitment are assigned or transferred, */
/* the Source(s) shall notify the assignee or transferee of the existence */
/* of such commitments. */
/*=========================================================================*/
/* */
/*-------------------------------------------------------------------*/
/*===================================================================*/
/* FILE: const.h */
/*-------------------------------------------------------------------*/
/* PURPOSE : Constant definitions for SMVocoder */
/*===================================================================*/
/*============================================================================*/
/*============================== Coding Parameters ===========================*/
/*============================================================================*/
#define sqr(a) ((a)*(a))
#define cube(a) ((a)*(a)*(a))
#define MAX(a,b) ((a)>(b) ? (a) : (b))
#define ABS(a) (((a)<0) ? -(a) : (a))
#define MIN(a,b) (((a)<(b)) ? (a) : (b))
#define SIGN(a) (((a)>=0) ? (1) : (-1))
#define ROUND(a) (INT64)((a)>0 ? ((a)+0.5) : ((a)-0.5))
#define AVG(a,b,c) (INT16)(((a)+(b)+(c))/(3.0)+0.5)
#define MAXFLT 1.0e30
#define MINFLT 1.0e-30
#define EPSI 0.00000000000000001
#define FALSE 0
#define TRUE 1
#define L_PREV 60 /* length of previous speech data */
#define L_FRM 160 /* length of coding frame */
#define L_SF 80 /* maximun length of subframe */
#define L_SF3 54 /* length of subframe */
#define L_SF4 40 /* length of subframe */
#define L_SF0 53 /* length of subframe */
#define N_SF_MAX 4 /* maximun number of subframes */
#define N_SF4 4 /* number of subframes 8.5 k*/
#define N_SF3 3 /* number of subframes 4.0 k mode 1*/
#define N_SF2 2 /* number of subframes 4.0 k mode 0*/
#define NP 10
#ifdef VAD_B
#define NP_EVAD 16
#endif
#define L_LPC 240 /* length of LPC window */
#define L_LPCLHD 80 /* length of LPC lookahead */
#ifdef NS_B
#define SLOPE_LEN 12
#endif
/*============================================================================*/
/*============================== Coding Parameters ===========================*/
/*============================================================================*/
#define FS 8000.0 /* Sampling frequency */
#define RATE8_5K 8 /* 8.5 kbps */
#define RATE4_0K 4 /* 4.0 kbps */
#define RATE2_0K 2 /* 2.0 kbps */
#define RATE0_8K 0 /* 0.8 kbps */
/*----------------------------------------------------------------------------*/
/* Bit-rate including overhead for the four rates */
/*----------------------------------------------------------------------------*/
#define RATE_1_1 9600 /* 8.5 kbit/s source coding */
#define RATE_1_2 4800 /* 4.0 kbit/s source coding */
#define RATE_1_4 2400 /* 2.0 kbit/s source coding */
#define RATE_1_8 1200 /* 0.8 kbit/s source coding */
/*============================================================================*/
/*============================== NOISE SUPRESSOR ===========================*/
/*============================================================================*/
#define NS_DELAY 24
/*============================================================================*/
/*=========================== PRE AND POST PROCESSING =======================*/
/*============================================================================*/
#define PPR_FLT_ORDER 2
#define LP_FLT_ORDER 1
#define SE_MEM_SIZE 4
#define SE_HIS_SIZE 3
#define SE_RAMP_SIZE 40
#define DELTA_THRLD 48.0
/*============================================================================*/
/*======================= DEFINITIONS FOR CLASSIFICATION ====================*/
/*============================================================================*/
#define MEM_CLASS 140
#define N_LP 3
#define MAX_N_SF 8
#define INV_SUM_SQR_MAX_N_SF (1.0/(140.0+EPSI))
#define MAX_L_SF 20
#define L_LPC_SF 40 /* SHOULD NOT BE CHANGED - HARDWIRED AT PLACES */
#define OVERLAP 20
#define LPC_WIN1 (L_LPC_SF+2*OVERLAP)
#define CLA_MEM_SIZE 4
#define SLOPE_MAX_SIZE 5
/*============================================================================*/
/*==================== DEFINITIONS FOR PERCEPTUAL WEIGHTING =================*/
/*============================================================================*/
#define GAMMA1 0.9
#define GAMMA2 0.6
/*============================================================================*/
/*=========================== FIXED COEDEBOOK SEARCH =========================*/
/*============================================================================*/
#define MAXPN 11
#define MAX_FB_PULSE_NUM 5
#define SEG_NUM_M1 8
#define SEG_NUM_M0 16
#define L_HF 20
#define L_CORR 80
#define L_WSP (L_CORR+L_SF+10)
#define PAST_PGAIN_MAX2 0.8
#define MAX_NUM_IDX 32
/*============================================================================*/
/*=========================== Gaussian codebook sizes ========================*/
/*============================================================================*/
#define N_GAUSS_13b 54 /* Entries 1. basis vector: 11664 entry codebook */
#define NUM11BITS 2048
#define NUMPOS2PULSE (L_SF*L_SF)
#define DELTA_REMAP (N_GAUSS_13b*N_GAUSS_13b - NUM11BITS)
#define NUM_PRESELECT 2
/*============================================================================*/
/*============================ DEFINITIONS FOR LTP ==========================*/
/*============================================================================*/
#define NUM_SINC_WIN 21 /* Number of quantized Sinc interpolation */
/* windows */
#define SINC_LIMIT_E 10
#define LEN_SINC_E (2*SINC_LIMIT_E)
#define LEN_SINC_TAB_E (((NUM_SINC_WIN+1)/2)*LEN_SINC_E)
/*============================================================================*/
/*===================== DEFINITIONS FOR PITCH PRE-PROCESSING ================*/
/*============================================================================*/
#define L_PP (L_PREV+L_FRM+L_LPCLHD) /* length of sig_ppr = 260 */
#define HALFP 2
#define MAX_PULS_NUM 5
#define MAX_DIF_TAB 16
#define MAX_L_TG 180 /* Maximum length for LT preprocessing */
/* Note: it must to be >= L_FRM and > L_SF */
#define MAX_DELAY 20
/*============================================================================*/
/*====================== DEFINITIONS FOR OPEN LOOP PITCH ====================*/
/*============================================================================*/
#define NUM_MAX_SRCH 4
#define SINC_LIMIT 4
#define LEN_SINC (2*SINC_LIMIT)
#define LEN_SINC_TAB (((NUM_SINC_WIN+1)/2)*LEN_SINC)
#define DELT_F (1.0/((double)NUM_SINC_WIN-1.0)) /* Precision of the */
/* interpolation */
#define MIN_LAG 17 /* minimum pitch lag */
#define MAX_LAG (L_FRM+SINC_LIMIT_E+2) /* Maximum pitch lag */
/* Note: must to be > 170 and */
/* > HI_LAG+11 */
#define L_OLPIT (L_FRM+L_LPCLHD+MAX_LAG) /* Open loop pitch window */
#define HI_LAG2 148 /* maximum pitch lag */
#define HI_LAG 120 /* maximum pitch lag */
#define MIN_LAG2 (HI_LAG2-127) /* minimum pitch lag */
#define PIT_F_MEM 3
/*============================================================================*/
/*==================== DEFINITIONS FOR CLOSED LOOP PITCH ====================*/
/*============================================================================*/
#define LEN_PITCH_TAB_7BIT 128
#define LEN_PITCH_TAB_5BIT 17
#define LEN_PITCH_TAB_8BIT 256
#define MAX_PIT_IDX_5b 16
#define MAX_PIT_IDX_7b 127
#define MAX_PIT_IDX_8b 255
#define DELT_F2 (1.0/(FLOAT64)DELT_F)
/*============================================================================*/
/*========================== DEFINITIONS FOR GAIN MA-VQ ======================*/
/*============================================================================*/
#define PAST_PGAIN_MIN 0.2 /* minimum value of the past quantized */
/* pitch gain for the adaptive prefilter*/
/* in the algebraic codebok search */
#define PAST_PGAIN_MAX 1.0 /* maximum value of the past quantized */
/* pitch gain for the adaptive prefilter*/
/* in the algebraic codebok search */
#define UVG1_CBSIZE 32
#define UVG2_CBSIZE 64
#define MSMAX_1_64 64
#define MSMAX_1_32 32
#define MSMAX_2_64 64
#define MSMAX_2_128 128
#define MSMAX_3_256 256
#define MSMAX_4_128 128
#define MSMAX_4_8 8
#define GP_BUF_SIZE 8
#define BETA_BUF_SIZE 4
#define GVQ_VEC_SIZE_2D 2
#define GVQ_VEC_SIZE_3D 3
#define TAB_SIZE_GVQ_3D 16
#define GVQ_VEC_SIZE_4D 4
#define TAB_SIZE_GVQ_4D 64
#define CORR_SIZE 6
/*============================================================================*/
/*================================ SMOOTHING =================================*/
/*============================================================================*/
#define DSP_BUFF_SIZE 4
#define SMO_BUFF_SIZE 15
#define MAX_GRP_SIZE 5
#define HL_COUNT_MAX 15
#define N_NOISE_ENERGY_STATIONARITY_START -4
#define UPDATE_MAX 15
#define CONSEC_MAX 31
/*----------------------------------------------------------------------------*/
/* Smooth LSF */
/*----------------------------------------------------------------------------*/
#define BETA_FRM 0.90
#define BETA_SUB 0.70
#define dSP1 0.0015
#define dSP2 0.0025
#define dSP_int1 0.0024
#define R1lim 0.50
/*============================================================================*/
/*========================== DEFINITIONS FOR LSF MA-VQ ======================*/
/*============================================================================*/
#define MAX_CAND_LSFQ 16 /* the maximal number of condidate per stage */
#define N_LSFVQCDBK 5 /* number of LSF codebooks */
#define MAXLNp 10 /* maximal order of LPC */
#define MAXLTT_08k 3 /* the maximal number of codebooks */
#define MAXLTT_40k 3 /* the maximal number of codebooks */
#define MAXLTT_85k 4 /* the maximal number of codebooks */
#define LP_08k 1 /* number of switch predictors */
#define LPL_08k 1 /* the number of delayed predictors */
#define LMS1_08k 16 /* the number of entries for the 1 code */
#define LMS2_08k 16 /* the number of entries for the 2 code */
#define LMS3_08k 8 /* the number of entries for the 3 code */
#define LMSMAX_08k 16
#define LQMA_08k 4
#define LP_20k 1 /* number of switch predictors */
#define LPL_20k 1 /* the number of delayed predictors */
#define LMS1_20k 128 /* the number of entries for the 1 code */
#define LMS2_20k 128 /* the number of entries for the 2 code */
#define LMS3_20k 64 /* the number of entries for the 3 code */
#define LMSMAX_20k 128
#define LQMA_20k 4
#define LP_40k 2 /* number of switch predictors */
#define LPL_40k 2 /* the number of delayed predictors */
#define LMS1_40k 128 /* the number of entries for the 1 code */
#define LMS2_40k 128 /* the number of entries for the 2 code */
#define LMS3_40k 64 /* the number of entries for the 3 code */
#define LMSMAX_40k 128
#define LQMA_40k 4
#define LP_85k 2 /* number of switch predictors */
#define LPL_85k 2 /* the number of delayed predictors */
#define LMS1_85k 128 /* the number of entries for the 1 code */
#define LMS2_85k 128 /* the number of entries for the 2 code */
#define LMS3_85k 64 /* the number of entries for the 3 code */
#define LMS4_85k 16 /* the number of entries for the 4 code */
#define LMSMAX_85k 128
#define LQMA_85k 2
#define LTT_08k 3 /* the number of stages for T */
#define LTT_20k 3 /* the number of stages for T */
#define LTT_40k 3 /* the number of stages for T */
#define LTT_85k 4 /* the number of stages for T */
#define GRID_POINTS 60 /* resolution of lsp search */
/*============================================================================*/
/*============================ DEFINITIONS FOR VAD ==========================*/
/*============================================================================*/
#define VOICE 1
#define NOISE 0
#define INIT_FRAME 32
#define INIT_COUNT 10
#define VAD_LPC_ORDER 4
#define LTP_BUFF_SIZE 5
#define FLAG_VAD_MEM_SIZE 2
#define VAD_MEM_SIZE 3
#define VAD_MIN_MEM_SIZE 8
#define MAX_ENERGY 1.0e30
/*============================================================================*/
/*==================== DEFINITIONS FOR BAD FRAME HANDLING ===================*/
/*============================================================================*/
#define BFH_OH 1 /* LSF: bad frame handling overhang */
#define ERNG_MEM_SIZE 3
#define MAX_BFI_COUNT 5
/*============================================================================*/
/*==================== DEFINITIONS FOR BAD RATE DETECTION ===================*/
/*============================================================================*/
#define LEN_TYPE1EN 50
#ifdef DATA
/*============================================================================*/
/*====================== DEFINITIONS FOR DATA (DTMF, TTY) ===================*/
/*============================================================================*/
#define DATA_SIZE 5 /* number of 16-bit data words*/
#define DATA_HEADER 1 /* header to indicate data */
#define TTY_HEADER 2 /* header to indicate data */
#define DTMF_HEADER 3 /* header to indicate data */
#define AUX_DATA_HEADER 4 /* header to indicate auxiliary data */
#define TTY_TYPE_Baudot 1 /* indicates the type of TTY (1=Baudot) */
#endif
/*============================================================================*/
/*===================== ENCODER / DECODER INDEX STRUCTURE ====================*/
/*============================================================================*/
#define PACKWDSNUM 12 /* the number of words to pack the SMV bits
(1 for rate/erasure control, 11*16=171 for data */
typedef struct {
INT16 idx_lsf[N_LSFVQCDBK+1];
INT16 idx_SVS_deci;
INT16 idx_ltp_deci[N_SF_MAX];
INT16 idx_pitch[N_SF_MAX];
INT16 idx_Gp_VQ;
INT16 idx_Gc_VQ;
INT16 idx_gainVQ[N_SF_MAX];
INT16 idx_subcpcb[N_SF_MAX][5];
INT16 idx_cpcbsign[N_SF_MAX][20];
INT16 idx_cpcb[N_SF_MAX][20];
INT16 idx_center[N_SF_MAX];
INT16 fix_rate;
INT16 idx_lpc_int;
INT16 idx_vad;
INT16 idx_pitchgainQ[N_SF_MAX];
INT16 ltp_mode;
INT16 fcb_mode[N_SF_MAX];
INT16 idx_pit_frac[N_SF_MAX];
INT16 idx_pit_int[N_SF_MAX];
INT16 idx_fcbpit_frac[N_SF_MAX][2];
INT16 idx_fcbpit_int[N_SF_MAX][2];
INT16 badrate_flag;
} PARAMETER;
#ifdef WMOPS
/*============================================================================*/
/*====================== ENCODER / DECODER WMOPS COUNTER =====================*/
/*============================================================================*/
#define NB_FUNC_MAX 1024 /* Maximum number of function to analyze */
/*----------------------------------------------------------------------------*/
/* Global counter variable for calculation of complexity weight */
/*----------------------------------------------------------------------------*/
typedef struct
{
INT64 add; /* Complexity Weight of 1 */
INT64 sub; /* Complexity Weight of 1 */
INT64 abs; /* Complexity Weight of 1 */
INT64 mult; /* Complexity Weight of 1 */
INT64 negate; /* Complexity Weight of 1 */
INT64 mac; /* Complexity Weight of 1 */
INT64 shift; /* Complexity Weight of 1 */
INT64 move; /* Complexity Weight of 1 */
INT64 logic; /* Complexity Weight of 1 */
INT64 test; /* Complexity Weight of 2 */
INT64 div; /* Complexity Weight of 18 */
INT64 sqrt; /* Complexity Weight of 25 */
INT64 transc; /* Complexity Weight of 25 */
} BASIC_OP;
#endif
/*============================================================================*/
/*------------------------------------ END -----------------------------------*/
/*============================================================================*/