/* ** ** Function: Dec_Cng() ** ** Description: Receives Ftyp ** 0 : for untransmitted frames ** 2 : for SID frames ** Decodes SID frames ** Computes current frame excitation ** Computes current frame LSPs ** ** Links to text: ** ** Arguments: ** ** int16_t Ftyp Type of silence frame ** LINEDEF *Line Coded parameters ** int16_t *DataExc Current frame excitation ** int16_t *QntLpc Interpolated frame LPC coefficients ** ** Outputs: ** ** int16_t *DataExc ** int16_t *QntLpc ** ** Return value: None ** */ void Dec_Cng(int16_t Ftyp, LINEDEF * Line, int16_t * DataExc, int16_t * QntLpc) { int16_t temp; int i; if (Ftyp == 2) { /* * SID Frame decoding */ DecCng.SidGain = Dec_SidGain(Line->Sfs[0].Mamp); /* Inverse quantization of the LSP */ Lsp_Inq(DecCng.LspSid, DecStat.PrevLsp, Line->LspId, 0); } else { /* * non SID Frame */ if (DecCng.PastFtyp == 1) { /* * Case of 1st SID frame erased : quantize-decode * energy estimate stored in DecCng.SidGain * scaling factor in DecCng.CurGain */ temp = Qua_SidGain(&DecCng.SidGain, &DecCng.CurGain, 0); DecCng.SidGain = Dec_SidGain(temp); } } if (DecCng.PastFtyp == 1) { DecCng.CurGain = DecCng.SidGain; } else { DecCng.CurGain = g723_extract_h(L_g723_add (L_g723_mult(DecCng.CurGain, 0x7000), L_g723_mult(DecCng.SidGain, 0x1000))); } Calc_Exc_Rand(DecCng.CurGain, DecStat.PrevExc, DataExc, &DecCng.RandSeed, Line); /* Interpolate the Lsp vectors */ Lsp_Int(QntLpc, DecCng.LspSid, DecStat.PrevLsp); /* Copy the LSP vector for the next frame */ for (i = 0; i < LpcOrder; i++) DecStat.PrevLsp[i] = DecCng.LspSid[i]; return; }
void Dec_Cng(Word16 Ftyp, LINEDEF *Line, Word16 *DataExc, Word16 *QntLpc,DEC_HANDLE *handle) { Word16 temp; int i; if(Ftyp == 2) { /* * SID Frame decoding */ handle->DecCng.SidGain = Dec_SidGain(Line->Sfs[0].Mamp); /* Inverse quantization of the LSP */ Lsp_Inq( handle->DecCng.LspSid, handle->DecStat.PrevLsp, Line->LspId, 0) ; } else { /* * non SID Frame */ if(handle->DecCng.PastFtyp == 1) { /* * Case of 1st SID frame erased : quantize-decode * energy estimate stored in DecCng.SidGain * scaling factor in DecCng.CurGain */ temp = Qua_SidGain(&handle->DecCng.SidGain, &handle->DecCng.CurGain, 0); handle->DecCng.SidGain = Dec_SidGain(temp); } } if(handle->DecCng.PastFtyp == 1) { handle->DecCng.CurGain = handle->DecCng.SidGain; } else { handle->DecCng.CurGain = extract_h(L_add( L_mult(handle->DecCng.CurGain,0x7000), L_mult(handle->DecCng.SidGain,0x1000) ) ) ; } Calc_Exc_Rand(handle->DecCng.CurGain, handle->DecStat.PrevExc, DataExc, &handle->DecCng.RandSeed, Line,handle->mode); /* Interpolate the Lsp vectors */ Lsp_Int( QntLpc, handle->DecCng.LspSid, handle->DecStat.PrevLsp ) ; /* Copy the LSP vector for the next frame */ for ( i = 0 ; i < LpcOrder ; i ++ ) handle->DecStat.PrevLsp[i] = handle->DecCng.LspSid[i] ; return; }