?? decgsmamr.c
字號:
/*/////////////////////////////////////////////////////////////////////////////
//
// 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 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 ipplic.htm 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: decoder API.
//
*/
#include "owngsmamr.h"
/* filter coefficients (fc = 100 Hz) */
static __ALIGN32 CONST short b100[3] = {7699, -15398, 7699}; /* Q13 */
static __ALIGN32 CONST short a100[3] = {8192, 15836, -7667}; /* Q13 */
GSMAMR_CODECFUN( APIGSMAMR_Status, apiGSMAMRDecoder_GetSize,
(GSMAMRDecoder_Obj* decoderObj, unsigned int *pCodecSize))
{
if(NULL == decoderObj)
return APIGSMAMR_StsBadArgErr;
if(NULL == pCodecSize)
return APIGSMAMR_StsBadArgErr;
if(decoderObj->objPrm.key != DEC_KEY)
return APIGSMAMR_StsNotInitialized;
*pCodecSize = decoderObj->objPrm.objSize;
return APIGSMAMR_StsNoErr;
}
GSMAMR_CODECFUN( APIGSMAMR_Status, apiGSMAMRDecoder_Alloc,
(const GSMAMRDec_Params *gsm_Params, unsigned int *pSizeTab))
{
int fltSize;
int allocSize=sizeof(GSMAMRDecoder_Obj);
if(GSMAMR_CODEC != gsm_Params->codecType)
return APIGSMAMR_StsBadCodecType;
ippsHighPassFilterSize_G729(&fltSize);
allocSize += fltSize; /* to provide memory for postprocessing high pass filter with upscaling */
pSizeTab[0] = allocSize;
return APIGSMAMR_StsNoErr;
}
int ownDtxDecoderInit_GSMAMR(sDTXDecoderSt* dtxState)
{
int i;
dtxState->vLastSidFrame = 0;
dtxState->vSidPeriodInv = (1 << 13);
dtxState->vLogEnergy = 3500;
dtxState->vLogEnergyOld = 3500;
/* low level noise for better performance in DTX handover cases*/
dtxState->vPerfSeedDTX_long = PSEUDO_NOISE_SEED;
/* Initialize state->a_LSP [] and state->a_LSP_Old [] */
ippsCopy_16s(TableLSPInitData, &dtxState->a_LSP[0], LP_ORDER_SIZE);
ippsCopy_16s(TableLSPInitData, &dtxState->a_LSP_Old[0], LP_ORDER_SIZE);
dtxState->vLogMean = 0;
dtxState->vLogEnergyHistory = 0;
/* initialize decoder lsf history */
ippsCopy_16s(TableMeanLSF_5, &dtxState->a_LSFHistory[0], LP_ORDER_SIZE);
for (i = 1; i < DTX_HIST_SIZE; i++)
ippsCopy_16s(&dtxState->a_LSFHistory[0], &dtxState->a_LSFHistory[LP_ORDER_SIZE*i], LP_ORDER_SIZE);
ippsZero_16s(dtxState->a_LSFHistoryMean, LP_ORDER_SIZE*DTX_HIST_SIZE);
/* initialize decoder log frame energy */
ippsSet_16s(dtxState->vLogEnergy, dtxState->a_LogEnergyHistory, DTX_HIST_SIZE);
dtxState->vLogEnergyCorrect = 0;
dtxState->vDTXHangoverCt = DTX_HANG_PERIOD;
dtxState->vDecExpireCt = 32767;
dtxState->vFlagSidFrame = 0;
dtxState->vFlagValidData = 0;
dtxState->vDTXHangAdd = 0;
dtxState->eDTXPrevState = DTX;
dtxState->vFlagDataUpdate = 0;
return 1;
}
int ownPhDispInit_GSMAMR(sPhaseDispSt* PhState)
{
ippsZero_16s(PhState->a_GainMemory, LTP_GAIN_MEM_SIZE);
PhState->vPrevState = 0;
PhState->vPrevGain = 0;
PhState->vFlagLockGain = 0;
PhState->vOnSetGain = 0; /* assume no onset in start */
return 1;
}
int ownPostFilterInit_GSMAMR(sPostFilterSt *PostState)
{
ippsZero_16s(PostState->a_MemSynPst, LP_ORDER_SIZE);
ippsZero_16s(PostState->a_SynthBuf, LP_ORDER_SIZE);
PostState->vPastGainScale = 4096;
PostState->vMemPrevRes = 0;
return 1;
}
int ownDecoderInit_GSMAMR(sDecoderState_GSMAMR* decState, GSMAMR_Rate_t rate)
{
/* Initialize static pointer */
decState->pExcVec = decState->a_ExcVecOld + PITCH_MAX_LAG + FLT_INTER_SIZE;
/* Static vectors to zero */
ippsZero_16s(decState->a_ExcVecOld, PITCH_MAX_LAG + FLT_INTER_SIZE);
if (rate != GSMAMR_RATE_DTX)
ippsZero_16s(decState->a_MemorySyn, LP_ORDER_SIZE);
/* initialize pitch sharpening */
decState->vFlagSharp = PITCH_SHARP_MIN;
decState->vPrevPitchLag = 40;
/* Initialize decState->lsp_old [] */
if (rate != GSMAMR_RATE_DTX) {
ippsCopy_16s(TableLSPInitData, &decState->a_LSP_Old[0], LP_ORDER_SIZE);
}
/* Initialize memories of bad frame handling */
decState->vPrevBadFr = 0;
decState->vPrevDegBadFr = 0;
decState->vStateMachine = 0;
decState->vLTPLag = 40;
decState->vBackgroundNoise = 0;
ippsZero_16s(decState->a_EnergyHistVector, ENERGY_HIST_SIZE);
/* Initialize hangover handling */
decState->vCountHangover = 0;
decState->vVoiceHangover = 0;
if (rate != GSMAMR_RATE_DTX) {
ippsZero_16s(decState->a_EnergyHistSubFr, 9);
}
ippsZero_16s(decState->a_LTPGainHistory, 9);
ippsZero_16s(decState->a_GainHistory, CBGAIN_HIST_SIZE);
/* Initialize hangover handling */
decState->vHgAverageVar = 0;
decState->vHgAverageCount= 0;
if (rate != GSMAMR_RATE_DTX)
ippsCopy_16s(TableMeanLSF_5, &decState->a_LSPAveraged[0], LP_ORDER_SIZE);
ippsZero_16s(decState->a_PastQntPredErr, LP_ORDER_SIZE); /* Past quantized prediction error */
/* Past dequantized lsfs */
ippsCopy_16s(TableMeanLSF_5, &decState->a_PastLSFQnt[0], LP_ORDER_SIZE);
ippsSet_16s(1640, decState->a_LSFBuffer, 5);
decState->vPastGainZero = 0;
decState->vPrevGainZero = 16384;
ippsSet_16s(1, decState->a_GainBuffer, 5);
decState->vPastGainCode = 0;
decState->vPrevGainCode = 1;
if (rate != GSMAMR_RATE_DTX) {
ippsSet_16s(MIN_ENERGY, decState->a_PastQntEnergy, NUM_PRED_TAPS);
ippsSet_16s(MIN_ENERGY_M122, decState->a_PastQntEnergy_M122, NUM_PRED_TAPS);
}
decState->vCNGen = 21845;
ownPhDispInit_GSMAMR(&decState->stPhDispState);
if (rate != GSMAMR_RATE_DTX)
ownDtxDecoderInit_GSMAMR(&decState->dtxDecoderState);
ownDecSidSyncReset_GSMAMR(&decState->dtxDecoderState);
return 1;
}
/*************************************************************************
* apiGSMAMRDecoder_Init()
* Initializes the decoder object
**************************************************************************/
GSMAMR_CODECFUN( APIGSMAMR_Status, apiGSMAMRDecoder_Init, (GSMAMRDecoder_Obj* decoderObj, unsigned int mode))
{
int fltSize;
IPP_ALIGNED_ARRAY(16, Ipp16s, abDec, 6);
int obj_size = sizeof(GSMAMRDecoder_Obj);
ippsZero_16s((short*)decoderObj,sizeof(GSMAMRDecoder_Obj)>>1) ; /* non-initialized data, bug in debug mode AK27.08.01 */
decoderObj->objPrm.mode = mode;
decoderObj->objPrm.key = DEC_KEY;
decoderObj->postProc = (char*)decoderObj + sizeof(GSMAMRDecoder_Obj);
ippsHighPassFilterSize_G729(&fltSize);
decoderObj->objPrm.objSize = obj_size+fltSize;
abDec[0] = a100[0];
abDec[1] = a100[1];
abDec[2] = a100[2];
abDec[3] = b100[0];
abDec[4] = b100[1];
abDec[5] = b100[2];
ownPostFilterInit_GSMAMR(&decoderObj->stPFiltState);
ippsHighPassFilterInit_G729(abDec,decoderObj->postProc);
ownDecoderInit_GSMAMR(&decoderObj->stDecState,decoderObj->rate);
return APIGSMAMR_StsNoErr;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -