?? sp_frm.c
字號:
}
else
{
if (j == psvqIndex[iSegment - 1].len - 2)
{
/* Then recursion to be done for one more lattice stage */
/*------------------------------------------------------*/
/* Copy address of PNew into POld */
/*--------------------------------*/
pL_POld = ppL_PAddrs[(j + 1) % 2];
/* Copy address of the input pL_PBar array into pswPNew; this will */
/* cause the PNew array to overwrite the input pL_PBar array, thus */
/* updating it at the final lattice stage of the current segment */
/*-----------------------------------------------------------------*/
pL_PNew = pL_PBar;
/* Copy address of VNew into VOld */
/*--------------------------------*/
pL_VOld = ppL_VAddrs[(j + 1) % 2];
/* Copy address of the input pL_VBar array into pswVNew; this will */
/* cause the VNew array to overwrite the input pL_VBar array, thus */
/* updating it at the final lattice stage of the current segment */
/*-----------------------------------------------------------------*/
pL_VNew = pL_VBar;
}
}
}
/* Update the pswPBar and pswVBar initial conditions for the AFLAT */
/* Rc-VQ search at the next segment. */
/*----------------------------------------------------------------------*/
bound = psvqIndex[iSegment].len - 1;
for (i = 0; i <= bound; i++)
{
pswPBar[i] = round(pL_PBar[i]);
pswVBar[i] = round(pL_VBar[i]);
}
for (i = -bound; i < 0; i++)
{
pswVBar[i] = round(pL_VBar[i]);
}
return;
}
/***************************************************************************
*
* FUNCTION NAME: aflatRecursion
*
* PURPOSE: Given the Shortword initial condition arrays, pswPBar and
* pswVBar, a reflection coefficient vector from the quantizer
* (or a prequantizer), and the order of the current Rc-VQ
* segment, function aflatRecursion computes and returns the
* residual error energy by evaluating the AFLAT recursion.
*
* This is an implementation of equations 4.18 to 4.23.
* INPUTS:
*
* pswQntRc[0:NP_AFLAT-1]
* An input reflection coefficient vector from the
* Rc-prequantizer or the Rc-VQ codebook.
*
* pswPBar[0:NP_AFLAT-1]
* The input Shortword array containing the P initial
* conditions for the P-V AFLAT recursion at the current
* Rc-VQ segment. The address of the 0-th element of
* pswVBar is passed in.
*
* pswVBar[-NP_AFLAT+1:NP_AFLAT-1]
* The input Shortword array containing the V initial
* conditions for the P-V AFLAT recursion, at the current
* Rc-VQ segment. The address of the 0-th element of
* pswVBar is passed in.
*
* *ppswPAddrs[0:1]
* An input array containing the address of temporary
* space P1 in its 0-th element, and the address of
* temporary space P2 in its 1-st element. Each of
* these addresses is alternately assigned onto
* pswPNew and pswPOld pointers using modulo
* arithmetic, so as to avoid copying the contents of
* pswPNew array into the pswPOld array at the end of
* each lattice stage of the AFLAT recursion.
* Temporary space P1 and P2 is allocated outside
* aflatRecursion by the calling function aflat.
*
* *ppswVAddrs[0:1]
* An input array containing the address of temporary
* space V1 in its 0-th element, and the address of
* temporary space V2 in its 1-st element. Each of
* these addresses is alternately assigned onto
* pswVNew and pswVOld pointers using modulo
* arithmetic, so as to avoid copying the contents of
* pswVNew array into the pswVOld array at the end of
* each lattice stage of the AFLAT recursion.
* Temporary space V1 and V2 is allocated outside
* aflatRecursion by the calling function aflat.
*
* swSegmentOrder
* This input short word describes the number of
* stages needed to compute the vector
* quantization of the given segment.
*
* OUTPUTS:
* None.
*
* RETURN:
* swRe The Shortword value of residual energy for the
* Rc vector, given the pswPBar and pswVBar initial
* conditions.
*
* REFERENCE: Sub-clause 4.1.4.1 GSM Recommendation 06.20
*
*************************************************************************/
Shortword aflatRecursion(Shortword pswQntRc[],
Shortword pswPBar[],
Shortword pswVBar[],
Shortword *ppswPAddrs[],
Shortword *ppswVAddrs[],
Shortword swSegmentOrder)
{
/*_________________________________________________________________________
| |
| Automatic Variables |
|_________________________________________________________________________|
*/
Shortword *pswPOld,
*pswPNew,
*pswVOld,
*pswVNew,
pswQntRcSqd[NP_AFLAT],
swRe;
Longword L_sum;
short int i,
j,
bound; /* loop control variables */
/*_________________________________________________________________________
| |
| Executable Code |
|_________________________________________________________________________|
*/
/* Point to PBar and VBar, the initial condition arrays for the AFLAT */
/* recursion. */
/*---------------------------------------------------------------------*/
pswPOld = pswPBar;
pswVOld = pswVBar;
/* Point to PNew and VNew, the arrays into which updated values of P */
/* and V functions will be written. */
/*---------------------------------------------------------------------*/
pswPNew = ppswPAddrs[1];
pswVNew = ppswVAddrs[1];
/* Compute the residual error energy due to the selected Rc vector */
/* using the AFLAT recursion. */
/*-----------------------------------------------------------------*/
/* Compute rc squared, used by the recursion */
/*-------------------------------------------*/
for (j = 0; j < swSegmentOrder; j++)
{
pswQntRcSqd[j] = mult_r(pswQntRc[j], pswQntRc[j]);
}
/* Compute the residual error energy due to the selected Rc vector */
/* using the AFLAT recursion. */
/*-----------------------------------------------------------------*/
for (j = 0; j < swSegmentOrder - 1; j++)
{
bound = swSegmentOrder - j - 2;
/* Compute Psubj(i), for i = 0, bound */
/*-------------------------------------*/
for (i = 0; i <= bound; i++)
{
L_sum = L_mac(L_ROUND, pswVOld[i], pswQntRc[j]);
L_sum = L_mac(L_sum, pswVOld[-i], pswQntRc[j]);
L_sum = L_mac(L_sum, pswPOld[i], pswQntRcSqd[j]);
L_sum = L_msu(L_sum, pswPOld[i], SW_MIN);
pswPNew[i] = extract_h(L_sum);
}
/* Check if potential for limiting exists. */
/*-----------------------------------------*/
if (sub(pswPNew[0], 0x4000) >= 0)
iLimit = 1;
/* Compute the new Vsubj(i) */
/*--------------------------*/
for (i = -bound; i < 0; i++)
{
L_sum = L_msu(L_ROUND, pswVOld[i + 1], SW_MIN);
L_sum = L_mac(L_sum, pswQntRcSqd[j], pswVOld[-i - 1]);
L_sum = L_mac(L_sum, pswQntRc[j], pswPOld[-i - 1]);
L_sum = L_mac(L_sum, pswQntRc[j], pswPOld[-i - 1]);
pswVNew[i] = extract_h(L_sum);
}
for (i = 0; i <= bound; i++)
{
L_sum = L_msu(L_ROUND, pswVOld[i + 1], SW_MIN);
L_sum = L_mac(L_sum, pswQntRcSqd[j], pswVOld[-i - 1]);
L_sum = L_mac(L_sum, pswQntRc[j], pswPOld[i + 1]);
L_sum = L_mac(L_sum, pswQntRc[j], pswPOld[i + 1]);
pswVNew[i] = extract_h(L_sum);
}
if (j < swSegmentOrder - 2)
{
/* Swap POld and PNew buffers, using modulo addressing */
/*-----------------------------------------------------*/
pswPOld = ppswPAddrs[(j + 1) % 2];
pswPNew = ppswPAddrs[j % 2];
/* Swap VOld and VNew buffers, using modulo addressing */
/*-----------------------------------------------------*/
pswVOld = ppswVAddrs[(j + 1) % 2];
pswVNew = ppswVAddrs[j % 2];
}
}
/* Computing Psubj(0) for the last lattice stage */
/*-----------------------------------------------*/
j = swSegmentOrder - 1;
L_sum = L_mac(L_ROUND, pswVNew[0], pswQntRc[j]);
L_sum = L_mac(L_sum, pswVNew[0], pswQntRc[j]);
L_sum = L_mac(L_sum, pswPNew[0], pswQntRcSqd[j]);
L_sum = L_msu(L_sum, pswPNew[0], SW_MIN);
swRe = extract_h(L_sum);
/* Return the residual energy corresponding to the reflection */
/* coefficient vector being evaluated. */
/*--------------------------------------------------------------*/
return (swRe); /* residual error is returned */
}
/***************************************************************************
*
* FUNCTION NAME: bestDelta
*
* PURPOSE:
*
* This function finds the delta-codeable lag which maximizes CC/G.
*
* INPUTS:
*
* pswLagList[0:siNumLags-1]
*
* List of delta-codeable lags over which search is done.
*
* pswCSfrm[0:127]
*
* C(k) sequence, k integer.
*
* pswGSfrm[0:127]
*
* G(k) sequence, k integer.
*
* siNumLags
*
* Number of lags in contention.
*
* siSfrmIndex
*
* The index of the subframe to which the delta-code
* applies.
*
*
* OUTPUTS:
*
* pswLTraj[0:3]
*
* The winning lag is put into this array at
* pswLTraj[siSfrmIndex]
*
* pswCCTraj[0:3]
*
* The corresponding winning C**2 is put into this
* array at pswCCTraj[siSfrmIndex]
*
* pswGTraj[0:3]
*
* The corresponding winning G is put into this arrray
* at pswGTraj[siSfrmIndex]
*
* RETURN VALUE:
*
* none
*
* DESCRIPTION:
*
* REFERENCE: Sub-clause 4.1.8.3 of GSM Recommendation 06.20
*
* KEYWORDS:
*
*************************************************************************/
void bestDelta(Shortword pswLagList[],
Shortword pswCSfrm[],
Shortword pswGSfrm[],
short int siNumLags,
short int siSfrmIndex,
Shortword pswLTraj[],
Shortword pswCCTraj[],
Shortword pswGTraj[])
{
/*_________________________________________________________________________
| |
| Automatic Variables |
|_________________________________________________________________________|
*/
Shortword pswCBuf[DELTA_LEVELS + CG_INT_MACS + 2],
pswGBuf[DELTA_LEVELS + CG_INT_MACS + 2],
pswCInterp[DELTA_LEVELS + 2],
pswGInterp[DELTA_LEVELS + 2],
*psw1,
*psw2,
swCmaxSqr,
swGmax,
swPeak;
short int siIPLo,
siRemLo,
siIPHi,
siRemHi,
siLoLag,
siHiLag,
siI;
/*_________________________________________________________________________
| |
| Executable Code |
|_________________________________________________________________________|
*/
/* get bounds for integer C's and G's needed for interpolation */
/* get integer and fractional portions of boundary lags */
/* ----------------------------------------------------------- */
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -