📄 owngsmamr.h
字号:
/*/////////////////////////////////////////////////////////////////////////////
//
// INTEL CORPORATION PROPRIETARY INFORMATION
// This software is supplied under the terms of a license agreement or
// nondisclosure agreement with Intel Corporation and may not be copied
// or disclosed except in accordance with the terms of that agreement.
// Copyright(c) 2005-2007 Intel Corporation. All Rights Reserved.
//
// Intel(R) Integrated Performance Primitives
// USC - Unified Speech Codec interface library
//
// By downloading and installing USC codec, you hereby agree that the
// accompanying Materials are being provided to you under the terms and
// conditions of the End User License Agreement for the Intel(R) Integrated
// Performance Primitives product previously accepted by you. Please refer
// to the file ippEULA.rtf or ippEULA.txt located in the root directory of your Intel(R) IPP
// product installation for more information.
//
// A speech coding standards promoted by ITU, ETSI, 3GPP and other
// organizations. Implementations of these standards, or the standard enabled
// platforms may require licenses from various entities, including
// Intel Corporation.
//
//
// Purpose: GSMAMR speech codec: internal header file.
//
*/
#ifndef __OWNGSMAMR_H__
#define __OWNGSMAMR_H__
#if defined( _WIN32_WCE)
#pragma warning( disable : 4505 )
#endif
#include "gsmamr.h"
#include "gsmamrapi.h"
#include "scratchmem.h"
#define ENC_KEY 0xecdaaa
#define DEC_KEY 0xdecaaa
/* GSMAMR constant definitions.
Constant names are kept same as IETF GSM AMR */
#define SPEECH_BUF_SIZE 320
#define LP_WINDOW_SIZE 240
#define FRAME_SIZE_GSMAMR 160
#define SUBFR_SIZE_GSMAMR 40
#define LP_ORDER_SIZE 10
#define LP1_ORDER_SIZE (LP_ORDER_SIZE+1)
#define LSF_GAP 205
#define LP_ALL_FRAME (4*LP1_ORDER_SIZE)
#define PITCH_MIN_LAG 20
#define PITCH_MAX_LAG 143
#define FLT_INTER_SIZE (10+1)
#define PITCH_SHARP_MAX 13017
#define PITCH_SHARP_MIN 0
#define MAX_OFFSET (PITCH_MAX_LAG +LP1_ORDER_SIZE)
#define MAX_NUM_PRM 57
#define PITCH_GAIN_CLIP 15565 /* Pitch gain clipping = 0.95 */
#define PG_NUM_FRAME 7
#define NUM_MEM_LTPG 5
#define NUM_SUBBANDS_VAD 9
#define DTX_HIST_SIZE 8
#define ENERGY_HIST_SIZE 60
#define CBGAIN_HIST_SIZE 7
#define NUM_PRED_TAPS 4
#define MIN_ENERGY -14336 /* -14 dB */
#define MIN_ENERGY_M122 -2381 /* -14 dB / (20*log10(2)) */
#define PSEUDO_NOISE_SEED 0x70816958L
#define INIT_BACKGROUND_NOISE 150
#define INIT_LOWPOW_SEGMENT 13106
/* Constants for pitch detection */
#define LOW_THRESHOLD 4
#define NUM_THRESHOLD 4
#define MAX_MED_SIZE 9
#define LTP_GAIN_LOG10_1 2721 /* 1.0 / (10*log10(2)) */
#define LTP_GAIN_LOG10_2 5443 /* 2.0 / (10*log10(2)) */
#define MAX_UPSAMPLING 6
#define LEN_INTERPOL_10 (FLT_INTER_SIZE-1)
#define LEN_FIRFLT (MAX_UPSAMPLING*LEN_INTERPOL_10+1)
#define EXP_CONST_016 5243 /* 0.16 */
#define EXP_CONST_084 27525 /* 0.84 */
#define LTP_GAIN_MEM_SIZE 5
#define LTP_THRESH1 9830 /* 0.6 */
#define LTP_THRESH2 14746 /* 0.9 */
#define THRESH_ENERGY_LIMIT 17578 /* 150 */
#define LOW_NOISE_LIMIT 20 /* 5 */
#define UPP_NOISE_LIMIT 1953 /* 50 */
#define LEN_QNT_GAIN 32
#define LEN_QNT_PITCH 16
#define VEC_QNT_M475_SIZE 256
#define VEC_QNT_HIGHRATES_SIZE 128
#define VEC_QNT_LOWRATES_SIZE 64
#define ALPHA_09 29491 /* 0.9 */
#define ONE_ALPHA 3277 /* 1.0-ALPHA */
enum enDTXStateType {SPEECH = 0, DTX, DTX_MUTE, DTX_NODATA};
#define DTX_MAX_EMPTY_THRESH 50
#define DTX_ELAPSED_FRAMES_THRESH (24 + 7 -1)
#define DTX_HANG_PERIOD 7
#define dVADState void
typedef struct {
Ipp16s vSinceLastSid;
Ipp16s vDTXHangCount;
Ipp16s vExpireCount;
Ipp16s vDataUpdated;
} sDecoderSidSync;
/* post filter memory */
typedef struct{
Ipp16s a_MemSynPst[LP_ORDER_SIZE];
Ipp16s vMemPrevRes;
Ipp16s vPastGainScale;
Ipp16s a_SynthBuf[LP_ORDER_SIZE];
} sPostFilterSt;
typedef struct {
Ipp16s a_GainMemory[LTP_GAIN_MEM_SIZE];
Ipp16s vPrevState;
Ipp16s vPrevGain;
Ipp16s vFlagLockGain;
Ipp16s vOnSetGain;
} sPhaseDispSt;
typedef struct {
Ipp16s vExpPredCBGain;
Ipp16s vFracPredCBGain;
Ipp16s vExpTargetEnergy;
Ipp16s vFracTargetEnergy;
Ipp16s a_ExpEnCoeff[5];
Ipp16s a_FracEnCoeff[5];
Ipp16s *pGainPtr;
Ipp16s a_PastQntEnergy[4];
Ipp16s a_PastQntEnergy_M122[4];
Ipp16s a_PastUnQntEnergy[4];
Ipp16s a_PastUnQntEnergy_M122[4];
Ipp16s vOnSetQntGain;
Ipp16s vPrevAdaptOut;
Ipp16s vPrevGainCode;
Ipp16s a_LTPHistoryGain[NUM_MEM_LTPG];
} sGainQuantSt;
typedef struct {
Ipp16s a_LSPHistory[LP_ORDER_SIZE * DTX_HIST_SIZE];
Ipp16s a_LogEnergyHistory[DTX_HIST_SIZE];
Ipp16s vHistoryPtr;
Ipp16s vLogEnergyIndex;
Ipp16s vLSFQntIndex;
Ipp16s a_LSPIndex[3];
/* DTX handler */
Ipp16s vDTXHangoverCt;
Ipp16s vDecExpireCt;
} sDTXEncoderSt;
typedef struct {
Ipp16s vLastSidFrame;
Ipp16s vSidPeriodInv;
Ipp16s vLogEnergy;
Ipp16s vLogEnergyOld;
Ipp32s vPerfSeedDTX_long;
Ipp16s a_LSP[LP_ORDER_SIZE];
Ipp16s a_LSP_Old[LP_ORDER_SIZE];
Ipp16s a_LSFHistory[LP_ORDER_SIZE*DTX_HIST_SIZE];
Ipp16s a_LSFHistoryMean[LP_ORDER_SIZE*DTX_HIST_SIZE];
Ipp16s vLogMean;
Ipp16s a_LogEnergyHistory[DTX_HIST_SIZE];
Ipp16s vLogEnergyHistory;
Ipp16s vLogEnergyCorrect;
Ipp16s vDTXHangoverCt;
Ipp16s vDecExpireCt;
Ipp16s vFlagSidFrame;
Ipp16s vFlagValidData;
Ipp16s vDTXHangAdd;
Ipp16s vSidUpdateCt;
enum enDTXStateType eDTXPrevState;
Ipp16s vFlagDataUpdate;
Ipp16s vSinceLastSid;
Ipp16s vDTXHangCount;
Ipp16s vExpireCount;
Ipp16s vDataUpdated;
} sDTXDecoderSt;
/* Decoder part */
/********************************************************
* array & table declarations
*********************************************************/
#define N_MODES 9
extern CONST Ipp16s TableHammingWindow[LP_WINDOW_SIZE];
extern CONST Ipp16s TablePastLSFQnt[80];
extern CONST Ipp16s TableMeanLSF_3[10];
extern CONST Ipp16s TableDecCode1LSF_3[256*3];
extern CONST Ipp16s TableDecCode2LSF_3[512*3];
extern CONST Ipp16s TableDecCode3LSF_3[512*4];
extern CONST Ipp16s TableMeanLSF_5[10];
extern CONST Ipp16s TableQuantGainPitch[16];
extern CONST Ipp16s TableLSPInitData[LP_ORDER_SIZE]; /* removed const for BE code */
extern CONST Ipp16s TableParamPerModes[N_MODES];
extern CONST Ipp16s *TableBitAllModes[N_MODES];
extern CONST IppSpchBitRate mode2rates[N_MODES];
/********************************************************
* function declarations
*********************************************************/
void ownVADPitchDetection_GSMAMR(IppGSMAMRVad1State *st, Ipp16s *pTimeVec, Ipp16s *vLagCountOld, Ipp16s *vLagOld);
void ownUpdateLTPFlag_GSMAMR(IppSpchBitRate rate, Ipp32s L_Rmax, Ipp32s L_R0, Ipp16s *vFlagLTP);
void ownLog2_GSMAMR_norm (Ipp32s inVal, Ipp16s exp, Ipp16s *expPart, Ipp16s *fracPart);
void ownLog2_GSMAMR(Ipp32s inVal, Ipp16s *expPart, Ipp16s *fracPart);
Ipp32s ownPow2_GSMAMR(Ipp16s expPart, Ipp16s fracPart);
Ipp32s ownSqrt_Exp_GSMAMR(Ipp32s inVal, Ipp16s *exp);
void ownReorderLSFVec_GSMAMR(Ipp16s *lsf, Ipp16s minDistance, Ipp16s len);
Ipp16s ownGetMedianElements_GSMAMR(Ipp16s *pPastGainVal, Ipp16s num);
Ipp16s ownCtrlDetectBackgroundNoise_GSMAMR (Ipp16s *excitation, Ipp16s excEnergy, Ipp16s *exEnergyHist,
Ipp16s vVoiceHangover, Ipp16s prevBFI, Ipp16s carefulFlag);
Ipp16s ownComputeCodebookGain_GSMAMR(Ipp16s *pTargetVec2, Ipp16s *pFltVector);
void ownGainAdaptAlpha_GSMAMR(Ipp16s *vOnSetQntGain, Ipp16s *vPrevAdaptOut, Ipp16s *vPrevGainCode,
Ipp16s *a_LTPHistoryGain, Ipp16s ltpg, Ipp16s gainCode, Ipp16s *alpha);
Ipp16s ownCBGainAverage_GSMAMR(Ipp16s *a_GainHistory, Ipp16s *vHgAverageVar, Ipp16s *vHgAverageCount, IppSpchBitRate rate,
Ipp16s gainCode, Ipp16s *lsp, Ipp16s *lspAver, Ipp16s badFrame, Ipp16s vPrevBadFr,
Ipp16s pdfi, Ipp16s vPrevDegBadFr, Ipp16s vBackgroundNoise, Ipp16s vVoiceHangover);
Ipp16s ownCheckLSPVec_GSMAMR(Ipp16s *count, Ipp16s *lsp);
Ipp32s ownSubframePostProc_GSMAMR(Ipp16s *pSpeechVec, IppSpchBitRate rate, Ipp16s numSubfr,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -