📄 ownamrwb.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 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: AMRWB speech codec own header file
//
*/
#ifndef __OWNAMRWB_H__
#define __OWNAMRWB_H__
#include <stdio.h>
#include <stdlib.h>
#include <ipps.h>
#include <ippsc.h>
#include "amrwbapi.h"
#include "scratchmem.h"
extern CONST IppSpchBitRate Mode2RateTbl[11];
extern CONST short NumberPrmsTbl[NUM_OF_MODES];
extern CONST short *pNumberBitsTbl[NUM_OF_MODES];
#define ENC_KEY 0xecd7222
#define DEC_KEY 0xdec7222
/* Codec constant parameters (coder and decoder) */
#define CODEC_VERSION "5.5.0"
#define FRAME_SIZE 256 /* Frame size */
#define SUBFRAME_SIZE_16k (L_FRAME16k/NUMBER_SUBFRAME) /* Subframe size at 16kHz */
#define MAX_PARAM_SIZE 57 /* Maximum number of params */
#define SUBFRAME_SIZE (FRAME_SIZE/NUMBER_SUBFRAME) /* Subframe size */
#define NUMBER_SUBFRAME 4 /* Number of subframe per frame */
#define WINDOW_SIZE 384 /* window size in LP analysis */
#define SPEECH_SIZE WINDOW_SIZE /* Total size of speech buffer */
#define LP_ORDER 16 /* Order of LP filter */
#define LP_ORDER_16K 20
#define UP_SAMPL_FILT_DELAY 12
#define DOWN_SAMPL_FILT_DELAY (UP_SAMPL_FILT_DELAY+3)
#define PITCH_GAIN_CLIP 15565 /* Pitch gain clipping */
#define PITCH_SHARP_FACTOR 27853 /* pitch sharpening factor */
#define PITCH_LAG_MAX 231 /* Maximum pitch lag */
#define OPL_DECIM 2 /* Decimation in open-loop pitch analysis */
#define INTERPOL_LEN (LP_ORDER+1) /* Length of filter for interpolation */
#define PREEMPH_FACTOR 22282 /* preemphasis factor */
#define TILT_FACTOR 22282 /* tilt factor (denominator) */
#define WEIGHT_FACTOR 30147 /* Weighting factor (numerator) */
#define MAX_SCALE_FACTOR 8 /* scaling max for signal */
#define RND_INIT 21845 /* random init value */
/* Constants for Voice Activity Detection */
#define DTX_MAX_EMPTY_THRESH 50
#define DTX_HIST_SIZE 8
#define DTX_HIST_SIZE_MIN_ONE (DTX_HIST_SIZE-1)
#define DTX_ELAPSED_FRAMES_THRESH 30
#define DTX_HANG_CONST 7 /* yields eight frames of SP HANGOVER */
#define INV_MED_THRESH 14564
#define ISF_GAP 128
#define ISF_FACTOR_LOW 256
#define ISF_DITHER_GAP 448
#define ISF_FACTOR_STEP 2
#define GAIN_FACTOR 75
#define GAIN_THRESH 180
#define THRESH_GAIN_PITCH 14746
#define DTX 1
#define DTX_MUTE 2
#define SPEECH 0
#define MAX_DISTANCE_ISF 307 /* 120 Hz (6400Hz=16384) */
#define THRESH_DISTANCE_ISF 154
#define MIN_GAIN_PITCH 9830
#define NB_COEF_DOWN 15
#define NB_COEF_UP 12
#define PRED_ORDER 4
/*
Some arrays reference
*/
extern CONST int LagWindowTbl[LP_ORDER];
extern CONST short LPWindowTbl[WINDOW_SIZE];
extern CONST short FirUpSamplTbl[120];
extern CONST short FirDownSamplTbl[120];
extern CONST short IspInitTbl[LP_ORDER];
extern CONST short IsfInitTbl[LP_ORDER];
extern CONST short HPGainTbl[16];
extern CONST short Fir6k_7kTbl[31];
extern CONST short Fir7kTbl[31];
extern CONST short InterpolFracTbl[NUMBER_SUBFRAME];
extern CONST short BCoeffHP50Tbl[3];
extern CONST short ACoeffHP50Tbl[3];
extern CONST short BCoeffHP400Tbl[3];
extern CONST short ACoeffHP400Tbl[3];
extern CONST short PCoeffDownUnusableTbl[7];
extern CONST short CCoeffDownUnusableTbl[7];
extern CONST short PCoeffDownUsableTbl[7];
extern CONST short CCoeffDownUsableTbl[7];
extern CONST short ACoeffTbl[4];
extern CONST short BCoeffTbl[4];
/*
Procedure definitions
*/
int ownPow2_AMRWB(short valExp, short valFrac);
void ownLagWindow_AMRWB_32s_I(int *pSrcDst);
void ownAutoCorr_AMRWB_16s32s(short *pSrcSignal, int valLPCOrder, int *pDst);
void ownScaleSignal_AMRWB_16s_ISfs(short *pSrcDstSignal, int len, short ScaleFactor);
short ownChkStab(short *pSrc1, short *pSrc2, int len);
void ownDecimation_AMRWB_16s(short *pSrcSignal16k, short len,
short *pDstSignal12k8, short *pMem);
void ownOversampling_AMRWB_16s(short *pSrcSignal12k8, short len,
unsigned short *pDstSignal16k,short *pMem);
short ownMedian5(short *x);
void ownInvSqrt_AMRWB_32s16s_I(int *frac,short *exp);
void ownagc2(short *pSrcPFSignal, short *pDstPFSignal, short len);
void ownIsfExtrapolation(short *pHfIsf);
void ownLPDecim2(short *pSignal, short len, short *pMem);
short ownVoiceFactor(short *pPitchExc, short valExcFmt, short valPitchGain,
short *pFixCdbkExc, short valCodeGain, short len);
short ownGpClip(short *pMem);
void ownCheckGpClipIsf(short *pIsfvec, short *pMem);
void ownCheckGpClipPitchGain(short valPitchGain, short *pMem);
void ownPhaseDispInit(short *pDispvec);
void ownPhaseDisp(short valCodeGain, short valPitchGain, short *pFixCdbkExc,
short valLevelDisp, short *pDispvec);
short amrExtractBits( const char **pBitStrm, int *currBitstrmOffset, int numParamBits );
void ownSynthesisFilter_AMRWB_16s32s_ISfs
( const Ipp16s *pSrcLpc, int valLpcOrder, const Ipp16s *pSrcExcitation,
Ipp32s *pSrcDstSignal, int len, int scaleFactor );
void ownISPToLPC_AMRWB_16s
( const Ipp16s *pSrcIsp, Ipp16s *pDstLpc, Ipp32s len, Ipp32s adaptive_scaling );
#define HIGH_PASS_MEM_SIZE 31
typedef struct _HighPassFIRState_AMRWB_16s_ISfs{
Ipp16s pFilterMemory[HIGH_PASS_MEM_SIZE-1];
Ipp16s pFilterCoeff[HIGH_PASS_MEM_SIZE];
Ipp32s ScaleFactor;
}HighPassFIRState_AMRWB_16s_ISfs;
/* /////////////////////////////////////////////////////////////////////////////
// Name: HighPassFIRGetSize_AMRWB_16s_ISfs
// Purpose: Knowing of AMR WB high pass FIR filter size demand
// Parameters:
// pDstSize Pointer to the output value of the memory size needed for filtering
// Returns: ippStsNoErr, if no errors
*/
void HighPassFIRGetSize_AMRWB_16s_ISfs(Ipp32s *pDstSize);
/* /////////////////////////////////////////////////////////////////////////////
// Name: HighPassFIRInit_AMRWB_16s_ISfs
// Purpose: Initialization of the memory allocated for AMR WB high pass FIR filter
// Parameters:
// pSrcFilterCoeff pointer to the filter coefficienst vector of lenght 31
// ScaleFactor scale factor value
// pState pointer to the memory supplied for filtering
// Returns: ippStsNoErr, if no errors
//
*/
void HighPassFIRInit_AMRWB_16s_ISfs(Ipp16s *pSrcFilterCoeff, Ipp32s ScaleFactor,
HighPassFIRState_AMRWB_16s_ISfs *pState);
/* /////////////////////////////////////////////////////////////////////////////
// Name: HighPassFIR_AMRWB_16s_ISfs
// Purpose: High-pass FIR filtering
// Parameters:
// pSrcDstSignal pointer to the vector for inplace operation
// pState pointer to the memory supplied for filtering
// Returns: ippStsNoErr, if no errors
*/
void HighPassFIR_AMRWB_16s_ISfs(
Ipp16s *pSrcDstSignal,
Ipp32s len,
HighPassFIRState_AMRWB_16s_ISfs *pState
);
/*
The encoder and decoder objects structures definitions
*/
typedef struct _SDtxEncoderState
{
short asiIsfHistory[LP_ORDER * DTX_HIST_SIZE];
short siLogEnerHist[DTX_HIST_SIZE];
short siHistPtr;
short siLogEnerIndex;
short siCngSeed;
short siHangoverCount;
short siAnaElapsedCount;
int aiDistMatrix[28];
int aiSumDist[DTX_HIST_SIZE];
} SDtxEncoderState;
typedef struct _SDtxDecoderState
{
short siSidLast;
short siSidPeriodInv;
short siLogEnergy;
short siLogEnergyOld;
short asiIsf[LP_ORDER];
short asiIsfOld[LP_ORDER];
short siCngSeed;
short asiIsfHistory[LP_ORDER * DTX_HIST_SIZE];
short siLogEnerHist[DTX_HIST_SIZE];
short siHistPtr;
short siHangoverCount;
short siAnaElapsedCount;
short siSidFrame;
short siValidData;
short siHangoverAdded;
short siGlobalState;
short siDataUpdated;
short siDitherSeed;
short siComfortNoiseDith;
} SDtxDecoderState;
typedef struct _SAMRWBCoderObj
{
int iObjSize;
int iKey;
unsigned int uiMode; /* coder mode's */
unsigned int uiRez; /* rezerved */
}SAMRWBCoderObj;
struct _AMRWBEncoder_Obj{
SAMRWBCoderObj objPrm;
short asiSpeechDecimate[2*DOWN_SAMPL_FILT_DELAY];
short siPreemph;
short asiSpeechOld[SPEECH_SIZE - FRAME_SIZE];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -