AN2094 Freescale Semiconductor / Motorola, AN2094 Datasheet - Page 38

no-image

AN2094

Manufacturer Part Number
AN2094
Description
ITU-T G.729 Implementation on StarCore SC140
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
References
A.3 Lag_max() - C code
38
Word16 Lag_max(
{
#pragma align *signal 8
/* in the original version, signal pointed to scaled_signal[PIT_MAX]
* now, it points to scaled_signal[0]
*/
Word16 signal[],
Word16 L_frame,
Word16 lag_max,
Word16 lag_min,
Word16 *cor_max)
Word16
Word16
Word32
Word16
Word32
/* check if the signal array is 8-byte aligned */
assert (((int) signal & 7) == 0);
/* initialize the maximum value and the position of the maximum */
max = MIN_32;
p_max = 0;
/* initialize the reference signal pointer used in correlations */
ref_signal = &signal[lag_max];
/* check the necessary condition for 4 samples in parallel */
assert (((lag_max - lag_min + 1) & 3) == 0);
for (i = lag_max - lag_min - 3; i >= 0; i-=4)
{
/*
/*
Word32 c0, c1, c2, c3;
Word16 rs;
Word16 sig0, sig1, sig2, sig3; /* four values from past signals */
/* initialize the correlations */
c0 = 0;
c1 = 0;
c2 = 0;
c3 = 0;
/* fetch needed values for first correlations */
rs = ref_signal[0];
sig0 = signal[i+0];
sig1 = signal[i+1];
sig2 = signal[i+2];
sig3 = signal[i+3];
/*
for (j=0; j < L_FRAME; j+=4)
{
* this loop computes four correlations in parallel
* to create the framework for better ALU usage
*/
* declare the variables as close as possible to their usage
*/
* Unroll next loop into four iterations to reuse previously fetched values.
* The reference signal is not aligned, so one reference sample is used
* for all computations in a phase.
*/
/* in each phase:
c0 = L_mac(c0, rs, sig0);
c1 = L_mac(c1, rs, sig1);
c2 = L_mac(c2, rs, sig2);
c3 = L_mac(c3, rs, sig3);
rs = ref_signal[j+1];
sig0 = signal[i+j+4];
c0 = L_mac(c0, rs, sig1);
c1 = L_mac(c1, rs, sig2);
* - compute a step in the correlations, and
* - fetch next values
*/
i, j; /* loop indexes */
*p, *ref_signal; /* pointers in the signal array */
max; /* maximum corelation and its position */
p_max;
s0, s1; /* partial sums used in split-summation energy computation */
ITU-T G.729 Implementation on the StarCore™ SC140/SC1400 Cores, Rev. 1
/* output: lag found
/* input : signal used to compute the open loop pitch */
/* input : length of frame to compute pitch
/* input : maximum lag
/* input : minimum lag
/* output: normalized correlation of selected lag
Example 11. Lag_max() C code
/* correlations */
/* current value from the reference signal */
*/
*/
*/
*/
*/
Freescale Semiconductor

Related parts for AN2094