📄 g7231_coder.c
字号:
#include "typedef.h"
#include "G7231_basop.h"
#include "G7231_cst_lbc.h"
#include "G7231_tab_lbc.h"
#include "G7231_coder.h"
#include "G7231_lpc.h"
#include "G7231_lsp.h"
#include "G7231_exc_lbc.h"
#include "G7231_util_lbc.h"
#include "G7231_vad.h"
#include "G7231_cod_cng.h"
#include "G7231_tame.h"
#include "intrindefs.h"
G7231CODSTATDEF G7231CodStat ;
void G7231Init_Coder(int rate)
{
int i ;
memset(&G7231CodStat, 0, sizeof(G7231CODSTATDEF));
G7231CodStat.WrkRate = (rate ? Rate53 : Rate63);
for ( i = 0 ; i < G7231LpcOrder ; i ++ )
G7231CodStat.PrevLsp[i] = G7231LspDcTable[i] ;
for(i=0; i<G7231SizErr; i++) G7231CodStat.Err[i] = G7231Err0;
//Init_Vad();
//Init_Cod_Cng( );
return;
}
Flag G7231Coder( Word16 *DataBuff, char *Vout )
{
int i,j ;
Word16 UnqLpc[G7231SubFrames*G7231LpcOrder] ;
Word16 QntLpc[G7231SubFrames*G7231LpcOrder] ;
Word16 PerLpc[2*G7231SubFrames*G7231LpcOrder] ;
Word16 LspVect[G7231LpcOrder] ;
G7231LINEDEF Line ;
G7231PWDEF Pw[G7231SubFrames] ;
Word16 ImpResp[G7231SubFrLen] ;
Word16 *Dpnt ;
Word16 Ftyp = 1 ;
Line.Crc = (Word16) 0 ;
G7231Rem_Dc( DataBuff ) ;
G7231Comp_Lpc( UnqLpc, G7231CodStat.PrevDat, DataBuff ) ;
G7231AtoLsp( LspVect, &UnqLpc[G7231LpcOrder*(G7231SubFrames-1)], G7231CodStat.PrevLsp ) ;
Ftyp = (Word16) G7231Comp_Vad( DataBuff ) ;
Line.LspId = G7231Lsp_Qnt( LspVect, G7231CodStat.PrevLsp ) ;
G7231Mem_Shift( G7231CodStat.PrevDat, DataBuff ) ;
G7231Wght_Lpc( PerLpc, UnqLpc ) ;
G7231Error_Wght( DataBuff, PerLpc ) ;
Dpnt = (Word16 *) malloc( sizeof(Word16)*(G7231PitchMax+G7231Frame) ) ;
for ( i = 0 ; i < G7231PitchMax ; i ++ )
Dpnt[i] = G7231CodStat.PrevWgt[i] ;
for ( i = 0 ; i < G7231Frame ; i ++ )
Dpnt[G7231PitchMax+i] = DataBuff[i] ;
G7231Vec_Norm( Dpnt, (Word16) (G7231PitchMax+G7231Frame) ) ;
j = G7231PitchMax ;
for ( i = 0 ; i < G7231SubFrames/2 ; i ++ ) {
Line.Olp[i] = G7231Estim_Pitch( Dpnt, (Word16) j ) ;
G7231VadStat.Polp[i+2] = Line.Olp[i] ;
j += 2*G7231SubFrLen ;
}
if(Ftyp != 1) {
free ( (char *) Dpnt ) ;
for ( i = 0 ; i < G7231PitchMax ; i ++ )
G7231CodStat.PrevWgt[i] = DataBuff[i+G7231Frame-G7231PitchMax] ;
G7231Cod_Cng(DataBuff, &Ftyp, &Line, QntLpc);
Dpnt = DataBuff;
for( i = 0 ; i < G7231SubFrames; i++ ) {
G7231Update_Err(Line.Olp[i>>1], Line.Sfs[i].AcLg, Line.Sfs[i].AcGn);
G7231Upd_Ring( Dpnt, &QntLpc[i*G7231LpcOrder], &PerLpc[i*2*G7231LpcOrder],
G7231CodStat.PrevErr ) ;
Dpnt += G7231SubFrLen;
}
}
else {
j = G7231PitchMax ;
for ( i = 0 ; i < G7231SubFrames ; i ++ ) {
Pw[i] = G7231Comp_Pw( Dpnt, (Word16) j, Line.Olp[i>>1] ) ;
j += G7231SubFrLen ;
}
for ( i = 0 ; i < G7231PitchMax ; i ++ )
Dpnt[i] = G7231CodStat.PrevWgt[i] ;
for ( i = 0 ; i < G7231Frame ; i ++ )
Dpnt[G7231PitchMax+i] = DataBuff[i] ;
for ( i = 0 ; i < G7231PitchMax ; i ++ )
G7231CodStat.PrevWgt[i] = Dpnt[G7231Frame+i] ;
j = 0 ;
for ( i = 0 ; i < G7231SubFrames ; i ++ ) {
G7231Filt_Pw( DataBuff, Dpnt, (Word16) j , Pw[i] ) ;
j += G7231SubFrLen ;
}
free ( (char *) Dpnt ) ;
G7231Lsp_Inq( LspVect, G7231CodStat.PrevLsp, Line.LspId, Line.Crc ) ;
G7231Lsp_Int( QntLpc, LspVect, G7231CodStat.PrevLsp ) ;
for ( i = 0 ; i < G7231LpcOrder ; i ++ )
G7231CodStat.PrevLsp[i] = LspVect[i] ;
Dpnt = DataBuff ;
for ( i = 0 ; i < G7231SubFrames ; i ++ ) {
G7231Comp_Ir( ImpResp, &QntLpc[i*G7231LpcOrder],
&PerLpc[i*2*G7231LpcOrder], Pw[i] ) ;
G7231Sub_Ring( Dpnt, &QntLpc[i*G7231LpcOrder], &PerLpc[i*2*G7231LpcOrder],
G7231CodStat.PrevErr, Pw[i] ) ;
G7231Find_Acbk( Dpnt, ImpResp, G7231CodStat.PrevExc, &Line, (Word16) i ) ;
G7231Find_Fcbk( Dpnt, ImpResp, &Line, (Word16) i ) ;
G7231Decod_Acbk_En( ImpResp, G7231CodStat.PrevExc, Line.Olp[i>>1],
Line.Sfs[i].AcLg, Line.Sfs[i].AcGn ) ;
for ( j = G7231SubFrLen ; j < G7231PitchMax ; j ++ )
G7231CodStat.PrevExc[j-G7231SubFrLen] = G7231CodStat.PrevExc[j] ;
for ( j = 0 ; j < G7231SubFrLen ; j ++ ) {
Dpnt[j] = G7231shl( Dpnt[j], (Word16) 1 ) ;
Dpnt[j] = G7231add( Dpnt[j], ImpResp[j] ) ;
G7231CodStat.PrevExc[G7231PitchMax-G7231SubFrLen+j] = Dpnt[j] ;
}
G7231Update_Err(Line.Olp[i>>1], Line.Sfs[i].AcLg, Line.Sfs[i].AcGn);
G7231Upd_Ring( Dpnt, &QntLpc[i*G7231LpcOrder], &PerLpc[i*2*G7231LpcOrder],
G7231CodStat.PrevErr ) ;
Dpnt += G7231SubFrLen ;
}
G7231CodCng.PastFtyp = 1;
G7231CodCng.RandSeed = 12345;
}
G7231Line_Pack( &Line, Vout, Ftyp ) ;
return (Flag) True ;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -