?? sp_frm.c
字號:
get_ipjj(pswLagList[0], &siIPLo, &siRemLo);
get_ipjj(pswLagList[siNumLags - 1], &siIPHi, &siRemHi);
/* get lag for first and last C and G required */
/* ------------------------------------------- */
siLoLag = sub(siIPLo, CG_INT_MACS / 2 - 1);
if (siRemHi != 0)
{
siHiLag = add(siIPHi, CG_INT_MACS / 2);
}
else
{
siHiLag = add(siIPHi, CG_INT_MACS / 2 - 1);
}
/* transfer needed integer C's and G's to temp buffers */
/* --------------------------------------------------- */
psw1 = pswCBuf;
psw2 = pswGBuf;
if (siRemLo == 0)
{
/* first lag in list is integer: don't care about first entries */
/* (they will be paired with zero tap in interpolating filter) */
/* ------------------------------------------------------------ */
psw1[0] = 0;
psw2[0] = 0;
psw1 = &psw1[1];
psw2 = &psw2[1];
}
for (siI = siLoLag; siI <= siHiLag; siI++)
{
psw1[siI - siLoLag] = pswCSfrm[siI - LSMIN];
psw2[siI - siLoLag] = pswGSfrm[siI - LSMIN];
}
if (siRemLo == 0)
{
/* make siLoLag correspond to first entry in temp buffers */
/* ------------------------------------------------------ */
siLoLag = sub(siLoLag, 1);
}
/* interpolate to get C's and G's which correspond to lags in list */
/* --------------------------------------------------------------- */
CGInterp(pswLagList, siNumLags, pswCBuf, pswGBuf, siLoLag,
pswCInterp, pswGInterp);
/* find max C*C*sgn(C)/G */
/* --------------------- */
swPeak = maxCCOverGWithSign(pswCInterp, pswGInterp, &swCmaxSqr, &swGmax,
siNumLags);
/* store best lag and corresponding C*C and G */
/* ------------------------------------------ */
pswLTraj[siSfrmIndex] = pswLagList[swPeak];
pswCCTraj[siSfrmIndex] = swCmaxSqr;
pswGTraj[siSfrmIndex] = swGmax;
}
/***************************************************************************
*
* FUNCTION NAME: CGInterp
*
* PURPOSE:
*
* Given a list of fractional lags, a C(k) array, and a G(k) array
* (k integer), this function generates arrays of C's and G's
* corresponding to the list of fractional lags by interpolating the
* integer C(k) and G(k) arrays.
*
* INPUTS:
*
* pswLIn[0:siNum-1]
*
* List of valid lags
*
* siNum
*
* Length of output lists
*
* pswCIn[0:variable]
*
* C(k) sequence, k integer. The zero index corresponds
* to k = siLoIntLag.
*
* pswGIn[0:variable]
*
* G(k) sequence, k integer. The zero index corresponds
* to k = siLoIntLag.
*
* siLoIntLag
*
* Integer lag corresponding to the first entry in the
* C(k) and G(k) input arrays.
*
* ppsrCGIntFilt[0:5][0:5]
*
* The FIR interpolation filter for C's and G's.
*
* OUTPUTS:
*
* pswCOut[0:siNum-1]
*
* List of interpolated C's corresponding to pswLIn.
*
* pswGOut[0:siNum-1]
*
* List of interpolated G's corresponding to pswLIn
*
* RETURN VALUE: none
*
* DESCRIPTION:
*
*
* REFERENCE: Sub-clause 4.1.8.2, 4.1.8.3 of GSM Recommendation 06.20
*
* KEYWORDS: lag, interpolateCG
*
*************************************************************************/
void CGInterp(Shortword pswLIn[],
short siNum,
Shortword pswCIn[],
Shortword pswGIn[],
short siLoIntLag,
Shortword pswCOut[],
Shortword pswGOut[])
{
/*_________________________________________________________________________
| |
| Automatic Variables |
|_________________________________________________________________________|
*/
Shortword i,
swBig,
swLoIntLag;
Shortword swLagInt,
swTempRem,
swLagRem;
Longword L_Temp,
L_Temp1,
L_Temp2;
/*_________________________________________________________________________
| |
| Executable Code |
|_________________________________________________________________________|
*/
swLoIntLag = add(siLoIntLag, (CG_INT_MACS / 2) - 1);
for (swBig = 0; swBig < siNum; swBig++)
{
/* Separate integer and fractional portions of lag */
/*-------------------------------------------------*/
L_Temp = L_mult(pswLIn[swBig], INV_OS_FCTR);
swLagInt = extract_h(L_Temp);
/* swLagRem = (OS_FCTR - pswLIn[iBig] % OS_FCTR)) */
/*---------------------------------------------------*/
swTempRem = extract_l(L_Temp);
swTempRem = shr(swTempRem, 1);
swLagRem = swTempRem & SW_MAX;
swLagRem = mult_r(swLagRem, OS_FCTR);
swLagRem = sub(OS_FCTR, swLagRem);
/* Get interpolated C and G values */
/*--------------------------*/
L_Temp1 = L_mac(32768, pswCIn[swLagInt - swLoIntLag],
ppsrCGIntFilt[0][swLagRem]);
L_Temp2 = L_mac(32768, pswGIn[swLagInt - swLoIntLag],
ppsrCGIntFilt[0][swLagRem]);
for (i = 1; i <= CG_INT_MACS - 1; i++)
{
L_Temp1 = L_mac(L_Temp1, pswCIn[i + swLagInt - swLoIntLag],
ppsrCGIntFilt[i][swLagRem]);
L_Temp2 = L_mac(L_Temp2, pswGIn[i + swLagInt - swLoIntLag],
ppsrCGIntFilt[i][swLagRem]);
}
pswCOut[swBig] = extract_h(L_Temp1);
pswGOut[swBig] = extract_h(L_Temp2);
}
}
/***************************************************************************
*
* FUNCTION NAME: CGInterpValid
*
* PURPOSE:
*
* The purpose of this function is to retrieve the valid (codeable) lags
* within one (exclusive) integer sample of the given integer lag, and
* interpolate the corresponding C's and G's from the integer arrays
*
* INPUTS:
*
* swFullResLag
*
* integer lag * OS_FCTR
*
* pswCIn[0:127]
*
* integer C sequence
*
* pswGIn[0:127]
*
* integer G sequence
*
* psrLagTbl[0:255]
*
* reference table of valid (codeable) lags
*
*
* OUTPUTS:
*
* pswLOut[0:*psiNum-1]
*
* list of valid lags within 1 of swFullResLag
*
* pswCOut[0:*psiNum-1]
*
* list of interpolated C's corresponding to pswLOut
*
* pswGOut[0:*psiNum-1]
*
* list of interpolated G's corresponding to pswLOut
*
* RETURN VALUE:
*
* siNum
*
* length of output lists
*
* DESCRIPTION:
*
* REFERENCE: Sub-clause 4.1.8.2, 4.1.9 of GSM Recommendation 06.20
*
* KEYWORDS: CGInterpValid, cginterpvalid, CG_INT_VALID
*
*************************************************************************/
short CGInterpValid(Shortword swFullResLag,
Shortword pswCIn[],
Shortword pswGIn[],
Shortword pswLOut[],
Shortword pswCOut[],
Shortword pswGOut[])
{
/*_________________________________________________________________________
| |
| Automatic Variables |
|_________________________________________________________________________|
*/
short int siLowerBound,
siUpperBound,
siNum,
siI;
Shortword swLag;
/*_________________________________________________________________________
| |
| Executable Code |
|_________________________________________________________________________|
*/
/* Get lower and upper bounds for valid lags */
/* within 1 (exclusive) integer lag of input lag */
/* --------------------------------------------- */
swLag = sub(swFullResLag, OS_FCTR);
swLag = quantLag(swLag, &siLowerBound);
if (sub(swLag, swFullResLag) != 0)
{
siLowerBound = add(siLowerBound, 1);
}
swLag = add(swFullResLag, OS_FCTR);
swLag = quantLag(swLag, &siUpperBound);
if (sub(swLag, swFullResLag) != 0)
{
siUpperBound = sub(siUpperBound, 1);
}
/* Get list of full resolution lags whose */
/* C's and G's will be interpolated */
/* -------------------------------------- */
siNum = sub(siUpperBound, siLowerBound);
siNum = add(siNum, 1);
for (siI = 0; siI < siNum; siI++)
{
pswLOut[siI] = psrLagTbl[siI + siLowerBound];
}
/* Interpolate C's and G's */
/* ----------------------- */
CGInterp(pswLOut, siNum, pswCIn, pswGIn, LSMIN, pswCOut,
pswGOut);
/* Return the length of the output lists */
/* ------------------------------------- */
return (siNum);
}
/***************************************************************************
*
* FUNCTION NAME: compResidEnergy
*
* PURPOSE:
*
* Computes and compares the residual energy from interpolated and
* non-interpolated coefficients. From the difference determines
* the soft interpolation decision.
*
* INPUTS:
*
* pswSpeech[0:159] ( [0:F_LEN-1] )
*
* Input speech frame (after high-pass filtering).
*
* ppswInterpCoef[0:3][0:9] ( [0:N_SUB-1][0:NP-1] )
*
* Set of interpolated LPC direct-form coefficients for
* each subframe.
*
* pswPreviousCoef[0:9} ( [0:NP-1] )
*
* Set of LPC direct-form coefficients corresponding to
* the previous frame
*
* pswCurrentCoef[0:9} ( [0:NP-1] )
*
* Set of LPC direct-form coefficients corresponding to
* the current frame
*
* psnsSqrtRs[0:3] ( [0:N_SUB-1] )
*
* Array of residual energy estimates for each subframe
* based on interpolated coefficients. Used for scaling.
*
* RETURN:
*
* Returned value indicates the coefficients to use for each subframe:
* One indicates interpolated coefficients are to be used, zero indicates
* un-interpolated coefficients are to be used.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -