
                                                                                          549
---------------------Page 550---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

Syntax
QplStatus qplsEnvelopFrequency_G7291_16s(const Qpl16s pSrc[64], Qpl16s
pDstEnvelopFreq[12]  );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h , qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrc                         Pointer to the original highband input signal.

pDstEnvelopFreq              Pointer to the output frequency envelope parameters.

Description
This function calculates the frequency envelope parameters. To calculate 12 frequency envelope parameters,
the pSrc signal is windowed and transformed by FFT with 64 elements. Finally, the frequency envelope
parameters are calculated as logarithmic weighted subband energies for 12 evenly spaced and wide
overlapping subbands in the FFT domain. See [ITU7291] section 6.5.2.

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointers is NULL.

GenerateExcitationGetStateSize_G7291
Calculates the size of the state memory for generation
of the excitation signal.

Syntax
QplStatus qplsGenerateExcitationGetStateSize_G7291_16s(int* pSize        );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h , qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSize                        Pointer to the output value of the memory size.

Description
This function computes the size of the external buffer for state of generation of the excitation signal and
store the result in pSize.

   550
---------------------Page 551---------------------

                                                                     Speech Coding Functions  9 

Return Values

qplStsNoErr                      Indicates no error.

qplStsNullPtrErr                 Indicates an error when the pSize pointer is NULL.

GenerateExcitationInit_G7291
Initializes the state memory for generation of the
excitation signal.

Syntax
QplStatus qplsGenerateExcitationInit_G7291_16s(QplsGenerateExcitationState_G7291_16s*
pState);

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pState                      Pointer to the memory supplied for generation of the excitation
                            signal.

Description
This function initializes the state structure pState for generation of the excitation signal. The size of this
structure must be computed previously by calling the function GenerateExcitationGetStateSize_G7291.

Return Values

qplStsNoErr                      Indicates no error.

qplStsNullPtrErr                 Indicates an error when the pState pointer is NULL.

GenerateExcitation_G7291
Performs generation of the excitation signal.

Syntax
QplStatus qplsGenerateExcitation_G7291_16s(const Qpl16s pIntPitchLag[4], const Qpl16s
pFracPitchLag[4], const Qpl32s pLtpPower[4], const Qpl32s pFixPower[4], Qpl16s
pDst[80], QplsGenerateExcitationState_G7291_16s* pState     );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

                                                                                         551
---------------------Page 552---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

Parameters

pIntPitchLag                 Pointer to the integer part of pitch lag.

pFracPitchLag                Pointer to the fractional part of pitch lag.

pLtpPower                    Pointer to the ltp power ratio.

pFixPower                    Pointer to the fix power ratio.

pDst                         Pointer to the output vector.

pState                       Pointer to the memory supplied for generation of the excitation
                             signal.

Description
This function generates TDBWE excitation according to [ITU7291] section 7.2.2.

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointers is NULL.

ShapeEnvelopTime_G7291
Performs the shaping of the time envelope of the
excitation signal.

Syntax
QplStatus qplsShapeEnvelopTime_G7291_16s(const Qpl16s pSrc[80], const Qpl16s
pSrcEnvelopTime[8], Qpl16s* pSrcDstGain, Qpl16s* pSrcDstNorm, Qpl16s pDst[208]          );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h , qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrc                         Pointer to the excitation input signal.

pSrcEnvelopTime              Pointer to the desired time envelope.

pSrcDstGain                  Pointer to the input/output gain of the time envelope shaping.

pSrcDstNorm                  Pointer to the input/output norm of the time envelope shaping.

pDst                         Pointer to the shaped output signal.

Description
The shaping of the time envelope of the excitation signal utilizes the decode time envelope parameters to
obtain a signal with a time envelope which is near-identical to the time envelope of the encoder side higher-
band signal. See [ITU7291] section 7.2.3.

   552
---------------------Page 553---------------------

                                                                     Speech Coding Functions  9 

Return Values

qplStsNoErr                      Indicates no error.

qplStsNullPtrErr                 Indicates an error when one of the specified pointers is NULL.

ShapeEnvelopFrequency_G7291
Performs the shaping of the frequency envelope of the
excitation signal.

Syntax
QplStatus qplsShapeEnvelopFrequency_G7291_16s(const Qpl16s pSrc[208], const Qpl16s
pSrcEnvelopFreq[12], Qpl16s pDst[80], Qpl16s pDstFilterCoeffs[33], Qpl16s pMem[32]       );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrc                        Pointer to the excitation input signal.

pSrcEnvelopFreq             Pointer to the input desired frequency envelope.

pDst                        Pointer to the shaped output signal.

pDstFilterCoeffs            Pointer to the filtering coefficients of the frequency envelope
                            shaping.
pMem                        Pointer to the memory supplied for frequency envelope parameters.

Description
The shaping of the frequency envelope of the excitation signal utilizes the decode frequency envelope
parameters to obtain a signal with a frequency envelope which is near-identical to the frequency envelope of
the encoder side higher-band signal. See [ITU7291] section 7.2.4.

Return Values

qplStsNoErr                      Indicates no error.

qplStsNullPtrErr                 Indicates an error when one of the specified pointers is NULL.

CompressEnvelopTime_G7291
Performs an adaptive amplitude compression.

Syntax
QplStatus qplsCompressEnvelopTime_G7291_16s(const Qpl16s pSrcEnvelopTime[28], Qpl16s
pSrcDst[160], Qpl16s pMem[2]  );

Include Files
qplsc.h

                                                                                         553
---------------------Page 554---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcEnvelopTime              Pointer to the desired time envelope .

pSrcDst                      Pointer to the shaped input/output signal.

pMem                         Pointer to the input/output memory for two past time envelope
                             parameters.

Description
The function shapes the excitation signal in time domain and performs adaptive amplitude compression in
order to attenuate large deviations from this envelope according to [ITU7291] section 7.2.5.

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointers is NULL.

MDCTFwd_G7291
Computes forward MDCT.

Syntax
QplStatus qplsMDCTFwd_G7291_16s(const Qpl16s pSrc[160], Qpl16s pSrcDst[160], Qpl16s*
pSrcDstNorm, Qpl16s pDstMDCTCoeffs[160], QplHintAlgorithm hint       );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrc                         Pointer to the input signal.

pSrcDst                      Pointer to the old input/output signal.

pDstNorm                     Pointer to the output normalization factor.

pDstMDCTCoeffs               Pointer to the output MDCT coefficients.

hint                         Suggests using specific code

Description
The function computes forward MDCT and returns used normalization factor. See [ITU7291] section 6.6.3.

Return Values

qplStsNoErr                       Indicates no error.

   554
---------------------Page 555---------------------

                                                                    Speech Coding Functions  9 

qplStsNullPtrErr                 Indicates an error when one of the specified pointers is NULL.

MDCTInv_G7291
Computes inverse MDCT.

Syntax
QplStatus qplsMDCTInv_G7291_16s(const Qpl16s pMDCTCoeffs[160], Qpl16s
pSrcDstMDCTPrevCoeffs[160], Qpl16s pDst[160], Qpl16s scaleFactor    );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pMDCTCoeffs                 Pointer to the MDCT coefficients.

pSrcDstMDCTPrevCoeffs       Pointer to the old input/output MDCT memory.

pDst                        Pointer to the output signal.

scaleFactor                 Scale factor for the normalization MDCT coefficients.

Description
The function computes inverse MDCT using given normalization factor. See [ITU7291] section 7.3.8.

Return Values

qplStsNoErr                      Indicates no error.

qplStsNullPtrErr                 Indicates an error when any of the input or output pointers is
                                 NULL.
qplStsRangeErr                   Indicates an error when scaleFactor is less than zero.

MDCTQuantFwd_G7291
Performs split spherical vector quantization.

Syntax
QplStatus qplsMDCTQuantFwd_G7291_16s32u(const Qpl16s pMDCTCoeffs[320], const Qpl16s
pBitsNumber[18], Qpl32u pDst[18]  );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

                                                                                       555
---------------------Page 556---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

Parameters

pMDCTCoeffs                  Pointer to the MDCT coefficients.

pBitsNumber                  Pointer to the input number of bits allocated per subbands.

pDst                         Pointer to the output vector quantization.

Description
This function perform spherical vector quantization. This operation id divided into two steps: search for the
best codevector and indexing of the selected codevector. See [ITU7291] section 6.6.9.

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointers is NULL.

MDCTQuantInv_G7291
Performs inverse split spherical vector quantization.

Syntax
QplStatus qplsMDCTQuantInv_G7291_32u16s(const Qpl32u pSrc[18], const Qpl16s
pBitsNumber[18], const Qpl16s pQuantSpecEnv[18], Qpl16s pDstMDCTCoeffs[320]         );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrc                         Pointer to the input vector quantization indices.

pBitsNumber                  Pointer to the input number of bits allocated per subbands.

pQuantSpecEnv                Pointer to the input quantized spectrum envelope.

pDstMDCTCoeffs               Pointer to the output MDCT coefficients.

Description
This function decoding of MDCT vector quantization indices. See [ITU7291] section 7.3.5.

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointers is NULL.

MDCTPostProcess_G7291
Performs post-processing oh higher-band MDCT
coefficients.

   556
---------------------Page 557---------------------

                                                                    Speech Coding Functions  9 

Syntax
QplStatus qplsMDCTPostProcess_G7291_16s(Qpl16s pSrcDstMDCTCoeffs[160], int numBits      );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcDstMDCTCoeffs           Pointer to the input/output MDCT coefficients.

numBits                     Number of bits to decode.

Description
This function performs MDCT short-term and long-term post-processing in high band. See [ITU7291] section
7.3.7.

Return Values

qplStsNoErr                      Indicates no error.

qplStsNullPtrErr                 Indicates an error when pSrcDstMDCTCoeffs  pointer is NULL.

qplStsRangeErr                   Indicates an error when numBits is less than 160 or greater
                                 than 640.

GainControl_G7291
Calculates adaptive gain control.

Syntax
QplStatus qplsGainControl_G7291_16s_I(const Qpl16s pSrc[40], Qpl16s pSrcDst[40],
Qpl16s* pSrcDstGain, Qpl16s gain, Qpl16s valGainSwitching, Qpl32s* pSrcDstSmoothLevel      );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrc                        Pointer to the source reconstructed speech vector.

pSrcDst                     Pointer to the input post-filtered signal and output gain-
                            compensated signal vector.
pSrcDstGain                 Pointer to the input/output adaptive gain.

gain                        First reflection coefficient.

                                                                                        557
---------------------Page 558---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

valGainSwitching             Gain attenuation factor.

pSrcDstSmoothLevel           Pointer to the input/output smooth level.

Description
This function performs gain control directly derived from the G.729 with some modifications described in
[ITU7291] section 7.4.1.

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointers is NULL.

TiltCompensation_G7291
Compensates for the tilt in the short-term filter.

Syntax
QplStatus qplsTiltCompensation_G7291_16s(const Qpl16s pSrc[40], Qpl16s pDst[40], Qpl16s
gain);

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrc                         Pointer to the gamma weighted LP coefficients input vector.

pDst                         Pointer to the present and tilt-compensated output speech.

gain                         Gain coefficient.

Description
This function performs FIR filtering to compensate the tilt in the short-term filter. See [ITU7291] section
7.3.10.

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointers is NULL.

QuantParam_G7291
Quantizes of the TDBWE parameter set by "mean
removed VQ".

Syntax
QplStatus qplsQuantParam_G7291_16s(Qpl16s pSrcDst[28], Qpl16s pCdbkIndices[4]         );

   558
---------------------Page 559---------------------

                                                                      Speech Coding Functions  9 

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcDst                      Pointer to the source/destination unquantized parameter set.

pCdbkIndices                 Pointer to the codebook indices.

Description
This function quantizes of the TDBWE parameter set by "mean removed VQ". For more details see [ITU7291]
section 6.5.3.

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointers is NULL.

G.723.1 Functions
The Intel QPL functions described in this section implement building blocks that can be used to create speech
codecs compliant with the ITU-T Recommendation G.723.1 (see [ITU723], [ITU723A]).
These functions are used in the Intel QPL G.723.1 Speech Encoder-Decoder sample downloadable from
http://www.intel.com/cd/software/products/asmo-na/eng/220046.htm.

Linear Prediction Analysis Functions
These functions perform LPC analysis, LSP coding (quantization) and decoding, as well as transformation
between LPC and LSF coefficients.

AutoCorr_G723
Estimates the autocorrelation of a vector.

Syntax
QplStatus qplsAutoCorr_G723_16s(const Qpl16s* pSrcSpch, Qpl16s* pResultAutoCorrExp,
Qpl16s* pDstAutoCorr  );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

                                                                                           559
---------------------Page 560---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

Parameters

pSrcSpch                      Pointer to the input speech signal vector [180].

pResultAutoCorrExp            Pointer to the exponent for autocorrelation coefficients.

pDstAutoCorr                  Pointer to the autocorrelation coefficients vector [11].

Description
This function calculates the first 11 autocorrelation coefficients of the input speech signal. This function is
applied to the 180 speech samples centered on the current subframe. The functionality is as follows:
1. First, apply to speech samples the Hamming windows, given by the following formula:

i = 0, 1, ...,179
2. Next, calculate the autocorrelations as follows:

k = 0,1,...,10
3. Finally, add the autocorrelation with binomial window, given by:
b(0) = 1025/1024  ,

i = 1,...,10 .

     NOTE
     The functionqplsAutoCorr_G723   is actually a combination of qplsAutoScale , qplsMul_NR and
     qplsAutoCorr_NormE_G723     functions. The following code details the correspondence:

{ int autoScale=3, corrScale; short vect[180]; qplsAutoScale_16s(pSrcSpch, Vect,180, &autoScale ); /* 
Apply the Hamming window */  qplsMul_NR_16s_ISfs(HammWindow,Vect,180,15);  /* Compute the 
autocorrelation coefficients */    qplsAutoCorr_NormE_G723_16s(Vect,pDstAutoCorr,&corrScale);  
*pResultAutoCorrExp = corrScale+(autoScale<<1); }

Return Values

qplStsNoErr                        Indicates no error.

qplStsNullPtrErr                   Indicates an error when one of the specified pointers is NULL.

AutoCorr_NormE_G723
Estimates normal autocorrelation of a vector.

Syntax
QplStatus qplsAutoCorr_NormE_G723_16s(const Qpl16s* pSrc, Qpl16s* pDst, int* pNorm           );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h , qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

   560
---------------------Page 561---------------------

                                                                         Speech Coding Functions  9  

Parameters

pSrc                          Pointer to the source vector [180].

pDst                          Pointer to the destination vector, which stores the estimated
                              autocorrelation results of the source vector.
pNorm                         Pointer to the output normalization scale factor.

Description
This function computes 11 autocorrelation coefficients from the input signal. The first correlation coefficient
(energy) is multiplied by a white noise correction factor b(0) = 1025/1024, and the remaining 10 correlation
coefficients are multiplied by the binomial window coefficients bn, n = 1, ..., 10 defined in the reference C-
code (see [ITU723]).
The autocorrelation coefficients are additionally multiplied by the factor 2norm0 , where norm0 ≥ 0 is
calculated so as to make the first coefficient (energy) normalized. Thus, the resulting vector pDst is
computed using the following formula:

0 ≤ n ≤ 10 .
The function qplsAutoCorr_NormE  stores the normalization scale factor norm0 in pNorm.

Return Values

qplStsNoErr                        Indicates no error.

qplStsNullPtrErr                   Indicates an error when one of the specified pointers is NULL .

LevinsonDurbin_G723
Calculates the LP coefficients from the autocorrelation
coefficients.

Syntax
QplStatus qplsLevinsonDurbin_G723_16s(const Qpl16s* pSrcAutoCorr, Qpl16s*
pValResultSineDtct, Qpl16s* pResultResidualEnergy, Qpl16s* pDstLPC          );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h , qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcAutoCorr                  Pointer to the autocorrelation coefficients vector [11].

pValResultSineDtct            Pointer to the sine detector input/output parameter.

pResultResidualEnergy         Pointer to the output residual energy, in Q15 format.

pDstLPC                       Pointer to the output LP coefficients vector [10], in Q13 format.

Description
This function calculates the 10th order LP coefficients from the autocorrelation coefficients using Levinson-
Durbin algorithm. This function also performs sine detection.

                                                                                              561
---------------------Page 562---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

To obtain LP coefficients ai, i = 1, 2, ..., 10, the following set of equations is to be solved:

k = 1,2,...,10 .
The function qplsLevinsonDurbin_G723   performs the following steps:
1. Levinson-Durbin algorithm is applied to solve the above set of equations. This algorithm uses the recursion
detailed in qplsLevinsonDurbin_G729 function.
2. If the LPC filter used in this algorithm is unstable, that is |ki| is very close to 1.0 during recursion, just
set the remaining LP coefficients to zero.
3. The sine detector parameter is updated when i = 1 in the recursion, as follows:
SineDtct  = SineDtct <<1.
If k > 0.95, then SineDtct = SineDtct  + 1.

Return Values

qplStsNoErr                         Indicates no error.

qplStsNullPtrErr                    Indicates an error when one of the specified pointers is NULL .

LPCToLSF_G723
Converts LP coefficients to LSF coefficients.

Syntax
QplStatus qplsLPCToLSF_G723_16s (const Qpl16s* pSrcLPC, const Qpl16s* pSrcPrevLSF,
Qpl16s* pDstLSF  );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h , qplvm.h , qpls.h
Libraries: qplcore.lib, qplvm.lib , qpls.lib

Parameters

pSrcLPC                       Pointer to the LPC input vector [10]:  a 1,...,a 10 in Q13 format.

pSrcPrevLSF                   Pointer to the previous normalized LSF coefficients vector [10], in
                              Q15 format.
pDstLSF                       Pointer to the normalized LSF coefficients vector [10], in Q15
                              format.

Description
This function converts a set of 10th order LP coefficients to LSF coefficients by implementing the following
operations:
1. Apply the 7.5Hz bandwidth expansion.
2. Calculate the polynomial coefficients of F1(z) and F2(z), using the following recursion:
f1(i+1) = a i+1 + a10-i - f1(i+1),
f2(i+1) = a i+1 + a10-i - f2(i+1)
i = 0...4 ,

   562
---------------------Page 563---------------------

                                                                        Speech Coding Functions  9 

where f1(0) = f 2(0) =1.0
3. Use Chebyshev polynomials to find the roots of F1(z) and F2(z), and obtain the LSF coefficients:
c1(ω) = cos (5ω) + f1(1) cos (4ω) + f1(2) cos (3ω) + f1(3) cos (2ω) + f1(4) cos (ω) + f1(5) / 2
c2(ω) = cos (5ω) + f2(1) cos (4ω) + f2(2) cos (3ω) + f2(3) cos (2ω) + f2(4) cos (ω) + f2(5) / 2
4. If all 10 roots needed to determine LSF coefficients are not found, use the set of previous LSF coefficients.

Return Values

qplStsNoErr                        Indicates no error.

qplStsNullPtrErr                   Indicates an error when one of the specified pointers is NULL.

LSFToLPC_G723
Converts LSF coefficients to the LP coefficients.

Syntax
QplStatus qplsLSFToLPC_G723_16s(const Qpl16s* pSrcLSF, Qpl16s* pDstLPC         );
QplStatus qplsLSFToLPC_G723_16s_I (Qpl16s* pSrcLSFDstLPC       );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h , qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcLSF                       Pointer to the input LSF coefficients vector [10], in Q15 format.

pDstLPC                       Pointer to the output LP coefficients vector [10], in Q13 format.

pSrcLSFDstLPC                 Pointer to the input LSF and output LP coefficients vector [10], in
                              Q15 and Q13 formats, respectively.

Description
This function converts a set of 10th order LSF coefficients to the LP coefficients as follows:
1. Convert LSF coefficients to the LSP coefficients using the following formula: qi = cos (ωi) , i = 0...9
2. Calculate the LP coefficients using the same algorithm as in the function LSPToLPC_G729 with the only
difference in rounding mode required for G.723.1 bit-exact compliance.

Return Values

qplStsNoErr                        Indicates no error.

qplStsNullPtrErr                   Indicates an error when one of the specified pointers is NULL.

LSFDecode_G723
Performs inverse quantization of LSFs.

                                                                                             563
---------------------Page 564---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

Syntax
QplStatus qplsLSFDecode_G723_16s (const Qpl16s* pQuantIndex, const Qpl16s* pPrevLSF,
int erase, Qpl16s* pQuantLSF   );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h , qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pQuantIndex                  Pointer to the input LSP VQ indices vector [3].

pPrevLSF                     Pointer to the input quantized LSF for previous subframes.

erase                        Indicates frame erasure.

pQuantLSF                    Pointer to the output quantized LSF for previous subframes.

Description
This function performs inverse quantization of LSFs (in other words, decodes LSP VQ indices). First three VQ
table entries corresponding to the transmitted index are found. The predicted vector is added to the found
vector and DC vector to form the decoded vectors in three bands separately. A stability check is performed
to ensure the difference between them not is less then 31.25 Hz.
For erased frame, zero predicted vectors are chosen and stability check for the difference in 62.5 Hz is
applied.

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointers is NULL.

qplStsLSFLow                      Indicates a warning when a stability condition is not met.

LSFQuant_G723
Quantizes LSF coefficients.

Syntax
QplStatus qplsLSFQuant_G723_16s32s(const Qpl16s* pSrcLSF, const Qpl16s* pSrcPrevLSF,
Qpl32s* pResultQLSFIndex   );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h , qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

   564
---------------------Page 565---------------------

                                                                        Speech Coding Functions  9  

Parameters

pSrcLSF                       Pointer to the LSF coefficients vector [10], in Q15 format.

pSrcPrevLSF                   Pointer to the previous LSF coefficients vector [10], in Q15 format.

pResultQLSFIndex              Pointer to the combined index of quantized LSF coefficients. The
                              combination is built by left-shifting the first codebook index by 16
                              bits and left-shifting the second codebook index by 8 bits, and then
                              adding together the two shifted indices and the third codebook
                              index.

Description
This function quantizes the LSF coefficients to obtain the codebook indices using PSVQ. It implements the
following operations:
1. Calculate the diagonal weighting matrix W, determined from the unquantized LSF coefficients, as:
w1,1 = 1/ (ω2-ω1),
w10,10 = 1/ (ω10-ω9),
wj,j = 1/ min(ωj -ωj-1, ωj+1-ωj) , j = 2...9
2. Calculate the prediction LSF coefficients as given by:
ωp = (ω -ωDC) - 0.375 (ω-1-ωDC)
where ω are the current LSF coefficients, ω-1 are the previous LSF coefficients, and ωDC are the DC LSF
coefficients.
3. Search the codebook vector to minimize the following error:
El = (ωp -ωl)TW(ωp -ωl) ,
where ωl is the l-th code vector in the codebook. The quantization uses 3-3-4 split.

Return Values

qplStsNoErr                        Indicates no error.

qplStsNullPtrErr                   Indicates an error when one of the specified pointers is NULL.

Codebook Search Functions
These functions perform open loop pitch estimation using the adaptive codebook, and search in ACELP
excitation (fixed) codebook for optimal signs and positions of the pulses.

OpenLoopPitchSearch_G723
Searches for an optimal pitch value.

Syntax
QplStatus qplsOpenLoopPitchSearch_G723_16s(const Qpl16s* pSrcWgtSpch, Qpl16s*
pResultOpenDelay  );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h , qplvm.h, qpls.h

                                                                                             565
---------------------Page 566---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcWgtSpch                  Pointer to the perceptually weighted speech signal. The signal
                             length is 265, and the pointer pSrcWgtSpch points to its 146th
                             element, in Q12 format.
pResultOpenDelay             Pointer to the OLP search result.

Description
This function extracts the open loop pitch from the weighted speech signal. It is applied in half-frames as
follows:
1. The open loop pitch is chosen such that the cross-correlation is maximized:

j = 18,...,142
2. During the search, preference is given to smaller pitch periods to avoid choosing pitch multiples. Every
found pitch value is compared with the previous best. If the difference is less than 18 and col(j) >
col(j') , the process is over. Otherwise, the pitch is chosen only if col(j) is greater than col(j') by
1.25db.

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointers is NULL.

ACELPFixedCodebookSearch_G723
Searches the ACELP fixed codebook for the excitation.

Syntax
QplStatus qplsACELPFixedCodebookSearch_G723_16s(const Qpl16s* pSrcFixedCorr, const
Qpl16s* pSrcMatrix, Qpl16s* pDstFixedSign, Qpl16s* pDstFixedPosition, Qpl16s*
pResultGrid, Qpl16s* pDstFixedVector, Qpl16s* pSearchTimes      );
QplStatus qplsACELPFixedCodebookSearch_G723_32s16s(const Qpl16s* pSrcFixedCorr, Qpl32s*
pSrcDstMatrix, Qpl16s* pDstFixedSign, Qpl16s* pDstFixedPosition, Qpl16s* pResultGrid,
Qpl16s* pDstFixedVector, Qpl16s* pSearchTimes     );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcFixedCorr                Pointer to the correlation between residual and impulse response
                             vector [60]
pSrcMatrix                   Pointer to the elements of Toepliz matrix [416].

pSrcDstMatrix                Pointer to the input and output elements of Toepliz matrix [416].

   566
---------------------Page 567---------------------

                                                                      Speech Coding Functions  9 

pDstFixedSign                Pointer to the signs of the fixed vector [4].

pDstFixedPosition            Pointer to the positions of the fixed vector [4].

pResultGrid                  Pointer to the beginning grid location.

pDstFixedVector              Pointer to the fixed vector [60].

pSearchTimes                 Pointer to the input and output maximum search time

Description
This function searches the ACELP fixed codebook for the excitation in the 5.3Kbps encoder. It is applied in
subframes as follows:
1. There are four non-zero pulses in the fixed vector as given by:

n = 0,...,59
where αk and mk, k =0..3 are the signs and positions of the fixed vector respectively.
2. Search for the parameters αk and mk, k =0..3 , that minimize the following error:

where Φ(i,j) is the Toepliz matrix.

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointers is NULL.

AdaptiveCodebookSearch_G723
Searches for the close loop pitch and the adaptive
gain index.

Syntax
QplStatus qplsAdaptiveCodebookSearch_G723(Qpl16s valBaseDelay, const Qpl16s*
pSrcAdptTarget, const Qpl16s* pSrcImpulseResponse, const Qpl16s* pSrcPrevExcitation,
const Qpl32s* pSrcPrevError, Qpl16s* pResultCloseLag, Qpl16s* pResultAdptGainIndex,
Qpl16s subFrame, Qpl16s sineDtct, QplSpchBitRate bitRate      );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

valBaseDelay                 Base delay, in the range [18,145].

pSrcAdptTarget               Pointer to the adaptive target signal vector [60].

pSrcImpulseResponse          Pointer to the impulse response vector [60].

pSrcPrevExcitation           Pointer to the previous excitation vector [145].

                                                                                           567
---------------------Page 568---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

pSrcPrevError                Pointer to the previous error vector [5].

subFrame                     Subframe number, from 0 to 3.

bitRate                      Transmit bit rate, equal to either QPL_SPCHBR_6300  or
                             QPL_SPCHBR_5300  .
sineDtct                     Sine detector parameter.

pResultCloseLag              Pointer to the lag of close pitch.

pResultAdptGainIndex         Pointer to the index of the adaptive gain.

Description
This function searches for the close loop pitch and the adaptive gain index. It is applied in subframes as
follows:
1. For subframe 0 and 2, the close loop pitch lag is chosen in the range of [-1,1] around the appropriate
open loop pitch. For subframe 1 and 3, the range is [-1, 3] around the open loop pitch.
2. Denote the close loop pitch as Li , i = 0...3. The pitch predictor gains are vector quantized. For 6.3Kbps
bit rate, two codebooks are used with 85 entries and 170 entries, respectively. If L0 is less than 58 for
subframe 0 and 1, or if L2 is less than 58 for subframe 2 and 3, then the 85-entry codebook is used for pitch
gain quantization. Otherwise, the 170-entry codebook is used. For 5.3Kbps bit rate, the quantization is
against a 170-entry codebook.

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointers is NULL.

qplStsRangeErr                    Indicates an error when  valBaseDelay   is not in the range [18,
                                  145], or subFrame  is not in the range [0, 3], or bitRate is not a
                                  valid element of the enumerated type   QplSpchBitRate  .

MPMLQFixedCodebookSearch_G723
Searches the MP-MLQ fixed codebook for the
excitation.

Syntax
QplStatus qplsMPMLQFixedCodebookSearch_G723(Qpl16s valBaseDelay, const Qpl16s*
pSrcImpulseResponse, const Qpl16s* pSrcResidualTarget, Qpl16s* pDstFixedVector, Qpl16s*
pResultGrid, Qpl16s* pResultTrainDirac, Qpl16s* pResultAmpIndex, Qpl16s*
pResultAmplitude, Qpl32s* pResultPosition, Qpl16s subFrame       );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h , qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

valBaseDelay                 Base delay, in the range [18,145].

pSrcImpulseResponse          Pointer to the impulse response vector [60].

   568
---------------------Page 569---------------------

                                                                       Speech Coding Functions  9 

pSrcResidualTarget           Pointer to the residual target signal vector [60].

pDstFixedVector              Pointer to the fixed codebook vector [60].

pResultGrid                  Pointer to the beginning grid location, 0 or 1.

pResultTrainDirac            Pointer to the flag to show if train Dirac function is used: 0-unused,
                             1-used.
pResultAmpIndex              Pointer to the index of the quantized amplitude.

pResultAmplitude             Pointer to the amplitude of the fixed codebook vector.

pResultPosition              Pointer to the position of the fixed codebook vector, whose
                             amplitude has non-zero value.
subFrame                     Subframe number, from 0 to 3.

Description
This function searches the MP-MLQ fixed codebook for the excitation in the 6.3Kbps encoder. It is applied in
subframes as follows: 1. The error is obtained by the following calculation:

where G is the gain factor, αk and mk are the signs and positions of the fixed vector, respectively.
2. Search for the parameters G, αk and mk that minimize the mean square of the error signal err(n).
3. The fixed codebook gain is obtained using the following formulas:

where c(n ) is the fixed vector.

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointers is NULL.

qplStsRangeErr                    Indicates an error when  subFrame  is not one of 0, 1, 2, or 3; or
                                  when  valBaseDelay   is not in the range [18,145].

ToeplizMatrix_G723
Calculates 416 elements of the Toepliz matrix for fixed
codebook search.

Syntax
QplStatus qplsToeplizMatrix_G723_16s(const Qpl16s* pSrcImpulseResponse, Qpl16s*
pDstMatrix );
QplStatus qplsToeplizMatrix_G723_16s32s(const Qpl16s* pSrcImpulseResponse, Qpl32s*
pDstMatrix );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h , qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

                                                                                            569
---------------------Page 570---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

Parameters

pSrcImpulseResponse           Pointer to the impulse response vector [60].

pDstMatrix                    Pointer to the elements of Toepliz matrix vector [416].

Description
This function calculates the 416 elements in Toepliz matrix for the fixed-codebook search. Elements of the
Toepliz matrix can be expressed as follows:

i ≤ j , 0 ≤ i ≤ 59 ,

where h(i), i = 0, 1, ..., 59, is the impulse response.
The function stores the calculated 416 elements in pDstMatrix in the following order:
1. Φ(mi , mi ) , (i = 0, 1, 2, 3), 4x8 =32 elements; starting location: 0.
2. Φ(m0, m1), 8x8 = 64 elements; starting location: 32.
3. Φ(m0, m2), 8x8 = 64 elements; starting location: 96.
4. Φ(m0, m3), 8x8 = 64 elements; starting location: 160.
5. Φ(m1, m2), 8x8 = 64 elements; starting location: 224.
6. Φ(m1, m3) , 8x8 = 64 elements; starting location: 288.
7. Φ(m2, m3), 8x8 = 64 elements; starting location: 352.

Return Values

qplStsNoErr                        Indicates no error.

qplStsNullPtrErr                   Indicates an error when one of the specified pointers is NULL .

Gain Quantization
These functions perform fixed codebook gain estimation and gain adjustment of the postfiltered signal.

GainQuant_G723
Implements MP-MLQ gain estimation and quantization.

Syntax
QplStatus qplsGainQuant_G723_16s (const Qpl16s* pImp, const Qpl16s* pSrc, Qpl16s*
pDstLoc, Qpl16s* pDstAmp, Qpl32s* pMaxErr, Qpl16s* pGrid, Qpl16s* pAmp, int Np, int*
isBest);

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h , qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

   570
---------------------Page 571---------------------

                                                                        Speech Coding Functions  9  

Parameters

pImp                          Pointer to the input impulse response h  vector [60].

pSrc                          Pointer to the input target signal r vector [60].

pDstLoc                       Pointer to the output pulse locations.

pDstAmp                       Pointer to the output pulse amplitudes.

pMaxErr                       Pointer to the input/output quantization error.

pGrid                         Pointer to the output grid: 0 - if pulses are in even positions, 1 - if
                              pulses are in odd positions.
pAmp                          Pointer to the output index of maximum amplitude.

Np                            Number of pulses: equal to 6 for even subframe, equal to 5 for odd
                              subframe.
pIsBest                       Pointer to the quantization result. Set to 0, if no pulses are found
                              with quantization error less than the input error.

Description
This function estimates the unknown parameters, G, {αk}, {mk}, k = 0,...,Np-1, that minimize the mean
square of the error signal:

The estimation is done as follows.
First, cross correlation of the impulse response and the target vector is computed:

0 ≤ n ≤ 59
The estimated maximum gain is computed as:

and then is quantized by the logarithmic quantizer. The gain values selected around this quantized gain are
then used to optimize the signs and locations of the pulses for both even and odd grids that yield the
minimum mean square of the error signal.

Return Values

qplStsNoErr                        Indicates no error.

qplStsNullPtrErr                   Indicates an error when one of the specified pointers is NULL.

GainControl_G723
Extracts delayed pitch contribution.

Syntax
QplStatus qplsGainControl_G723_16s_I (Qpl32s energy, Qpl16s* pSrcDst, Qpl16s* pGain           );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h , qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

                                                                                             571
---------------------Page 572---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

Parameters

energy                         The input energy coefficient.

pSrcDst                        Pointer to the input/output post-filtered signal.

pGain                          Pointer to the input/output gain.

Description
This function first computes the amplitude ratio gs as:

If denominator in this expression is equal to 0, gs is set to 1.
Then the input postfiltered signal is scaled as follows:
pSrcDst[n] = pSrcDst[n]*g    n(1+α) , n = 0,..., 59,
where gn is updated using the following expression, respectively:
gn = (1-α)g n-1 + α g s , n = 0,..., 59, g-1= 0, and α = 1/16.
The output gain is equal to g59.

Return Values

qplStsNoErr                         Indicates no error.

qplStsNullPtrErr                    Indicates an error when one of the specified pointers is  NULL .

Filtering Functions
These functions implement different types of filtering, including high pass filtering on pre-processing stage of
encoding and post-processing stage of decoding, as well as the postfilter in final decode stage.
Different kinds of synthesis (IIR), harmonic, and preemphasize filter functions can be combined to perform
more complex filtering and may be used in different encode and decode stages.

HighPassFilter_G723
Performs high-pass filtering of the input signal.

Syntax
QplStatus qplsHighPassFilter_G723_16s (const Qpl16s* pSrc, Qpl16s* pDst, int* pMem              );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h , qplvm.h , qpls.h
Libraries: qplcore.lib, qplvm.lib , qpls.lib

Parameters

pSrc                           Pointer to the source vector [240].

pDst                           Pointer to the destination vector [240].

   572
---------------------Page 573---------------------

                                                                       Speech Coding Functions  9 

pMem                         Pointer to the filter memory vector [2]. This vector must be initially
                             filled with zeroes.

Description
This function pre-processes the input signal using the following filter transfer function:

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when the pSrc ,pDst or pMem pointer is NULL.

IIR16s_G723
Performs IIR filtering.

Syntax
QplStatus qplsIIR16s_G723_16s32s (const Qpl16s* pCoeffs, const Qpl16s* pSrc, Qpl32s*
pDst, Qpl16s* pMem  );
QplStatus qplsIIR16s_G723_16s_I (const Qpl16s* pCoeffs, Qpl16s* pSrcDst, Qpl16s* pMem          );
QplStatus qplsIIR16s_G723_32s16s_Sfs (const Qpl16s* pCoeffs, const Qpl32s* pSrc, int
scaleFactor, Qpl16s* pDst, Qpl16s* pMem    );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pCoeffs                      Pointer to the input vector of filter coefficients vector [20]:
                             b1,...,b10, a1, ...,a10 .
pSrc                         Pointer to the input signal vector [60].

pSrcDst                      Pointer to the input/output signal vector [60].

scaleFactor                  Scale factor.

pDst                         Pointer to the output filtered vector [60].

pMem                         Pointer to the filter memory vector [20]. This vector must be initially
                             filled with zeroes.

Description

The functions qplsIIR16s_G723_16s32s  and qplsIIR16s_G723_16s_I   perform infinite impulse response
(IIR) filtering using the following transfer function:

The function qplsIIR16s_G723_32s16s_Sfs  performs IIR filtering using the transfer function:

The filter memory is updated.

                                                                                           573
---------------------Page 574---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointers is NULL.

SynthesisFilter_G723
Computes the speech signal by filtering the input
speech through the synthesis filter 1/A(z).

Syntax
QplStatus qplsSynthesisFilter_G723_16s32s (const Qpl16s* pLPC, const Qpl16s* pSrc,
Qpl32s* pDst, Qpl16s* pMem   );
QplStatus qplsSynthesisFilter_G723_16s (const Qpl16s* pLPC, const Qpl16s* pSrc, Qpl16s*
pMem, Qpl16s* pDst  );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h , qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pLPC                         Pointer to the input LP coefficients a0, a1 ,...,a10 , in Q11 format.

pSrc                         Pointer to the source vector.

pDst                         Pointer to the filtered output.

pMem                         Pointer to the memory supplied for filtering: short integer vector
                             [10], initially set to zero.

Description
This function computes the filter using the following formula:

This function is applied after the residual filter in computing the perceptually weighted speech signal:

n = 0,...,59

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointers is NULL.

qplStsOverflow                    Indicates a warning that at least one result value was
                                  saturated.

TiltCompensation_G723
Computes tilt compensation filter.

   574
---------------------Page 575---------------------

                                                                     Speech Coding Functions  9 

Syntax
QplStatus qplsTiltCompensation_G723_32s16s (Qpl16s val, const Qpl32s* pSrc, Qpl16s*
pDst);

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

val                         The first-order partial correlation coefficient, in Q15 format.

pSrc                        Pointer to the source vector [61].

pDst                        Pointer to the output filtered vector [60].

Description
This function computes the tilt compensation filter, using the following formula:
Ht(z) = (1 - val*z-1),
pDst[i] = pSrct[i + 1] + pSrct[i]*val, i = 0,...,59

Return Values

qplStsNoErr                      Indicates no error.

qplStsNullPtrErr                 Indicates an error when one of the specified pointers is NULL.

HarmonicSearch_G723
Searches for the harmonic delay and gain for the
harmonic noise shaping filter.

Syntax
QplStatus qplsHarmonicSearch_G723_16s(Qpl16s valOpenDelay, const Qpl16s* pSrcWgtSpch,
Qpl16s* pResultHarmonicDelay, Qpl16s* pResultHarmonicGain     );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

valOpenDelay                Open loop pitch, in the range [18,145].

pSrcWgtSpch                 Pointer to the weighted speech vector [205]. The pointer points to
                            the 146th element, in Q12 format.
pResultHarmonicDelay        Pointer to the output harmonic delay.

                                                                                         575
---------------------Page 576---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

pResultHarmonicGain           Pointer to the output harmonic gain, in Q15 format.

Description
This function searches for the harmonic delay and harmonic gain for the harmonic noise shaping filter, using
the weighted speech and open loop pitch as input. This function is applied in subframes.

Return Values

qplStsNoErr                        Indicates no error.

qplStsNullPtrErr                   Indicates an error when one of the specified pointers is NULL.

qplStsRangeErr                     Indicates an error when valOpenDelay   is not in the range [18,
                                   145].

HarmonicNoiseSubtract_G723
Performs harmonic noise shaping.

Syntax
QplStatus qplsHarmonicNoiseSubtract_G723_16s_I(Qpl16s val, int T, const Qpl16s* pSrc,
Qpl16s* pSrcDst  );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h , qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

val                           The input harmonic filter coefficient, in Q15 format.

T                             The input harmonic filter lag.

pSrc                          Pointer to the input zero impulse response vector [60] of the
                              combined filter.
pSrcDst                       Pointer to the input/output harmonic noise weighted speech vector
                              [60].

Description
This function subtracts the harmonic shaped vector pSrc from vector pSrcDst, using the following formula:
pSrcDst[n] = pSrcDst[n] - (pSrc[n] + val*pSrc[n - T])       , n = 0,..., 59
This operation is used for ringing subtraction, which is performed by subtracting the zero impulse response
from the harmonic weighted speech vector to obtain the target vector:
t[n] = w[n] - z[n]

Return Values

qplStsNoErr                        Indicates no error.

qplStsNullPtrErr                   Indicates an error when one of the specified pointers is NULL.

   576
---------------------Page 577---------------------

                                                                     Speech Coding Functions  9 

DecodeAdaptiveVector_G723
Restores the adaptive codebook vector from
excitation, pitch, and adaptive gain.

Syntax
QplStatus qplsDecodeAdaptiveVector_G723_16s(Qpl16s valBaseDelay, Qpl16s valCloseLag,
Qpl16s valAdptGainIndex, const Qpl16s* pSrcPrevExcitation, Qpl16s* pDstAdptVector,
QplSpchBitRate bitRate );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

valBaseDelay                Base delay, in the range [18,145].

valCloseLag                 Lag of close pitch.

valAdptGainIndex            Index of adaptive gain.

pSrcPrevExcitation          Pointer to the past excitations vector [145].

bitRate                     Transmit bit rate, equal to either QPL_SPCHBR_6300 or
                            QPL_SPCHBR_5300 .
pDstAdptVector              Pointer to the adaptive codebook vector [60].

Description
This function decodes the adaptive vector from excitation, close loop pitch, and adaptive gain index. It is
applied in subframes.

Return Values

qplStsNoErr                      Indicates no error.

qplStsNullPtrErr                 Indicates an error when one of the specified pointers is NULL.

qplStsRangeErr                   Indicates an error when valBaseDelay  is not in the range [18,
                                 145]; or valCloseLag  is not in the range [0, 2]; or
                                 valAdptGainIndex  is not in the range [0, 169], or bitRate is
                                 not a valid element of the enumerated type QplSpchBitRate .

PitchPostFilter_G723
Calculates coefficients of the pitch post filter.

Syntax
QplStatus qplsPitchPostFilter_G723_16s(Qpl16s valBaseDelay, const Qpl16s* pSrcResidual,
Qpl16s* pResultDelay, Qpl16s* pResultPitchGain, Qpl16s* pResultScalingGain, Qpl16s
subFrame, QplSpchBitRate bitRate  );

Include Files
qplsc.h

                                                                                        577
---------------------Page 578---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

Domain Dependencies
Headers: qplcore.h , qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

valBaseDelay                  Base delay, in the range [18,145].

pSrcResidual                  Pointer to the residual signal vector [365]. This pointer points to the
                              146th element.
pResultDelay                  Pointer to the delay of the pitch post filter.

pResultPitchGain              Pointer to the gain of the pitch post filter, in Q15 format.

pResultScalingGain            Pointer to the scaling gain of the pitch post filter, in Q15 format.

subFrame                      Subframe number, from 0 to 3.

bitRate                       Transmit bit rate, equal to either QPL_SPCHBR_6300  or
                              QPL_SPCHBR_5300  .

Description
This function calculates the coefficients of the pitch post filter. It is applied in subframes.

Return Values

qplStsNoErr                        Indicates no error.

qplStsNullPtrErr                   Indicates an error when one of the specified pointers is NULL.

qplStsRangeErr                     Indicates an error when  valBaseDelay   is not in the range [18,
                                   145], or subFrame  is not 0 or 3, or bitRate is not a valid
                                   element of the enumerated type   QplSpchBitRate  .

GSM-AMR Functions
This part of the chapter describes the Intel QPL functions that can be combined to construct a bit-exact
implementation of the European Telecommunications Standards Institute (ETSI) Global System for Mobile
Communications (GSM) Adaptive Multi-Rate (AMR) ETSI EN 301 704 GSM 06.90 version 7.5.0 Release 2001
speech codec, more commonly known as the GSM-AMR 06.90 codec. The primitives are primarily concerned
with the well-defined, computationally expensive core operations that comprise the codec portion of the
GSM-AMR system.
The GSM 06.90 AMR speech codec comprises an adaptive multi-rate algorithm that represents efficiently
telephone-bandwidth digital speech using compressed data rates of 4.75, 5.15, 5.90, 6.70, 7.40, 7.95, 10.2,
and 12.2 kilobits per second (kbps). The GSM-AMR system adaptively controls speech codec bit rates such
that output quality is maximized for a given set of channel conditions.
These functions are used in the Intel QPL GSM/AMR Speech Encoder-Decoder sample downloadable from
http://www.intel.com/cd/software/products/asmo-na/eng/220046.htm.

Basic Functions
These functions perform basic operation for codec.

Interpolate_GSMAMR
Computes the weighted sum of two vectors.

   578
---------------------Page 579---------------------

                                                                     Speech Coding Functions  9 

Syntax
QplStatus qplsInterpolate_GSMAMR_16s (const Qpl16s* pSrc1, const Qpl16s* pSrc2, Qpl16s*
pDst, int len );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrc1                       Pointer to the first input vector[ len].

pSrc2                       Pointer to the second input vector[ len].

pDst                        Pointer to the output vector[len].

len                         Length of the input and output vectors.

Description
This function computes the weighted sum of two vectors as:
pDst[i] = (pSrc1[i]>>2) + (pSrc2[i] - (pSrc2[i]>>2) ); 0 ≤ i < len

Return Values

qplStsNoErr                      Indicates no error.

QplStsNullPtrErr                 Indicates an error when one of the specified pointers is NULL.

qplStsSizeErr                    Indicates an error when len is less than or equal to zero.

FFTFwd_RToPerm_GSMAMR
Computes the forward fast Fourier transform (FFT) of
a real signal.

Syntax
QplStatus qplsFFTFwd_RToPerm_GSMAMR_16s_I (Qpl16s* pSrcDst     );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcDst                     Pointer to the input and output vector [128].

                                                                                         579
---------------------Page 580---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

Description
This function computes the forward FFT of a real signal. This transform is the same as done by the general
signal processing FFT function qplsFFTFwd_RToPerm_16s_Sfs with the following settings: order = 7, flag
= QPL_FFT_DIV_FWD_BY_N  , scaleFactor  = -1. The result of function operation may be different because
the rounding mode used in qplsFFTFwd_RToPerm_16s_Sfs   does not guarantee a bit-exact operation of
GSM-AMR codec.

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when the  pSrcDst  pointer is NULL.

See Also
Fast Fourier Transform Functions

LP Analysis and Quantization Functions
This section describes the GSM-AMR primitives that are concerned with LP analysis, quantization, encoding,
and decoding. It also provides details on primitives that accomplish the following tasks:
• Autocorrelation analysis
• Levinson-Durbin algorithm
• LPC to LSP conversion
• LSP to LPC conversion
• LSP quantization and inverse quantization
• Quantized LSP encoding and decoding.

AutoCorr_GSMAMR
Estimates the autocorrelation sequence for a block of
samples.

Syntax
QplStatus qplsAutoCorr_GSMAMR_16s32s(const Qpl16s* pSrcSpch, Qpl32s* pDstAutoCorr,
QplSpchBitRate mode  );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h , qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcSpch                      Pointer to the input speech vector (240 samples), represented using
                              Q15.0. This should be aligned on an 8‑byte boundary.
pDstAutoCorr                  Pointer to the autocorrelation coefficients with 22 elements. For
                              12.2 kbps mode, elements 0 ~ 10 contain the first set of
                              autocorrelation lags, and elements 11 ~ 21 contain the second set
                              of autocorrelation lags. For all other modes there is only one set of
                              autocorrelation lags contained in vector elements 0 ~ 10.

   580
---------------------Page 581---------------------

                                                                          Speech Coding Functions  9  

mode                          Bit rate specifier. Values between  QPL_SPCHBR_4750   and
                              QPL_SPCHBR_12200    are valid.

Description
This function estimates the autocorrelation sequence for a block of 240 samples (30 ms). For the12.2 kbps
mode, the 160 samples associated with the current 20 ms frame are combined with the last 80 samples from
the previous frame, and two autocorrelation sequences are estimated. For all other bit rates, 160 samples
from the current frame are combined with the last 40 samples from the previous frame as well as the first 40
samples from the next frame, and only one autocorrelation sequence is estimated. In particular, the
estimates are formed as follows:
1. Tapered windowing - asymmetric tapered windows are applied to the input speech. Different windows are
selected depending on the bit rate. For 12.2 kbps frames, unique tapered windows are applied for each of the
two autocorrelation estimates, that is and 
Neither w1 nor w2 has any look ahead. For all bit rates other than 12.2 kbps, a window centered on the
current frame is applied, that is

2. Estimation of autocorrelation lags - autocorrelation lags are estimated from the windowed speech samples
s(i), i = 0, 1, ..., 239, as follows

3. Bandwidth expansion - the following binomial lag window is applied to the autocorrelation sequence(s)
obtained in step 2:

where f0 = 60 Hz and fS = 8000 Hz.

Return Values

qplStsNoErr                        Indicates no error.

qplStsNullPtrErr                   Indicates an error when the   pSrcSpch  or pDstAutoCorr   pointer
                                   is NULL.
qplStsRangeErr                     Indicates an error when   mode is not a valid element of the
                                   enumerated type    QplSpchBitRate  .

LevinsonDurbin_GSMAMR
Calculates the LP coefficients using the Levinson-
Durbin algorithm.

Syntax
QplStatus qplsLevinsonDurbin_GSMAMR_32s16s (const Qpl32s* pSrcAutoCorr, Qpl16s*
pSrcDstLpc );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h , qplvm.h , qpls.h
Libraries: qplcore.lib, qplvm.lib , qpls.lib

                                                                                               581
---------------------Page 582---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

Parameters

pSrcAutoCorr                 Pointer to the autocorrelation coefficients, a vector with 11
                             elements.
pSrcDstLpc                   Pointer to the LP coefficients associated with the previous frame, a
                             vector with 11 elements, represented using Q3.12 format. On
                             output, updated to point to the LP coefficients associated with the
                             current frame, a vector with 11 elements, represented using Q3.12
                             format.

Description
This function calculates the 10th-order LP coefficients from the autocorrelation lags using the Levinson-
Durbin algorithm.

Return Values

qplStsNoErr                       Indicates no error.

QplStsNullPtrErr                  Indicates an error when one of the specified pointers is NULL.

LPCToLSP_GSMAMR
Converts LP coefficients to line spectrum pairs.

Syntax
QplStatus qplsLPCToLSP_GSMAMR_16s(const Qpl16s* pSrcLpc, const Qpl16s* pSrcPrevLsp,
Qpl16s* pDstLsp );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h , qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcLpc                      Pointer to the LP coefficient vector, represented using Q3.12 format.
                             The LP coefficient vector has 11 elements.
pSrcPrevLsp                  Pointer to the LSP coefficient vector associated with the previous
                             frame, represented using Q0.15 format. The LSP coefficient vector
                             has ten elements.
pDstLsp                      Pointer to the LSP coefficient vector, represented using Q0.15
                             format. The LSP coefficient vector has ten elements.

Description
This function converts a set of 10th-order LP coefficients to an equivalent set of LSPs. The functionality is as
follows:
Calculate the polynomial coefficients of F1(z) and F2(z) using the recursive relations
f1(i+1) = a i+1 + ai-1 - f1(i),
f2(i+1) = a i+1 + ai-1 + f1(i)
i = 0...4 ,

   582
---------------------Page 583---------------------

                                                                         Speech Coding Functions  9  

where f1(0) = f 2(0) =1.0
Use Chebyshev polynomials to evaluate F1(z) and F2(z) . The Chebyshev polynomials are given by the
following formulas:
c1(ω) = cos (5ω) + f1(1) cos (4ω) + f1(2) cos (3ω) + f1(3) cos (2ω) + f1(4) cos (ω) + f1(5) / 2
c2(ω) = cos (5ω) + f2(1) cos (4ω) + f2(2) cos (3ω) + f2(3) cos (2ω) + f2(4) cos (ω) + f2(5) / 2
Evaluate F1(z) and F2(z) on 60 points equally spaced between 0 and π, checking for sign changes. A sign
change indicates the existence of a root and the sign change interval is then divided four times to track the
root.
If ten roots for LSP coefficients are not found during the search, the previous set of LSPs is used.

Return Values

qplStsNoErr                        Indicates no error.

QplStsNullPtrErr                   Indicates an error when one of the specified pointers is NULL.

LSPToLPC_GSMAMR
Converts LSPs to LP coefficients.

Syntax
QplStatus qplsLSPToLPC_GSMAMR_16s(const Qpl16s* pSrcLsp, Qpl16s* pDstLpc          );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h , qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcLsp                       Pointer to the LSP coefficient vector with ten elements, represented
                              using Q0.15 format.
pDstLpc                       Pointer to the LP coefficient vector with 11 elements, represented
                              using Q3.12 format.

Description
This function converts a set of 10th-order LSPs to LP coefficients. The functionality is as follows:
1.   Calculate the polynomial coefficients of F1(z) and F2(z), using the following recursive relations
for i = 1 .. 5
f1(i) = 2q2i-1 * f1(i-1) + 2f1(i-2)
for j = i-1 .. 1
f1(j) = f1(j) - 2q2i-1 * f1(j-1) + 2f1(j-2)
where initial values f1(0) = 1 and f1 (-1) = 0.
The coefficients f2(i) are computed similarly by replacing q2i-1 by q2i.
2. MultiplyF1(z) and F2(z) by 1+z-1 and 1-z-1 , respectively, to obtain F'1(z) and F'2(z), using the following
relations:
f'1(i) = f1(i) + f1(i-1),

                                                                                              583
---------------------Page 584---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

f'2(i) = f2(i) + f2(i-1), for i = 1,2, ..., 5.
3. Compute the LP coefficients from the polynomials F'1(z) and F'2(z) as follows:
ai = 0.5f'1(i) + 0.5f'2(i) for i = 1,2, ..., 5, and
ai = 0.5f'1(11 - i) + 0.5f'2(11 - i) for i = 6,7, ..., 11.

Return Values

qplStsNoErr                       Indicates no error.

QplStsNullPtrErr                  Indicates an error when one of the specified pointers is NULL.

LSFToLSP_GSMAMR
Converts Line Spectral Frequencies to LSP coefficients.

Syntax
QplStatus qplsLSFToLSP_GSMAMR_16s (const Qpl16s* pLSF, Qpl16s* pLSP        );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pLSF                         Pointer to the vector [10] of LSF normalized by factor 1/π in Q14, so
                             given in the range [0,1].
pLSP                         Pointer to the LSP vector [10], in Q15 in the range [-1,1].

Description
This function converts the LSF to the LSP coefficients using the following formula:
lspn = cos(lsf n), 1 ≤ n ≤ 10.

Return Values

qplStsNoErr                       Indicates no error.

QplStsNullPtrErr                  Indicates an error when one of the specified pointers is NULL.

LSPQuant_GSMAMR
Quantizes the LSP coefficient vector.

Syntax
QplStatus qplsLSPQuant_GSMAMR_16s(const Qpl16s* pSrcLsp, Qpl16s*
pSrcDstPrevQLsfResidual, Qpl16s* pDstQLsp, Qpl16s* pDstQLspIndex, QplSpchBitRate mode          );

Include Files
qplsc.h

   584
---------------------Page 585---------------------

                                                                     Speech Coding Functions  9 

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcLsp                     Pointer to the unquantized LSP vector with 20 elements,
                            represented using Q0.15 format. For 12.2 kbps frames, the first LSP
                            set is contained in vector elements 0 ~ 9, and the second LSP set is
                            contained in vector elements 10 ~ 19. For all other bit rates, only
                            elements 0 to 9 are valid and used for the quantization.
pSrcDstPrevQLsfResidual     Pointer to the quantized LSF residual vector with ten elements from
                            the previous frame, represented using Q0.15 format. On output,
                            points to the quantized LSF residual vector with ten elements for the
                            current frame, represented using Q0.15 format.
pDstQLsp                    Pointer to the quantized LSP vector with 20 elements, represented
                            using Q0.15 format. For 12.2 kbps frames, elements 0 to 9 contain
                            the first quantized LSP set, and elements 10 to 19 contain the
                            second quantized LSP set. For all other bit rates there is only one
                            LSP set contained in elements 0 to 9.
pDstQLspIndex               Pointer to the vector of quantized LSP indices with five elements.
                            For 12.2Kbps frames, all five elements contain valid data; for all
                            other bit rates, only the first three elements contain valid indices
                            (see the following discussion of SMQ and SVQ for the various
                            modes).
mode                        Bit rate specifier. The enumerated values of QPL_SPCHBR_4750 to
                            QPL_SPCHBR_12200   are valid.

Description
This function quantizes the LSP coefficient vector, then obtains quantized LSP codebook indices.

Return Values

qplStsNoErr                      Indicates no error.

QplStsNullPtrErr                 Indicates an error when one of the specified pointers is NULL.

qplStsRangeErr                   Indicates an error when mode is not a valid element of the
                                 enumerated type  QplSpchBitRate .

QuantLSPDecode_GSMAMR
Decodes quantized LSPs.

Syntax
QplStatus qplsQuantLSPDecode_GSMAMR_16s(const Qpl16s* pSrcQLspIndex, Qpl16s*
pSrcDstPrevQLsfResidual, Qpl16s* pSrcDstPrevQLsf, Qpl16s* pSrcDstPrevQLsp, Qpl16s*
pDstQLsp, Qpl16s bfi, QplSpchBitRate mode   );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h

                                                                                         585
---------------------Page 586---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcQLspIndex                 Pointer to the vector with five elements containing codebook indices
                              of the quantized LSPs. For 12.2 kbps frames, all five elements
                              contain valid indices; for all other bit rates, only the first three
                              elements contain valid indices.
pSrcDstPrevQLsfResidual       Pointer to the quantized LSF residual vector with ten elements from
                              the previous frame, represented using Q0.15 format. On output,
                              points to the quantized LSF residual with ten elements for the
                              current frame, represented using Q0.15 format.
pSrcDstPrevQLsf               Pointer to the LSF vector with ten elements from the previous
                              frame, represented using Q0.15 from. On output, points to the
                              updated quantized LSF vector with ten elements, represented using
                              Q0.15 format.
pSrcDstPrevQLsp               Pointer to the quantized LSP vector with ten elements from the
                              previous frame, represented using Q0.15 format. On output, points
                              to the updated quantized LSP vector with ten elements, represented
                              using Q0.15 format.
pDstQLsp                      Pointer to a vector with 40 elements containing four subframe LSP
                              sets. Two sets are generated by interpolation for 12.2 kbps frames;
                              for all other bit rates three sets are generated by interpolation. All
                              elements are represented in using Q0.15 format.
bfi                           Bad frame indicator; “0” indicates a valid frame; all other values
                              indicate an invalid frame.
mode                          Bit rate specifier. The enumerated values of QPL_SPCHBR_4750   to
                              QPL_SPCHBR_12200   are valid.

Description
This function decodes quantized LSPs from the received codebook index if the errors are not detected on the
received frame. Otherwise, the function recovers the quantized LSPs from previous quantized LSPs using
linear interpolation. The functionality can be summarized as follows:
1. If no errors are detected on the current frame, obtain the quantized LSPs from the codebook indices and
the previous quantized residual using inverse LSP quantization.
2. If errors are detected on the current frame, quantized LSFs are obtained using the following rate-
dependent interpolation scheme:
For 12.2 kbit/s
lsf_q1(i) = lsf_q2(i) = α*past_lsf_q(i) + (1 - α )*mean_lsf_q (i)
For all ither rates:
lsf_q(i) = α*past_lsf_q(i) + (1 - α )*mean_lsf_q (i)
Here i = 0, 1,..., 9, α = 0.95, lsf_q1 and lsf_q2 (for 12.2 kbps) are two sets of quantized LSF vectors for
current frame, past_lsf_q is lsf_q2 of the previous frame, and mean_lsf is the average LSF vector. There
is only one set of quantized LSF coefficients for rates other than 12.2 kbps. The corresponding quantized
LSPs are obtained by LSF-to-LSP conversion.
Linear interpolation is applied to generate four sets of quantized LSPs from the decoded set(s) of LSPs and
the quantized LSPs from the previous frame.

Return Values

qplStsNoErr                        Indicates no error.

   586
---------------------Page 587---------------------

                                                                           Speech Coding Functions  9  

qplStsNullPtrErr                    Indicates an error when the   pSrcQLspIndex  ,
                                    pSrcDstPrevQLsfResidual    , pSrcDstPrevQLsf  , pSrcDstPrevQLsp
                                    or pDstQLsp  pointer is NULL.
qplStsRangeErr                      Indicates an error when   mode is not a valid element of the
                                    enumerated type    QplSpchBitRate  .

Adaptive Codebook Functions
This section describes primitives that are concerned with various aspects of the adaptive codebook, including
primitives that perform the following functions:
• Open-loop pitch search, including Non-DTX, VAD1, and VAD2
• Impulse response computation
• Target signal computation
• Adaptive codebook search
• Decode of the adaptive codebook vector.

Open-Loop Pitch (OLP) Search
Three functions are provided for open-loop pitch (OLP) search. Use of these functions is mutually exclusive,
that is, only one is appropriate for an application during any given frame type. The appropriate choice of an
OLP search function depends upon the state of the discontinuous transmission ( DTX) and VAD modules. The
OLP search functions should be applied as follows:

 Encoder Mode                                        Appropriate Function

 DTX disabled                                       qplsOpenLoopPitchSearchNonDTX_GSMAMR

 DTX, VAD 1 enabled                                 qplsOpenLoopPitchSearchDTXVAD1_GSMAMR

 DTX, VAD 2 enabled                                 qplsOpenLoopPitchSearchDTXVAD2_GSMAMR

The OLP search functions extract a pitch estimate from a weighted version of the input speech. For 5.15 and
4.75 kbps frames, the search is performed once per frame. For all other frame rates, the search is performed
twice per frame. A unique search is employed for 10.2 kbps frames. The OLP search details are as follows:
If the transmission bit rate is 10.2 kbps, do the following:
1.   Compute a windowed autocorrelation of weighted speech, that is, where the sequence sw(n) contains
     weighted speech, and w is the weighting function given by In this weighting function, wl emphasizes
     low pitch, and is defined in terms of the table cw, while wn is a sequence of neighboring emphasis lag
     coefficients associated with the previous frame, that is and the parameter Told is the median filtered
     pitch lag of 5 previous voiced speech half frames.
     The estimated OLP lag is the value k that maximizes R(k). It is denoted by Top.
2.   Compute the optimal open-loop gain using the relation

     In addition,
     and

     If g > 0, the previous pitch lag buffer and v median pitch lag of the previous pitch lags are updated.
For rates other than 10.2 kbps, the following OLP search procedure is employed:
1.   Three maximums are found in three different ranges for the correlations given by

     For 5.15 and 4.75 kbps frames, length = 160.

                                                                                                587
---------------------Page 588---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

    For all other bit rates (except 10.2 kbps), length = 80.
2.  Normalize the three maximum correlations according to

3.  Determine the best open-loop lag using the following rule:
    Top = T1, M(Top) = M1, if M2 > 0.85 M(Top);
    M(T op) = M2, Top = T2, if M3 > 0.85 M(Top);
    Top = T3.
Each of the OLP search functions implements the rate-dependent search algorithms described above. Next,
details are given for non-DTX, VAD1, and VAD2 OLP search functions.

OpenLoopPitchSearchNonDTX_GSMAMR
Computes the OLP lag.

Syntax
QplStatus qplsOpenLoopPitchSearchNonDTX_GSMAMR_16s(const Qpl16s* pSrcWgtLpc1, const
Qpl16s* pSrcWgtLpc2, const Qpl16s* pSrcSpch, Qpl16s* pValResultPrevMidPitchLag, Qpl16s*
pValResultVvalue, Qpl16s* pSrcDstPrevPitchLag, Qpl16s* pSrcDstPrevWgtSpch, Qpl16s*
pDstOpenLoopLag, Qpl16s* pDstOpenLoopGain, QplSpchBitRate mode      );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcWgtLpc1                  Pointer to the vector with 44 elements of weighted LP coefficients,
                             represented using Q3.12 format. These LP coefficients comprise the
                             numerator of the perceptual weighting filter.
pSrcWgtLpc2                  Pointer to the vector with 44 elements of weighted LP coefficients,
                             represented using Q3.12 format. These LP coefficients comprise the
                             denominator of the perceptual weighting filter.
pSrcSpch                     Pointer to the input speech vector with 170 elements, represented
                             using Q15.0 format.
pValResultPrevMidPitchLag    Pointer to a vector of median filtered pitch lags from the five
                             previous voiced speech half-frames, represented using Q15.0
                             format. On output, points to the updated vector of median filtered
                             pitch lags from the five previous voiced speech half-frames,
                             represented using Q15.0 format. This argument is valid only for
                             10.2 kbps frames.
pValResultVvalue             Pointer to the adaptive parameter v, represented using Q0.15
                             format. On output, points to the updated adaptive parameter v ,
                             represented using Q0.15 format. This argument is valid only for
                             10.2 kbps frames.
pSrcDstPrevPitchLag          Pointer to a vector with five elements of pitch lags associated with
                             the five most recent voiced speech half-frames. On output, points to
                             the updated vector with five elements of pitch lags associated with
                             the five most recent voiced speech half-frames. This argument is
                             valid only for 10.2 kbps frames.

   588
---------------------Page 589---------------------

                                                                    Speech Coding Functions  9 

pSrcDstPrevWgtSpch          Pointer to a vector with 143 elements containing the perceptually
                            weighted speech associated with the previous frame, represented
                            using Q15.0 format. On output, points to the updated vector with
                            143 elements containing the perceptually weighted speech
                            associated with the previous frame, represented using Q15.0
                            format.
pDstOpenLoopLag             Pointer to a vector with two elements of OLP lags. For 5.15 and 4.75
                            kbps frames, only the first vector element contains a valid lag value,
                            since only one lag is estimated. For all other bit rates, both vector
                            elements contain valid pitch lag values.
pDstOpenLoopGain            Pointer to a vector with two elements containing optimal OLP gains,
                            represented using Q15.0 format. This argument is valid only for
                            10.2 kbps frames.
mode                        Bit rate specifier. Values between QPL_SPCHBR_4750 and
                            QPL_SPCHBR_12200  are valid.

Description
This function computes the OLP lag (as well as optimal pitch gain for 10.2 kbps frames only) when both DTX
and VAD are disabled.

Return Values

qplStsNoErr                      Indicates no error.

qplStsNullPtrErr                 Indicates an error when one of the specified pointers is NULL.

qplStsRangeErr                   Indicates an error when mode is not a valid element of the
                                 enumerated type  QplSpchBitRate .

See Also
Open-Loop Pitch Search

OpenLoopPitchSearchDTXVAD1_GSMAMR
Extracts an OLP lag estimate (VAD 1 scheme is
enabled).

Syntax
QplStatus qplsOpenLoopPitchSearchDTXVAD1_GSMAMR_16s(const Qpl16s* pSrcWgtLpc1, const
Qpl16s* pSrcWgtLpc2, const Qpl16s* pSrcSpch, Qpl16s* pValResultToneFlag, Qpl16s*
pValResultPrevMidPitchLag, Qpl16s* pValResultVvalue, Qpl16s* pSrcDstPrevPitchLag,
Qpl16s* pSrcDstPrevWgtSpch, Qpl16s* pResultMaxHpCorr, Qpl16s* pDstOpenLoopLag, Qpl16s*
pDstOpenLoopGain, QplSpchBitRate mode  );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

                                                                                        589
---------------------Page 590---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

Parameters

pSrcWgtLpc1                  Pointer to the vector with 44 elements of weighted LP coefficients,
                             represented using Q3.12 format. These LP coefficients comprise the
                             numerator of the perceptual weighting filter.
pSrcWgtLpc2                  Pointer to the vector with 44 elements of weighted LP coefficients,
                             represented using Q3.12 format. These LP coefficients comprise the
                             denominator of the perceptual weighting filter.
pSrcSpch                     Pointer to the input speech vector with 170 elements, represented
                             using Q15.0 format.
pValResultToneFlag           Pointer to the tone flag for the VAD module. On output, points to
                             the updated tone flag for the VAD module.
pValResultPrevMidPitchLag    Pointer to a vector of median filtered pitch lags from the five
                             previous voiced speech half-frames, represented using Q15.0
                             format. On output, points to the updated vector of median filtered
                             pitch lags from the five previous voiced speech half-frames,
                             represented using Q15.0 format. This argument is valid only for
                             10.2 kbps frames.
pValResultVvalue             Pointer to the adaptive parameter v, represented using Q0.15
                             format. On output, points to the updated adaptive parameter  v ,
                             represented using Q0.15 format. This argument is valid only for
                             10.2 kbps frames.
pSrcDstPrevPitchLag          Pointer to a vector with five elements of pitch lags associated with
                             the five most recent voiced speech half-frames. On output, points to
                             the updated vector with five elements of pitch lags associated with
                             the five most recent voiced speech half-frames. This argument is
                             valid only for 10.2 kbps frames.
pSrcDstPrevWgtSpch           Pointer to a vector with 143 elements containing the perceptually
                             weighted speech associated with the previous frame, represented
                             using Q15.0 format. On output, points to the updated vector with
                             143 elements containing the perceptually weighted speech
                             associated with the previous frame, represented using Q15.0
                             format.
pResultMaxHpCorr             Pointer to the correlation maximum.

pDstOpenLoopLag              Pointer to a vector with two of OLP lags with two elements. For 5.15
                             and 4.75 kbps frames, only the first vector element contains a valid
                             lag value, since only one lag is estimated. For all other bit rates,
                             both vector elements contain valid pitch lag values.
pDstOpenLoopGain             Pointer to a vector with two elelemnts containing optimal OLP gains,
                             represented using Q15.0. format This argument is valid only for
                             10.2 kbps frames.
mode                         Bit rate specifier. Values between QPL_SPCHBR_4750  and
                             QPL_SPCHBR_12200   are valid.

Description
This function extracts an OLP lag estimate from the weighted input speech when the VAD 1 scheme is
enabled using a version of the pitch search algorithm that is modified as follows:
1. For 10.2 kbps frames, the following modification is applied after the best OLP is found:
Update the tone flag (when initialized or reset, it is set to 0) in the following way
toneflag >>=1
if 0.325*DelayEnergy < MaxCorr , toneflag = toneflag|0x4000   .

   590
---------------------Page 591---------------------

                                                                       Speech Coding Functions  9 

On the second OLP search for the current frame, find the maximum of the high-pass filtered autocorrelations,
that is
maxhpcorr = max(2R(k) - R(k-1) - R(k+1)|k = 142, ..., 21)
Then, maxhpcorr is normalized by NormFactor = frameEnergy - frameCorr :

2. For all other bit rates, the following modifications are applied:
a. Before the OLP search, update the tone flag as follows:
toneflag = toneflag  >>1
If the bit rate is either 5.15 or 4.75 kbps, update the tone flag as follows:
toneflag = toneflag  >> 1, toneflag  = toneflag | 0x2000
b. After finding three OLP candidates, update the tone flag as follows:
if (DelayEnergy × 0.65 < MaxCorr) toneflag = toneflag  | 0x4000
This update is repeated three times with DelayEnergy and MaxCorr corresponding to the three pitch
candidates. Note that the computation length of DelayEnergy and MaxCorr for 4.75 and 5.15 kbps frames is
160 samples. For all other bit rates, the length is 80 samples.
c. On the second OLP search for each frame, find the maximum of the high passed autocorrelations. The
implementation is identical the 10.2 kbps correlation search, but the search range is rate-dependent.

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointers is NULL.

qplStsRangeErr                    Indicates an error when mode  is not a valid element of the
                                  enumerated type   QplSpchBitRate .

See Also
Open-Loop Pitch Search

OpenLoopPitchSearchDTXVAD2_GSMAMR
Extracts an OLP lag estimate (VAD 2 scheme is
enabled).

Syntax
QplStatus qplsOpenLoopPitchSearchDTXVAD2_GSMAMR_16s32s(const Qpl16s* pSrcWgtLpc1, const
Qpl16s* pSrcWgtLpc2, const Qpl16s* pSrcSpch, Qpl16s* pValResultPrevMidPitchLag, Qpl16s*
pValResultVvalue, Qpl16s* pSrcDstPrevPitchLag, Qpl16s* pSrcDstPrevWgtSpch, Qpl32s*
pResultMaxCorr, Qpl32s pResultWgtEnergy, Qpl16s* pDstOpenLoopLag, Qpl16s*
pDstOpenLoopGain, QplSpchBitRate mode    );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

                                                                                           591
---------------------Page 592---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

Parameters

pSrcWgtLpc1                  Pointer to the vector with 44 elements of weighted LP coefficients,
                             represented using Q3.12 format. These LP coefficients comprise the
                             numerator of the perceptual weighting filter.
pSrcWgtLpc2                  Pointer to the vector with 44 elements of weighted LP coefficients,
                             represented using Q3.12 format. These LP coefficients comprise the
                             denominator of the perceptual weighting filter.
pSrcSpch                     Pointer to the input speech vector with 170 elements, represented
                             using Q15.0 format.
pValResultToneFlag           Pointer to the tone flag for the VAD module.

pValResultPrevMidPitchLag    Pointer to a vector of median filtered pitch lags from the five
                             previous voiced speech half-frames, represented using Q15.0
                             format. On output, points to the updated vector of median filtered
                             pitch lags from the five previous voiced speech half-frames,
                             represented using Q15.0 format. This argument is valid only for
                             10.2 kbps frames.
pValResultVvalue             Pointer to the adaptive parameter v, represented using Q0.15
                             format. On output, points to the updated adaptive parameter  v,
                             represented using Q0.15 format. This argument is valid only for
                             10.2 kbps frames.
pSrcDstPrevPitchLag          Pointer to a five-element vector of pitch lags associated with the
                             five most recent voiced speech half-frames. On output, points to the
                             updated five-element vector of pitch lags associated with the five
                             most recent voiced speech half-frames. This argument is valid only
                             for 10.2 kbps frames.
pSrcDstPrevWgtSpch           Pointer to a vector with 143 elements containing the perceptually
                             weighted speech associated with the previous frame, represented
                             using Q15.0 format. On output, points to the updated vector with
                             143 elements containing the perceptually weighted speech
                             associated with the previous frame, represented using Q15.0
                             format.
pResultMaxCorr               Pointer to the correlation maximum.

pResultWgtEnergy             Pointer to the pitch delayed energy of the weighted speech signal,
                             as described above. The output may be scaled, and the Q
                             representation is not given.
pDstOpenLoopLag              Pointer to a vector of OLP lags with two elements. For 5.15 and 4.75
                             kbps frames, only the first vector element contains a valid lag value,
                             since only one lag is estimated. For all other bit rates, both vector
                             elements contain valid pitch lag values.
pDstOpenLoopGain             Pointer to a vector with two elements containing optimal OLP gains,
                             represented using Q15.0 format. This argument is valid only for
                             10.2 kbps frames.
mode                         Bit rate specifier. Values between QPL_SPCHBR_4750 and
                             QPL_SPCHBR_12200   are valid.

Description
This function extracts an OLP lag estimate from the weighted input speech when the VAD 2 scheme is
enabled, using a version of the pitch search algorithm that is modified in the following way:

   592
---------------------Page 593---------------------

                                                                      Speech Coding Functions  9 

After finding the best OLP, extract from the weighted speech the maximum correlation MaxCorr and the
delayed energy DelayEnergy. For both 4.75 and 5.15 kbps frames, the computation is carried for 160
samples. For all other bit rates, the computation is carried for only 80 samples using the relations

The MaxCorr and DelayEnergy  values corresponding to the two half-frame OLP lag estimates are combined
to obtain whole-frame estimates of MaxCorr and DelayEnergy (except during 4.75 and 5.15 kbps frames,
when the OLP search is performed only once per frame).

Return Values

qplStsNoErr                      Indicates no error.

qplStsNullPtrErr                 Indicates an error when one of the specified pointers is NULL.

qplStsRangeErr                   Indicates an error when mode  is not a valid element of the
                                 enumerated type   QplSpchBitRate .

See Also
Open-Loop Pitch Search

ImpulseResponseTarget_GSMAMR
Computes the impulse response and target signal
required for the adaptive codebook search.

Syntax
QplStatus qplsImpulseResponseTarget_GSMAMR_16s(const Qpl16s* pSrcSpch, const Qpl16s*
pSrcWgtLpc1, const Qpl16s* pSrcWgtLpc2, const Qpl16s* pSrcQLpc, const Qpl16s*
pSrcSynFltState, const Qpl16s* pSrcWgtFltState, Qpl16s* pDstImpulseResponse, Qpl16s*
pDstLpResidual, Qpl16s* pDstAdptTarget   );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcSpch                     Pointer to the input speech vector with 50 elements, where
                             elements 0 - 9 are from the previous subframe, and elements 10 -
                             49 are from the current subframe.
pSrcWgtLpc1                  Pointer to a vector with eleven elements of weighted LP coefficients
                             associated with A(z/γ1) on the current subframe, represented using
                             Q3.12 format.
pSrcWgtLpc2                  Pointer to a vector with eleven elements of weighted LP coefficients
                             associated with A(z/γ2) on the current subframe, represented using
                             Q3.12 format.
pSrcQLpc                     Pointer to a vector with eleven elements of quantized LP coefficients
                             for the current subframe, represented using Q3.12 format.
pSrcSynFltState              Pointer to the vector with ten elements that contains the state of
                             the synthesis filter, represented using Q15.0 format.

                                                                                          593
---------------------Page 594---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

pSrcWgtFltState              Pointer to the vector with ten elements that contains the state of
                             the weighting filter, represented using Q15.0 format.
pDstImpulseResponse          Pointer to the vector with 40 elements that contains the impulse
                             response, represented using Q3.12 format.
pDstLpResidual               Pointer to the vector with 40 elements that contains the LP residual,
                             represented using Q15.0 format.
pDstAdptTarget               Pointer to the vector with 40 elements that contains the LP residual,
                             represented using Q15.0 format.

Description
This function computes the impulse response and target signal required for the adaptive codebook search.
This function is performed on a subframe basis using the following approach:
1.  The impulse response h( n) of the weighted synthesis filter, H(z)W(z) = A(z/γ1)/[ Â(z) A(z/γ2) , is
    computed by applying the filters 1/Â(z) and 1/A(z/γ2) to the zero-padded impulse response of the
    filter A(z/γ1).
2.  The target signal is then obtained by applying to the LP residual resLP(n) the cascaded synthesis and
    weighting filters 1/Â(z) and A(z/γ1)/A(z/γ2) , respectively. The adaptive codebook search also uses
    the residual signal resLP(n to update the history of past excitations. The LP residual is obtained by
    inverse filtering the input speech, that is

Return Values

qplStsNoErr                       Indicates no error.

QplStsNullPtrErr                  Indicates an error when one of the specified pointers is NULL.

AdaptiveCodebookSearch_GSMAMR
Performs the adaptive codebook search.

Syntax
QplStatus qplsAdaptiveCodebookSearch_GSMAMR_16s(const Qpl16s* pSrcTarget, const Qpl16s*
pSrcImpulseResponse, Qpl16s* pSrcOpenLoopLag, Qpl16s* pValResultPrevIntPitchLag,
Qpl16s* pSrcDstExcitation, Qpl16s* pResultFracPitchLag, Qpl16s* pResultAdptIndex,
Qpl16s* pDstAdptVector, Qpl16s subFrame, QplSpchBitRate mode       );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcTarget                   Pointer to the adaptive target signal vector with 40 elements,
                             represented using Q15.0 format. This should be aligned on an
                             8‑byte boundary.
pSrcImpulseResponse          Pointer to the impulse response of the weighted synthesis filter with
                             40 elements, represented using Q3.12 format. This should be
                             aligned on an 8‑byte boundary.

   594
---------------------Page 595---------------------

                                                                     Speech Coding Functions  9 

pSrcOpenLoopLag              Pointer to the OLP lags vector with two elements. For 5.15 and 4.75
                             kbps frames, only the first vector element contains a valid lag value,
                             since only one lag is estimated. For all other bit rates, both vector
                             elements contain valid pitch lag values.
pValResultPrevIntPitchLag    Pointer to the previous integral pitch lag.

pSrcDstExcitation            Pointer to the excitation vector with 194 elements. Elements 0 ~
                             153 contain the past excitation, represented using Q15.0. Elements
                             154 ~ 193 are used as a buffer whenever the subframe length
                             exceeds the pitch lag. On output, elements 154 - 193 are updated
                             to contain the adaptive codebook vector.
pResultFracPitchLag          Pointer to the fractional pitch lag obtained during the adaptive
                             codebook search.
pResultAdptIndex             Pointer to the coded closed-loop pitch index.

pDstAdptVector               Pointer to the adaptive codebook vector with 40 samples,
                             represented using Q15.0 format.
subFrame                     Subframe index.

mode                         Bit rate specifier. Values between QPL_SPCHBR_4750 and
                             QPL_SPCHBR_12200  are valid.

Description
This function performs the adaptive codebook search. The adaptive codebook search consists of a closed-loop
pitch search followed by computation of an adaptive excitation vector. The adaptive excitation vector is
obtained by interpolating the past excitation at the fractional pitch lag obtained during the closed-loop pitch
search. The adaptive codebook is searched on every subframe.

Return Values

qplStsNoErr                      Indicates no error.

QplStsNullPtrErr                 Indicates an error when one of the specified pointers is NULL.

qplStsRangeErr                   Indicates an error when mode  is not a valid element of the
                                 enumerated type   QplSpchBitRate .
qplStsSizeErr                    Indicates an error when subFrame  is not in the range [0, 3].

AdaptiveCodebookDecode_GSMAMR
Decodes the adaptive codebook parameters.

Syntax
QplStatus qplsAdaptiveCodebookDecode_GSMAMR_16s(Qpl16s valAdptIndex, Qpl16s*
pValResultPrevIntPitchLag, Qpl16s* pValResultLtpLag, Qpl16s* pSrcDstExcitation, Qpl16s*
pResultIntPitchLag, Qpl16s* pDstAdptVector, Qpl16s subFrame, Qpl16s bfi, Qpl16s
inBackgroundNoise, Qpl16s voicedHangover, QplSpchBitRate mode      );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

                                                                                          595
---------------------Page 596---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

Parameters

valAdptIndex                  Adaptive codebook index.

pValResultPrevIntPitchLag     Pointer to the previous integer pitch lag. Used as an output
                              argument also.
pValResultLtpLag              Pointer to the LTP-Lag value. Used as an output argument also.

pSrcDstExcitation             Pointer to the excitation vector with 194 elements. Elements 0 ~
                              153 contain the past excitation, represented using Q15.0 format.
                              Elements 154 ~ 193 are used as a buffer whenever the subframe
                              length exceeds the pitch lag. On output, elements 154 - 193 are
                              updated to contain the adaptive codebook vector.
pResultIntPitchLag            Pointer to the integer pitch.

pDstAdptVector                Pointer to the adaptive codebook vector with 40 samples,
                              represented using Q15.0 format.
subFrame                      Subframe index.

bfi                           Bad frame indicator. “0” signifies a valid frame; any other value
                              signifies an invalid frame.
inBackgroundNoise             Indicator that the previous frame is considered to contain
                              background noise and only shows minor energy level changes.
voicedHangover                Counter used to monitor the time since a frame was presumably
                              voiced.
mode                          Bit rate specifier. Values between QPL_SPCHBR_4750   and
                              QPL_SPCHBR_12200   are valid.

Description
This function decodes the adaptive codebook parameters transmitted by the encoder, and then applies them
to interpolate an adaptive codebook vector. If errors are detected on the received frame, previously received
parameters are used to approximate the parameters of the current frame and the adaptive codebook vector
interpolation procedure is carried with the approximated parameter set. Adaptive codebook vectors are
decoded for every subframe as follows:
1.   If no errors are detected on the current frame, integer and fractional pitch lags are extracted from the
     adaptive codebook indices.
2.   If errors are detected, the integer pitch is recovered either from the previous integer pitch or the LTP-
     Lag, and the fractional pitch is set to zero. The LTP-Lag value is replaced by the integer pitch of the 4th
     subframe of the previous frame (12.2 Kbps mode) or slightly modified values based on the last
     correctly received value (all other modes).
3.   The same adaptive codebook interpolation procedure described in section 13.4.3 is applied to obtain the
     adaptive codebook vector.

Return Values

qplStsNoErr                        Indicates no error.

QplStsNullPtrErr                   Indicates an error when one of the specified pointers is NULL.

qplStsRangeErr                     Indicates an error when  mode is not a valid element of the
                                   enumerated type   QplSpchBitRate  .
qplStsSizeErr                      Indicates an error when  subFrame  is not in the range [0, 3].

   596
---------------------Page 597---------------------

                                                                      Speech Coding Functions  9 

AdaptiveCodebookGain_GSMAMR
Calculates the gain of the adaptive-codebook vector
and the filtered codebook vector.

Syntax
QplStatus qplsAdaptiveCodebookGain_GSMAMR_16s (const Qpl16s* pSrcAdptTarget, const
Qpl16s* pSrcFltAdptVector, Qpl16s* pResultAdptGain     );
QplStatus qplsAdaptiveCodebookGainCoeffs_GSMAMR_16s (const Qpl16s* pSrcAdptTarget,
const Qpl16s* pSrcFltAdptVector, Qpl16s* pResultAdptGain, Qpl16s*
pResultAdptGainCoeffs  );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcAdptTarget               Pointer to the adaptive target signal vector [40].

pSrcFltAdptVector            Pointer to the filtered adaptive-codebook vector [40], in Q12
                             format.
pResultAdptGain              Pointer to the output adaptive-codebook gain gp, in Q14 format.

pResultAdptGainCoeffs        Pointer to the output gain coefficients vector [4] , in Q15 format.

Description

qplsAdaptiveCodebookGain_GSMAMR_16s   . This function calculates the adaptive-codebook gain gp using
the following formula:

bounded by 0 ≤gp ≤ 1.2, in Q14 format,
where x is the adaptive target signal vector, and y is the filtered adaptive-codebook vector.
qplsAdaptiveCodebookGainCoeffs_GSMAMR_16s    . This function calculates the adaptive-codebook gain gp
in the same way as the qplsAdaptiveCodebookGain_GSMAMR_16s  function does, and additionally returns
the gain in a different representation given by the following formula:

The mantissas cxy , cyy and exponents expxy , expyy for both the normalized denominator and normalized
numerator are returned in the pResultAdptGainCoeffs vector:
pResultAdptGainCoeffs  [0] = cyy,
pResultAdptGainCoeffs  [1] = expyy,
pResultAdptGainCoeffs  [2] = cxy,
pResultAdptGainCoeffs  [3] = expxy.
If cxy < 4, then zero gain is returned.

                                                                                          597
---------------------Page 598---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

Return Values

qplStsNoErr                      Indicates no error.

QplStsNullPtrErr                 Indicates an error when one of the specified pointers is NULL.

Fixed Codebook Search
This section describes primitives that are concerned with the fixed codebook, including primitives that
perform the following functions:
• Fixed (algebraic) codebook search
• Fixed codebook vector decode

AlgebraicCodebookSearch_GSMAMR
Searches the algebraic codebook.

Syntax
QplStatus qplsAlgebraicCodebookSearch_GSMAMR_16s(Qpl16s valIntPitchLag, Qpl16s
valBoundQAdptGain, const Qpl16s* pSrcFixedTarget, const Qpl16s* pSrcLtpResidual,
Qpl16s* pSrcDstImpulseResponse, Qpl16s* pDstFixedVector, Qpl16s* pDstFltFixedVector,
Qpl16s* pDstEncPosSign, Qpl16s subFrame, QplSpchBitRate mode    );
QplStatus qplsAlgebraicCodebookSearchEX_GSMAMR_16s(Qpl16s valIntPitchLag, Qpl16s
valBoundQAdptGain, const Qpl16s* pSrcFixedTarget, const Qpl16s* pSrcLtpResidual,
Qpl16s* pSrcDstImpulseResponse, Qpl16s* pDstFixedVector, Qpl16s* pDstFltFixedVector,
Qpl16s* pDstEncPosSign, Qpl16s subFrame, QplSpchBitRate mode, Qpl32s* pBuffer      );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

valIntPitchLag              The nearest integer pitch lag T to the closed-loop fractional pitch lag
                            of this subframe, which is computed by closed-loop pitch search
                            routine.
valBoundQAdptGain           Bounded quantized adaptive codebook gain. For MR122 mode, this
                            value is the bounded quantized pitch gain of current subframe.
                            While for other modes, it is the bounded quantized pitch gain of
                            previous subframe. This value is represented using Q1.14 format.
pSrcFixedTarget             Pointer to the fixed target signal vector x2(n) with 40 elements,
                            which is used to search the fixed codebook vector, represented
                            using Q15.0 format. This should be aligned on an 8‑byte boundary.
pSrcLtpResidual             Pointer to the long-term prediction residual signal vector resLTP(n)
                            with 40 elements, represented using Q15.0 format.
pSrcDstImpulseResponse      Pointer to the weighted synthesis filter impulse response vector with
                            40 elements, represented using Q3.12 format. This should be
                            aligned on an 8‑byte boundary. On output, points to the updated

   598
---------------------Page 599---------------------

                                                                       Speech Coding Functions  9 

                             impulse response vector with 40 elements, which is obtained by
                             filtering original impulse response h(n) through the pre-filter FE(z).
                             It is represented using Q3.12 format.
pDstFixedVector              Pointer to the fixed codebook vector c( n) with 40 elements,
                             represented using Q2.13 format.
pDstFltFixedVector           Pointer to the filtered fixed codebook vector z( n) with 40 elements,
                             which is obtained by convolving the impulse response with the fixed
                             codebook vector, represented using Q2.13 format.
pDstEncPosSign               Pointer to the buffer with ten elements that contains the encoded
                             positions and signs of optimal pulses. For 12.2 kbps mode, ten short
                             words are used to store the result of this encoding. For the 10.2
                             kbps mode, seven short words are used. For all other modes, only
                             two short words are used.
subFrame                     Subframe index, which ranges from 0 to 3.

pBuffer                      Pointer to internal working buffer, of length 1K.

mode                         Bit rate specifier. Values between QPL_SPCHBR_4750  and
                             QPL_SPCHBR_12200   are valid.

Description
These functions search the algebraic codebook by minimizing the mean square error between the weighted
input speech and the weighted synthesized speech. After the fixed codebook vector has been obtained, it is
filtered through the weighted synthesis filter to obtain a fixed codebook vector. The positions and signs of the
optimal pulses are encoded respectively according to the GSM06.90 specification. Algebraic codebook search
is applied on each subframe.
These two functions work identically with the following exception:
qplsAlgebraicCodebookSearchEX_GSMAMR     uses an internal working buffer pointed by pBuffer allocated
by user, but qplsAlgebraicCodebookSearch_GSMAMR   allocates this internal working buffer in stack.

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointers is NULL.

qplStsRangeErr                    Indicates an error when mode  is not a valid element of the
                                  enumerated type   QplSpchBitRate .

FixedCodebookDecode_GSMAMR
Decodes the fixed codebook vector.

Syntax
QplStatus qplsFixedCodebookDecode_GSMAMR_16s(const Qpl16s* pSrcFixedIndex, Qpl16s*
pDstFixedVector, Qpl16s subFrame, QplSpchBitRate mode      );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

                                                                                           599
---------------------Page 600---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

Parameters

pSrcFixedIndex               Pointer to the fixed codebook index vector. If the mode is 12.2
                             kbps, the vector length is 10 elements; if the mode is 10.2 kbps,
                             the vector length is 7; otherwise the vector length is 2.
pDstFixedVector              Pointer to the fixed codebook vector with 40 elements.

subFrame                     Subframe index.

mode                         Bit rate specifier. Values between QPL_SPCHBR_4750  and
                             QPL_SPCHBR_12200   are valid.

Description
This function decodes the fixed codebook vector from the received fixed codebook index.

Return Values

qplStsNoErr                       Indicates no error.

QplStsNullPtrErr                  Indicates an error when one of the specified pointers is NULL.

qplStsRangeErr                    Indicates an error when  mode is not a valid element of the
                                  enumerated type   QplSpchBitRate  .
qplStsSizeErr                     Indicates an error when  subFrame  is not in the range [0, 3].

Discontinuous Transmission (DTX)
This section describes primitives that are concerned with discontinuous transmission (DTX), including
primitives that perform the following functions:
• Signal pre-emphasis prior to VAD option 2
• VAD Decision Function for Option 1
• VAD Decision Function for Option 2
• Parameter Extraction for the SID frame
• DTX Handler
• DTX Buffering
Each of these primitives is described next.

Preemphasize_GSMAMR
Computes pre-emphasis of an input signal in VAD
option 2.

Syntax
QplStatus qplsPreemphasize_GSMAMR_16s (Qpl16s gamma, const Qpl16s* pSrc, Qpl16s* pDst,
int len, Qpl16s* pMem  );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h , qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

   600
---------------------Page 601---------------------

                                                                      Speech Coding Functions  9 

Parameters

gamma                        The filter coefficient, in Q15 format.

pSrc                         Pointer to the source vector, in Q0 format.

pDst                         Pointer to the destination vector, in Q0 format.

len                          Number of elements in the source and destination vectors.

pMem                         Pointer to the filter memory [1].

Description
This function computes pre-emphasis of the input signal prior to frequency domain conversion in VAD option
2. The function qplsPreemphasize_GSMAMR performs the same operation as the Preemphasize_G729A
function does, but has a slightly different order to deliver accuracy required by the GSM-AMR transcoding
standard.

Return Values

qplStsNoErr                       Indicates no error.

QplStsNullPtrErr                  Indicates an error when one of the specified pointers is NULL.

qplStsSizeErr                     Indicates an error when len is less than or equal to 0.

VAD1_GSMAMR
Implements the VAD functionality corresponding to
VAD option 1.

Syntax
QplStatus qplsVAD1_GSMAMR_16s(const Qpl16s pSrcSpch, QplGSMAMRVad1State*
pValResultVad1State, Qpl16s* pResultVadFlag, Qpl16s maxHpCorr, Qpl16s toneFlag        );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcSpch                     Pointer to the input speech signal with 160 elements, represented in
                             Q0 format.
pValResultVad1State          On input, pointer to the VAD Option 1 history variables. On output,
                             points to the updated VAD Option 1 history variables. The structure
                             QplGSMAMRVad1State   is defined below.
pResultVadFlag               Pointer to the VAD flag of this frame. If set to “1”, it indicates the
                             presence of signals that should be transmitted. If set to “0”, no
                             need to transmit signals from this frame.
maxHpCorr                    best_corr_hp value of previous frame, which is the maximum
                             normalized value of the high pass filtered correlation. This value is
                             the output of the OLP search function..

                                                                                          601
---------------------Page 602---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

toneFlag                        Tone flag, which indicates the presence of information tones or
                                signals containing very strong periodic component. This value is the
                                output of the OLP search function.

Description
This function implements the VAD functionality corresponding to VAD option 1 of ETSI GSM 06.94. It is used
to indicate whether each 20ms frame contains signals that should be transmitted - for example, speech,
music or information tones. The structure QplGSMAMRVad1State    contains the history variables of VAD Option
1. These variables are initialized before the beginning of the encoder, and can be only updated by this
function. Refer to ETSI GSM 06.94 VAD Option 1 specification for details of the implementation.
 typedef struct{                                       Description

 Qpl16s pPrevSignalLevel[9];                           Signal level vector of level[n] previous frame.
 Qpl16s pPrevSignalSublevel[9];                        Intermediate signal sublevel vector of previous frame.
 Qpl16s pPrevAverageLevel[9];                          Average signal level vector ave_level[ n] of previous
                                                       frame.
 Qpl16s pBkgNoiseEstimate[9];                          Background noise estimate vector back_est[ n] of
                                                       previous frame.
 Qpl16s pFifthFltState[6];                             The history state of the most recent three 5th order filters
                                                       of filter bank.
 Qpl16s pThirdFltState[5];                             The history state of the most recent five 3rd order filters
                                                       of filter bank.
 Qpl16s burstCount;                                    Burst counter burst_count that counts length of a speech
                                                       burst, used by VAD hangover addition.
 Qpl16s hangCount;                                     Hang counter hang_counter that is used by VAD hangover
                                                       addition.
 Qpl16s statCount;                                     Stationary counter variable stat_count that is used in
                                                       background noise estimation.
 Qpl16s vadReg;                                        Value that indicates intermediate VAD decision.
 Qpl16s complexHigh;                                   complex_high value that is used as intermediate complex
                                                       signal decision.
 Qpl16s complexLow;                                    complex_low value that is used as intermediate complex
                                                       signal decision.
 Qpl16s complexHangTimer;                              complex_hang_timer that is used as hangover initiator by
                                                       Complex Activity Estimation.
 Qpl16s complexHangCount;                              complex_hang_count that is used as hangover counter by
                                                       VAD hangover addition.
 Qpl16s complexWarning;                                complex_warning flag.
 Qpl16s corrHp;                                        The high-pass filtered value of best_corr_hp.
 Qpl16s pitchFlag;                                     Pitch flag that indicates the presence of vowel sounds and
                                                       other periodic signals.
 }QplGSMAMRVad1State.

For the detail usage of these history variables, please refer to ETSI GSM 06.94.

Return Values

qplStsNoErr                          Indicates no error.

QplStsNullPtrErr                     Indicates an error when one of the specified pointers is     NULL .

   602
---------------------Page 603---------------------

                                                                          Speech Coding Functions  9  

VAD2_GSMAMR
Implements the VAD functionality corresponding to
VAD option 2.

Syntax
QplStatus qplsVAD2_GSMAMR_16s(const Qpl16s* pSrcSpch, QplGSMAMRVad2State*
pValResultVad2State, Qpl16s* pResultVadFlag, Qpl16s ltpFlag          );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h , qplvm.h , qpls.h
Libraries: qplcore.lib, qplvm.lib , qpls.lib

Parameters

pSrcSpch                      Pointer to the input speech signal with 160 elements, represented in
                              Q0 format.
pValResultVad2State           On input, pointer to the VAD Option 2 history variables. On output,
                              points to the updated VAD Option 2 history variables. The structure
                              QplGSMAMRVad2State     is defined below.
pResultVadFlag                Pointer to the Boolean flag  VAD_flag . If set to “1”, it indicates the
                              presence of signals that should be transmitted. If set to “0”, no
                              need to transmit signals from this frame.
ltpFlag                       LTP_flag   value in GSM 06.94 equation (4.24), which is generated
                              by the comparison of the long-term prediction to a constant
                              threshold  LTP_THLD .

Description
This function implements the VAD functionality corresponding to VAD option 2 of ETSI GSM 06.94. It is used
to indicate whether each 20ms frame contains signals that must be transmitted. For example, speech, music,
or information tones. The structure QplGSMAMRVad2State contains the history variables of VAD Option 2:

 typedef struct{                                  Description
 Qpl32s pEngyEstimate[16];                        Channel energy estimates vector Ech of current half-frame,
                                                  which is calculated during the previous half-frame according
                                                  to the equation ETSI GSM 06.94 (4.4).
 Qpl32s pNoiseEstimate[16];                       Channel noise estimate vector En of current half-frame,
                                                  which is calculated during the previous half-frame according
                                                  to the equation ETSI GSM 06.94 (4.26).
 Qpl16s pLongTermEngyDb[16];                      Channel average long-term spectral estimate vector ĒdB,
                                                  which is calculated during the previous half-frame according
                                                  to the equation ETSI GSM 06.94 (4.20).
 Qpl16s preEmphasisFactor;                        Pre-emphasis factor ζp, which is used to pre-emphasize the
                                                  input speech signal according to the equation ETSI GSM
                                                  06.94 (4.1).
 Qpl16s updateCount;                              update_cnt value used in background noise update decision
                                                  logic.
 Qpl16s lastUpdateCount;                          last_update_cnt value used in background noise update
                                                  decision logic.

                                                                                                603
---------------------Page 604---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

 typedef struct{                                    Description

 Qpl16s hysterCount;                               hyster_cnt value used in background noise update decision
                                                   logic.
 Qpl16s prevNormShift;                             Shifted bits of previous half-frame input speech, normalized
                                                   to obtain high precision and avoid overflow, when doing FFT
                                                   transformation.
 Qpl16s shiftState;                                Shift state flag which indicates whether previous half-frame
                                                   was shifted or not.
 Qpl16s forcedUpdateFlag;                          fupdate_flag value which is the result of forced update logic
                                                   of background noise update decision.
 Qpl16s ltpSnr;                                    Long-term peak signal-noise ratio SNRp of previous half-
                                                   frame, which is used to calibrate the responsiveness of the
                                                   VAD decision.
 Qpl16s variabFactor;                              Variability factor ψ of previous half-frame, which indicates
                                                   the variability of the background noise estimate and is
                                                   updated according to the equation ETSI GSM 06.94 (4.13).
 Qpl16s negSnrBias;                                Negative SNR sensitivity bias factor μ of previous half-frame.
 Qpl16s burstCount;                                Burst counter b(m) used in the 10ms half-frames's VAD
                                                   Decision.
 Qpl16s hangOverCount;                             Hangover counter h(m) used in the 10ms half-frame's VAD
                                                   Decision.
 Qpl32s frameCount;                                Half-frame counter.
 }QplGmrVad2State;

Please refer to ETSI GSM 06.94 VAD Option 2 specification for details.

Return Values

qplStsNoErr                         Indicates no error.

qplStsNullPtrErr                    Indicates an error when one of the specified pointers is    NULL .

EncDTXSID_GSMAMR
Extracts parameters for the SID frame.

Syntax
QplStatus qplsEncDTXSID_GSMAMR_16s(const Qpl16s* pSrcLspBuffer, const Qpl16s*
pSrcLogEnergyBuffer, Qpl16s* pValResultLogEnergyIndex, Qpl16s*
pValResultDtxLsfRefIndex, Qpl16s* pSrcDstQLsfIndex, Qpl16s* pSrcDstPredQErr, Qpl16s*
pSrcDstPredQErrMR122, Qpl16s sidFlag       );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h  , qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib  , qpls.lib

   604
---------------------Page 605---------------------

                                                                      Speech Coding Functions  9 

Parameters

pSrcLspBuffer                Pointer to the LSP coefficients of eight consecutive frames marked
                             with VAD = 0, represented in Q0.15 format. The LSP coefficients
                             vector has 80 elements.
pSrcLogEnergyBuffer          Pointer to the log energy coefficients of eight consecutive frames
                             marked with unvoiced, represented in Q5.10 format. The log energy
                             coefficients vector has eight elements.
pValResultLogEnergyIndex     Size of the subframe pointer to the LSF quantization reference index
                             of last frame. On output, points to the LSF quantization reference
                             index of the current DTX frame.
pValResultDtxLsfRefIndex     Pointer to the LSF quantization reference index of the last frame. On
                             output, points to the LSF quantization reference index of the current
                             DTX frame.
pSrcDstQLsfIndex             Pointer to the LSF residual quantization indices vector of last frame
                             with three elements. On output, points to the LSF residual
                             quantization indices of current frame vector with three elements.
pSrcDstPredQErr              Pointer to the fixed gain prediction error vector of four previous
                             subframes for non-12.2 Kbps modes, represented in Q5.10 format.
                             The fixed gain prediction error vector has four elements. On output,
                             points to the updated fixed gain prediction error vector for non 12.2
                             Kbps modes, represented in Q5.10. The updated vector has four
                             elements.
pSrcDstPredQErrMR122         Pointer to the fixed gain prediction error vector of four previous
                             subframes for 12.2 Kbps, represented in Q5.10 format. The fixed
                             gain prediction error vector has four elements. On output, points to
                             the updated fixed gain prediction error vector for 12.2 Kbps mode,
                             represented in Q5.10 format. The updated vector has four elements.
sidFLag                      The SID flag of the current frame. If it is set to 1, the current frame
                             is a SID frame, and the function will extract the LSF and energy
                             parameters. If it is set to 0, the LSF and energy parameters are
                             copied from the previous frame.

Description
This function is called only when the current frame is a DTX frame. If the SID flag is on, the function extracts
the LSF quantization parameter and the energy index parameter for the SID frame. If the SID flag is off, no
operation is needed, and all parameters are copied from the last frame.

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointers is NULL.

EncDTXHandler_GSMAMR
Determines the SID flag of current frame.

Syntax
QplStatus qplsEncDTXHandler_GSMAMR_16s(Qpl16s* pValResultHangOverCount, Qpl16s*
pValResultDtxElapsedCount, Qpl16s* pValResultUsedMode, Qpl16s* pResultSidFlag, Qpl16s
vadFlag);

Include Files
qplsc.h

                                                                                          605
---------------------Page 606---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

Domain Dependencies
Headers: qplcore.h, qplvm.h , qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pValResultHangOverCount      Pointer to the DTX hangover count. When initialized or reset, it is
                             set to 0. On output, points to the updated DTX hangover count.
pValResultDtxElapsedCount    Pointer to the elapsed frame count since the last non-DTX frame.
                             When initialized or reset, it is set to “0”. On output, points to the
                             updated elapsed frame count since the last non-DTX frame.
pValResultUsedMode           Pointer to the transmission mode. At the input stage, the mode is
                             one of the bit rate modes ranging from 4.75 Kbps to 12.2 Kbps. At
                             the output stage, this value is either unchanged or set to the DTX
                             frame mode.
pResultSidFlag               Pointer to the output SID flag, “1” indicates a SID frame, and “0”
                             indicates a non-SID frame.
vadFlag                      This is the VAD flag of the current frame, if it is set to “1”, the
                             current frame is marked as voiced, and if it is set to “0”, it is
                             marked as unvoiced.

Description
This function determines the SID flag of current frame, and it determines whether the current frame should
use DTX encoding, as follows:
1.  Update the elapsed frame count since last SID frame: DTX_ElapsedCount = DTX_ElapsedCount +
    1(Bounded to 0~0x7fff ).
2.  If the VAD flag of current frame is 1 (voiced frame), the DTX hangover count is set to 7, and this
    function ends.
3.  If the VAD flag of current frame is 0 (unvoiced frame), and the DTX hangover count is 0, the
    transmission mode of this frame is set to DTX frame mode, and the elapsed frame count since last DTX
    frame is set to 0, the SID flag is set to 1.
4.  If the VAD flag of current frame is 0 (unvoiced frame), but the DTX hangover count is not 0, then
    decrease DTX hangover count by 1, and if DTX_HangOver_Count + DTX_ElapsedCount   < 30 the SID
    flag is set to 0, and the transmission mode is set to MRDTX.

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointers is NULL.

EncDTXBuffer_GSMAMR, DecDTXBuffer_GSMAMR
Buffer the LSP (or LSF) coefficients and previous log
energy coefficients.

Syntax
QplStatus qplsEncDTXBuffer_GSMAMR_16s(const Qpl16s* pSrcSpch, const Qpl16s* pSrcLsp,
Qpl16s* pValResultUpdateIndex, Qpl16s* pSrcDstLspBuffer, Qpl16s*
pSrcDstLogEnergyBuffer  );
QplStatus qplsDecDTXBuffer_GSMAMR_16s(const Qpl16s* pSrcSpch, const Qpl16s* pSrcLsf,
Qpl16s* pValResultUpdateIndex, Qpl16s* pSrcDstLsfBuffer, Qpl16s*
pSrcDstLogEnergyBuffer  );

   606
---------------------Page 607---------------------

                                                                       Speech Coding Functions  9 

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcSpch                     Pointer to the input speech signal vector with 160 elements,
                             represented in Q15.0 format.
pSrcLsp                      Pointer to the LSP vector for this frame with ten elements,
                             represented in Q0.15 format.
pSrcLsf                      Pointer to the LSF coefficients vector of the current frame with ten
                             elements, represented in Q0.15 format.
pValResultUpdateIndex        Pointer to the previous memory update index. On output, points to
                             the current memory update index. It is circularly increased between
                             0 and 7.
pSrcDstLspBuffer             Pointer to the LSP coefficients vector of eight previous frames with
                             80 elements, represented in Q0.15 format. On output, points to the
                             LSP coefficients of eight most recent frames (including the current
                             frame) with 80 elements, represented in Q0.15 format.
pSrcDstLsfBuffer             Pointer to the LSF coefficients vector of eight previous frames with
                             80 elements, represented in Q0.15 format.
pSrcDstLogEnergyBuffer       Pointer to the logarithm energy coefficients vector of eight previous
                             frames with eight elements, represented in Q5.10 format. On
                             output, points to the log energy coefficients vector of eight most
                             recent frames (including the current frame) with eight elements,
                             represented in Q5.10 format.

Description
These functions buffer the LSP (or LSF) coefficients and previous log energy coefficients. These LSPs (or
LSFs) and energy coefficients will be used for SID frame to extract necessary parameters. The memory
update index indicates which part of the buffer will be updated, and it saves the cost for some memory copy.
The log energy is computed using the following formula:

where
N is the frame length
s is the input speech signal.

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointers is NULL.

Post Processing

                                                                                           607
---------------------Page 608---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

PostFilter_GSMAMR
Filters the synthesized speech.

Syntax
QplStatus qplsPostFilter_GSMAMR_16s(const Qpl16s* pSrcQLpc, const Qpl16s* pSrcSpch,
Qpl16s* pValResultPrevResidual, Qpl16s* pValResultPrevScalingGain, Qpl16s*
pSrcDstFormantFIRState, Qpl16s* pSrcDstFormantIIRState, Qpl16s* pDstFltSpch,
QplSpchBitRate mode  );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcQLpc                     Pointer to the reconstructed LP coefficients vector with 44 elements,
                             represented in Q3.12 format.
pSrcSpch                     Pointer to the start position of the input speech signal vector for the
                             current frame with 160 elements, represented in Q15.0 format.
pValResultPrevResidual       On entry, pointer to the last output of the FIR filter of the formant
                             filter for previous subframe, in Q15.0 format. It is the input of the
                             tilt compensation filter. On exit, points to the last output of the FIR
                             filter of the formant filter for this subframe (in Q15.0 format) and is
                             the output of the tilt compensation filter. This value is initialized to 0
                             and can only be updated by this function.
pValResultPrevScalingGain    Pointer to the scaling factor b of the last signal for the previous
                             subframe, in Q3.12 format. On output, points to the scaling factor b
                             of the last signal for this subframe, in Q3.12 format.
pSrcDstFormantFIRState       Pointer to the state of the FIR part of the formant filter, in the
                             length of ten elements, in Q15.0 format. On output, points to the
                             updated state of the FIR part of the formant filter, in the length of
                             ten elements, in Q15.0 format.
pSrcDstFormantIIRState       Pointer to the state of the IIR part of the formant filter, in the length
                             of 10 elements, in Q15.0 format. On output, points to the updated
                             state of the IIR part of the formant filter, in the length of 10
                             elements, in Q15.0 format.
pDstFltSpch                  Pointer to the filtered speech, in the length of 160 elements, in
                             Q15.0 format.
mode                         Bit rate specifier. Values between QPL_SPCHBR_4750  and
                             QPL_SPCHBR_12200   are valid.

Description
This function filters the synthesized speech to enhance reconstruction quality.

Return Values

qplStsNoErr                       Indicates no error.

QplStsNullPtrErr                  Indicates an error when one of the specified pointers is NULL.

   608
---------------------Page 609---------------------

                                                                        Speech Coding Functions  9  

qplStsRangeErr                     Indicates an error when the input variable mode  is out of range.

AMR Wideband Functions

The Intel QPL functions described in this section if properly combined can be used to construct the Adaptive
Multi-Rate Wideband (AMR WB) Speech Codec compliant to 3rd Generation Partnership Project (3GPP)
specification TS 26.173: “AMR Wideband Speech Codec; ANSI-C code". The description of AMR WB codec
may be found in 3GPP TS 26.190: “AMR Wideband Speech Codec; Transcoding functions". Also it is known as
ITU-T G.722.2 AMR WB codec.
The primitives are primarily designed to implement the well-defined, computationally expensive core
operations that comprise the codec portion of the AMR WB system. The AMR WB codec comprises an
adaptive multi-rate algorithm intended for encoding 7 kHz bandwidth speech signals at the sampling rate of
16 000 samples per second, which results in bit rates for the encoded bit stream of 6.60, 8.85, 12.65, 14.25,
15.85, 18.25, 19.85, 23.05 or 23.85 kbit/s.
The use of these functions is demonstrated in the Intel QPL GSM/AMR Wideband/G.722.2 Speech Encoder-
Decoder sample downloadable from http://www.intel.com/cd/software/products/asmo-na/eng/220046.htm.

LPC Analysis Functions

LPCToISP_AMRWB
Performs LP to ISP coefficients conversion.

Syntax
QplStatus qplsLPCToISP_AMRWB_16s( const Qpl16s* pSrcLpc, Qpl16s* pDstIsp, const Qpl16s*
pSrcPrevIsp );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h , qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcLpc                       Pointer to the input predictor coefficients.

pDstIsp                       Pointer to the output immittance spectral pairs.

pSrcPrevIsp                   Pointer to the input previous immittance spectral pairs.

Description
The function performs the following steps:
1. Calculates the polynomial coefficients of F1(z) and F2(z) , using the following recursive relations:
i = 0,1,...,7 ,
f1(i) = a i + am-i
f2(i) = a i - am-i
f1(8) = 2a 8
where f2(-2) = f2(-1) = 1.0.

                                                                                             609
---------------------Page 610---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

2. Uses Chebyshev polynomials to evaluate F1(z) and F2(z). The Chebyshev polynomials are given by:

F1(z) and F2(z) polynomials are evaluated at 100 points in equally spaced intervals between 0 and π and are
checked for sign changes. A sign change indicates the existence of a root in the corresponding interval. In
this case the interval is divided four times to track the root.
3. If the function cannot find all 16 roots needed to determine ISP coefficients, it returns the previous set of
ISP coefficients instead.

Return Values

qplStsNoErr                         Indicates no error.

qplStsNullPtrErr                    Indicates an error when one of the specified pointers is  NULL .

ISPToLPC_AMRWB
Performs ISP to LP coefficients conversion.

Syntax
QplStatus qplsISPToLPC_AMRWB_16s(const Qpl16s* pSrcIsp, Qpl16s* pDstLpc, int len              );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h , qplvm.h , qpls.h
Libraries: qplcore.lib, qplvm.lib , qpls.lib

Parameters

pSrcIsp                        Pointer to the input immittance spectral pairs.

pDstLpc                        Pointer to the output predictor coefficients.

len                            Number of ISP and LPC coefficients.

Description
The function performs the following steps:
1. Calculates the polynomial coefficients of F1(z) and F2(z) , using the recursive relations from i equal to 2
to len/2 by formulas
f1(i) = 2q2i-2 * f1(i-1) + 2f1(i-2)
for j=i-1 .. 2
f1(j) = f1(j) - 2q2i-2 * f1(j-1) + 2f1(j-2) end
f1(1) = f1(1) - 2q2i-2
with initial values f1(0) = 1 and f1(1) = -2q0.
The coefficients f2(i) are computed similarly by replacing q2i-2 by q2i-1 and len/2 by len/2-1, and with
initial conditions f2(0) = 1 and f2(1) = -2q1.
2. Once the coefficients f1(z) and f2(z) are found, F2(z) is multiplied by 1-z-2 to obtain F'2(z) , that is
f'2(i) = f2(i) - f2(i-2), for i = 2, ..., len /2 - 1;
f'1(i) = f1(i) , for i = 0, ..., len /2.

   610
---------------------Page 611---------------------

                                                                       Speech Coding Functions  9 

Then F'1(z) and F'2(z) are multiplied by 1+qlen -1 and 1- qlen -1, respectively.
3. Finally, the function computes the LP coefficients from f'1(i) and f'2(i) as:

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointers is NULL.

QplStsSizeErr                     Indicates an error when len  is less than or equal to zero, or
                                  when  len is greater than 20.

ISPToISF_Norm_AMRWB
Performs ISP to ISF coefficients conversion.

Syntax
QplStatus qplsISPToISF_Norm_AMRWB_16s(const Qpl16s* pSrcIsp, Qpl16s* pDstIsf, int len          );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcIsp                      Pointer to the ISP input vector of values scaled in range [-1:1].

pDstIsf                      Pointer to the ISF output vector of values scaled in range [0:0.5].

len                          Number of ISP and ISF coefficients.

Description
The function qplsISPToISF_Norm_AMRWB  converts the ISP coefficients to ISF coefficients as follows:

Here fs = 12800 is the sampling frequency. The scale factor is chosen such that the first ISF coefficient is
normalized to the interval [0:0.5] by multiplying to 1/π.

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointers is NULL.

qplStsSizeErr                     Indicates an error when len  is less than or equal to zero.

ISFToISP_AMRWB
Performs ISF conversion to ISP.

Syntax
QplStatus qplsISFToISP_AMRWB_16s(const Qpl16s* pSrcIsf, Qpl16s* pDstIsp, int len         );

                                                                                           611
---------------------Page 612---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcIsf                     Pointer to the ISF input vector of values scaled in range [0:0.5].

pDstIsp                     Pointer to the ISP output vector of values scaled in range [-1:1].

len                         Number of ISP and ISF.

Description
It converts ISF to the ISP coefficients using the following formula: pDdstIsp[i] = cos(pSrcIsf[i]), i =
0,..., len.

Return Values

qplStsNoErr                      Indicates no error.

qplStsNullPtrErr                 Indicates an error when one of the specified pointers is NULL.

qplStsSizeErr                    Indicates an error when len is less than or equal to zero.

Open-loop Pitch Analysis Functions

OpenLoopPitchSearch_AMRWB
Extracts an open-loop pitch lag estimate from the
weighted input speech.

Syntax
QplStatus qplsOpenLoopPitchSearch_AMRWB_16s(const Qpl16s* pSrcWgtSpch, const Qpl16s*
pSrcFltWgtSpch, Qpl16s* pPrevMidPitchLag, Qpl16s* pAdaptiveParam, Qpl16s*
pDstOpenLoopLag, Qpl16s* pToneFlag, Qpl16s* pDstOpenLoopGain, Qpl16s*
pSrcDstPrevPitchLag, Qpl16s* pSrcDstLagSwitcher, int len     );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcWgtSpch                 Pointer to a vector with 320 elements containing perceptually
                            weighted speech.
pSrcFltWgtSpch              Pointer to a vector with 320 elements containing perceptually
                            weighted speech, filtered through a high-pass filter perceptually.

   612
---------------------Page 613---------------------

                                                                     Speech Coding Functions  9 

pPrevMidPitchLag            Pointer to the median filtered pitch lag of the five previous voiced
                            speech half-frames.
pAdaptiveParam              Pointer to the adaptive parameter.

pDstOpenLoopLag             Pointer to a vector with two elements of open-loop pitch lags.

pToneFlag                   Pointer to the tone flag for the VAD module.

pDstOpenLoopGain            Pointer to a vector with two elements containing optimal open-loop
                            pitch gains.
pSrcDstPrevPitchLag         Pointer to the vector with five elements that contains the pitch lags
                            associated with the five most recent voiced speech half-frames.
pSrcDstLagSwitcher          Toggles the lag weighting feature.

len                         Length of the frame.

Description
The OLP search function qplsOpenLoopPitchSearch_AMRWB extracts a pitch estimate from a weighted
version of the input speech.

Return Values

qplStsNoErr                      Indicates no error.

qplStsNullPtrErr                 Indicates an error when one of the specified pointers is NULL.

qplStsSizeErr                    Indicates an error when len is less than or equal to zero.

Filtering Functions
This section describes functions that perform filtering operations specific to the AMRWB Speech Codec.

ResidualFilter
Computes the LPC residual

Syntax
QplStatus qplsResidualFilter_AMRWB_16s_Sfs (const Qpl16s* pSrcLpc, Qpl16s valLPCOrder,
const Qpl16s* pSrcSpeech, Qpl16s* pDstResidualSignal, Qpl32s len, Qpl32s scaleFactor       );
QplStatus qplsResidualFilter_Low_16s_Sfs (const Qpl16s* pSrcLpc, Qpl16s valLPCOrder,
const Qpl16s* pSrcSpeech, Qpl16s* pDstResidualSignal, Qpl32s len, Qpl32s scaleFactor       );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcLpc                     Pointer to the input LPC.

valLPCOrder                 Length of the LPC vector.

                                                                                         613
---------------------Page 614---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

pSrcSpeech                   Pointer to the input vector [-valLPCOrder , ..,-1,0, ..., len-1].

pDstResidualSignal           Pointer to the output vector of length [len].

len                          Length of the vectors.

scaleFactor                  Scale factor value.

Description
The functionality is the same as for the function ResidualFilter_G729. The only difference is that the functions
qplsResidualFilter_AMRWB    and qplsResidualFilter_AMRWB   scale the result according to the
scaleFactor  value.
The difference between the qplsResidualFilter_AMRWB  and qplsResidualFilter_Low   functions is that
qplsResidualFilter_AMRWB    makes intermediate Q15 reduction of the result with possible saturation.

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when any of the specified pointers is NULL.

qplStsSizeErr                     Indicates an error when  order  or len is less than or equal to
                                  zero, or when  order  is greater than len.
qplStsScaleRangeErr               Indicates an error when  scaleFactor  is negative or greater
                                  than 15.

HighPassFilterGetSize_AMRWB
Calculates the size of the high-pass filter state
memory.

Syntax
QplStatus qplsHighPassFilterGetSize_AMRWB_16s (int order, int* pDstSize         );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h , qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

order                        The order of high-pass filter. Valid values are 2 or 3.

pDstSize                     Pointer to the output value of the memory size.

Description
It calculates the size of memory needed for proper operation of the high-pass filter of the given order.

Return Values

qplStsNoErr                       Indicates no error.

qplStsRangeErr                    Indicates an error when  order  is not equal to either 2 or 3.

   614
---------------------Page 615---------------------

                                                                    Speech Coding Functions  9 

qplStsNullPtrErr                 Indicates an error when the pDstSize pointer is NULL.

HighPassFilterInit_AMRWB
Initializes the state memory of high-pass filter.

Syntax
QplStatus qplsHighPassFilterInit_AMRWB_16s(Qpl16s* pFilterCoeffA, Qpl16s*
pFilterCoeffB, int order, QplsHighPassFilterState_AMRWB_16s* pState     );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

order                       The order of high-pass filter. Valid values are 2 or 3.

pFilterCoeffA               Pointer to the vector of order size containing the IIR part of the
                            filter coefficients .
pFilterCoeffB               Pointer to the vector of order size containing the FIR part of the
                            filter coefficients.
pState                      Pointer to the memory supplied for filtering.

Description
It sets the coefficients and initializes the state memory of the high-pass filter.

Return Values

qplStsNoErr                      Indicates no error.

qplStsNullPtrErr                 Indicates an error when one of the specified pointers is NULL.

qplStsRangeErr                   Indicates an error when order is not equal to either 2 or 3.

HighPassFilter_AMRWB
Performs high-pass filtering.

Syntax
QplStatus qplsHighPassFilter_AMRWB_16s_Sfs (const Qpl16s* pSrc, Qpl16s* pDst, int len,
QplsHighPassFilterState_AMRWB_16s* pState, int scaleFactor    );
QplStatus qplsHighPassFilter_AMRWB_16s_ISfs (Qpl16s* pSrcDst, int len,
QplsHighPassFilterState_AMRWB_16s* pState, int scaleFactor    );
QplStatus qplsHighPassFilter_Direct_AMRWB_16s (const Qpl16s* pSrcCoeff, const Qpl16s*
pSrc, Qpl16s* pDst, int len, int borderMode   );

Include Files
qplsc.h

                                                                                        615
---------------------Page 616---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

Domain Dependencies
Headers: qplcore.h , qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrc                         Pointer to the vector containing input signal.

pDst                         Pointer to the vector containing filtered signal.

pSrcDst                      Pointer to the input/output vector.

pState                       Pointer to the memory supplied for filtering.

scaleFactor                  Scale factor of the input signal.

pSrcCoeff                    Pointer to the vector with two elements containing the coefficients
                             of the filter.
len                          Length of the input and output vectors.

borderMode                   if borderMode  = 0 then pSrc [-1] and pSrc[len] are equal to zero;
                             otherwise you must set these values.

Description

qplsHighPassFilter_AMRWB_16s   . This function performs the high-pass filtering of the input signal by the
following transfer function:

Currently, only a0 = 1.0 is supported. The scale factor is used to update the filter memory according to the
input signal.
qplsHighPassFilter_Direct_AMRWB_16s    . This function performs the high-pass filtering of the input signal
by the following transfer function:

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointers is NULL.

qplStsSizeErr                     Indicates an error when  len  is less than or equal to zero.

HighPassFilterGetDlyLine_AMRWB
Receives the parameters of delay line of high-pass
filter.

Syntax
QplStatus qplsHighPassFilterGetDlyLine_AMRWB_16s(const
QplsHighPassFilterState_AMRWB_16s* pState, Qpl16s* pDlyLine, Qpl32s order         );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h , qplvm.h, qpls.h

   616
---------------------Page 617---------------------

                                                                         Speech Coding Functions  9  

Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pState                        Pointer to the memory supplied for filtering.

pDlyLine                      Pointer to the vector with six elements for order 2, or with nine
                              elements for order 3 containing the filter memory.
order                         The order of high-pass filter; valid values are 2 or 3.

Description
This function gets the parameters of the delay line of the high-pass filter structure. The layout of the
returned filter memory is follows:
Yh2,Yl2, Yh1, Yl1, X0, X1 - for the high-pass filter of order 2.
Yh3,Yl3, Yh2,Yl2, Yh1, Yl1, X0, X1, X2 - the high-pass filter of order 3 ,
where Xi - the memory of the FIR filter part, and Yhi, Yli - the memories of the IIR filter part.

Return Values

qplStsNoErr                        Indicates no error.

qplStsNullPtrErr                   Indicates an error when one of the specified pointer is NULL.

qplStsSizeErr                      Indicates an error when  order  is not equal 2 or 3.

HighPassFilterSetDlyLine_AMRWB
Sets the parameters of delay line of high-pass filter.

Syntax
QplStatus qplsHighPassFilterSetDlyLine_AMRWB_16s(const Qpl16s* pDlyLine,
QplsHighPassFilterState_AMRWB_16s* pState, Qpl32s order        );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h , qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pDlyLine                      Pointer to the vector with six elements for order 2, or with nine
                              elements for order 3 containing the filter memory.
pState                        Pointer to the memory supplied for filtering.

order                         The order of high-pass filter; valid values are 2 or 3.

Description
This function updates pState structure by pDlyLine vector with the parameters of the delay line of the
high-pass filtering. The layout of the pDlyLine vector is the same as in the description of the function 
SNR_AMRWBE.

                                                                                              617
---------------------Page 618---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointer is NULL.

qplStsSizeErr                     Indicates an error when order is not equal 2 or 3.

Preemphasize_AMRWB
Computes pre-emphasis of a speech signal.

Syntax
QplStatus qplsPreemphasize_AMRWB_16s_ISfs (Qpl16s gamma, Qpl16s* pSrcDst, int len, int
scaleFactor, Qpl16s* pMem  );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

gamma                        Filter coefficient.

pSrcDst                      Pointer to the input/output vector.

scaleFactor                  Scale factor for the result.

len                          Length of the input/output vector.

pMem                         Pointer to the filter memory vector with one element.

Description
It computes pre-emphasis of the input speech using the following equation:
H(z) = 1 - γ*z -1

The memory value pMem[0] is updated by pSrcDst[n-1]. For proper use of this function in AMR WB codec,
the memory value must be initialized to zero in the user program.

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when the pSrcDst or pMem pointer is NULL.

qplStsSizeErr                     Indicates an error when len is less than or equal to zero.

qplStsScaleRangeErr               Indicates an error when scaleFactor  < 0 or scaleFactor > 15.

Deemphasize_AMRWB
Performs de-emphasis filtering.

Syntax
QplStatus qplsDeemphasize_AMRWB_NR_16s_I(Qpl16s gamma, Qpl16s* pSrcDst, int len,
Qpl16s* pMem );

   618
---------------------Page 619---------------------

                                                                     Speech Coding Functions  9 

QplStatus qplsDeemphasize_AMRWB_32s16s(Qpl16s gamma, const Qpl32s* pSrc, Qpl16s* pDst,
int len, Qpl16s* pMem  );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

gamma                        De-emphasis factor.

pSrc                         Pointer to the input vector.

pDst                         Pointer to the output vector.

pSrcDst                      Pointer to the input/output vector.

len                          Length of the input/output vector.

pMem                         Pointer to the filter memory element.

Description
It performs de-emphasis of the input synthesized signal by filtering it with the following transfer function:
H(z) = 1/(1 - γ*z -1)
The initial memory of the filter must be set to zero. The memory value pMem[0] is updated by pDst[len -1]
or pSrcDst[len -1].

Return Values

qplStsNoErr                      Indicates no error.

qplStsNullPtrErr                 Indicates an error when one of the specified pointers is NULL.

qplStsSizeErr                    Indicates an error when len  is less than or equal to zero.

SynthesisFilter_AMRWB
Reconstructs the speech signal from LP coefficients
and residuals.

Syntax
QplStatus qplsSynthesisFilter_AMRWB_16s32s_I(const Qpl16s* pSrcLpc, int order, const
Qpl16s* pSrcExc, Qpl32s* pSrcDstSignal, int len    );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

                                                                                          619
---------------------Page 620---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

Parameters

pSrcLpc                      Pointer to the LP coefficients vector a0, a1 ,...,aorder
order                        Order of LP filter.

pSrcExc                      Pointer to the excitation vector.

pSrcDstSignal                Pointer to the synthesized and updated speech.

len                          Length of the filter.

Description
It computes the filter using the following formula:

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointers is NULL.

QplStsSizeErr                     Indicates an error when  len or order is less than or equal to
                                  zero.

Discontinuous Transmission (DTX) Functions
This section describes primitives that deal with discontinuous transmission (DTX) for AMR WB codec.

VADGetSize_AMRWB
Calculates the size of the VAD module state memory.

Syntax
QplStatus qplsVADGetSize_AMRWB_16s (int* pDstSize      );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h , qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pDstSize                     Pointer to the output value of the memory size.

Description
It calculates the size of memory needed for proper operation of the VAD module in the AMR WB codec.

Return Values

QplStsNoErr                       Indicates no error.

QplStsNullPtrErr                  Indicates an error when the  pDstSize  pointer is NULL.

   620
---------------------Page 621---------------------

                                                                     Speech Coding Functions  9 

VADInit_AMRWB
Initializes the VAD module state memory.

Syntax
QplStatus qplsVADInit_AMRWB_16s(QplsVADState_AMRWB_16s* pState     );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pState                      Pointer to the VAD memory.

Description
It initializes the state of VAD (Voice Activity Decision) module of the AMR WB codec. The structure
QplsVADState_AMRWB_16s  contains the VAD history that must be initialized prior to the use of the function
qplsVAD_AMRWB .

Return Values

qplStsNoErr                      Indicates no error.

QplStsNullPtrErr                 Indicates an error when the pState pointer is NULL.

VAD_AMRWB
Performs VAD in AMR WB encoder.

Syntax
QplStatus qplsVAD_AMRWB_16s(const Qpl16s* pSrcSpch, QplsVADState_AMRWB_16s*
pSrcDstVadState, Qpl16s* pToneFlag, Qpl16s* pVadFlag    );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcSpch                    Pointer to the input speech signal, of length 320.

pSrcDstVadState             Pointer to the VAD memory.

pToneFlag                   Pointer to the output tone flag.

pVadFlag                    Pointer to the VAD flag of this frame.

                                                                                         621
---------------------Page 622---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

Description
The function qplsVAD_AMRWB implements the VAD functionality of the AMR WB encoder. This function is used
to indicate whether the input speech frame contains active speech or some other audio signal such as silence
or music. The structure QplsVADState_AMRWB_16s contains the VAD history and is updated in the function.
This structure must be initialized in advance by using the function VADInit_AMRWB.

Return Values

qplStsNoErr                        Indicates no error.

qplStsNullPtrErr                   Indicates an error when one of the specified pointers is NULL.

VADGetEnergyLevel_AMRWB
Gets the vector of energy levels from VAD memory.

Syntax
QplStatus qplsVADGetEnergyLevel_AMRWB_16s(const QplsVADState_AMRWB_16s* pState, Qpl16s*
pEnergyLevel );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h , qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pState                        Pointer to the VAD memory.

pEnergyLevel                  Pointer to the energy level vector [12].

Description
The function qplsVAD_AMRWB produces signal energy in the 12 non-uniform bands over the frequency range
from 0 to 6.4 kHz for 256-sample frame. And the function qplsVADGetEnergyLevel_AMRWB returns
normalized energy levels which are produced by dividing the energy level form each band by the width of
this band in Hz. The lower index refers to the lower sub band.

Return Values

qplStsNoErr                        Indicates no error.

qplStsNullPtrErr                   Indicates an error when one of the specified pointer is NULL.

Codebook Search Functions
These functions perform algebraic and adaptive codebook search and decoding operations which are specific
for the AMR WB codec.

AlgebraicCodebookSearch_AMRWB
Performs the fixed (algebraic) codebook search.

   622
---------------------Page 623---------------------

                                                                         Speech Coding Functions  9 

Syntax
QplStatus qplsAlgebraicCodebookSearch_AMRWB_16s(const Qpl16s* pSrcFixedTarget, const
Qpl16s* pSrcLtpResidual, Qpl16s* pSrcDstImpulseResponse, Qpl16s* pDstFixedVector,
Qpl16s* pDstFltFixedVector, QplSpchBitRate mode, Qpl16s* pDstIndex         );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h , qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcFixedTarget               Pointer to the target vector.

pSrcLtpResidual               Pointer to the long term prediction residual.

pSrcDstImpulseResponse        Pointer to the impulse response of the weighted synthesis filter;
                              pSrcDstImpulseResponse   [-L_subfr ..-1] must be set to zero.
pDstFixedVector               Pointer to the innovative codebook.

pDstFltFixedVector            Pointer to the filtered fixed codebook excitation.

mode                          Coder mode.

pDstIndex                     Pointer to the indexes of the pulses.

Description
It performs the following steps:
1. Computes backward filtered target vector d by

where x2(n) is the fixed target signal used for fixed codebook search.
2. Computes the signal b(n), which is used for presetting the pulse amplitudes, as:

The scaling factor a controls the amount of dependence of the reference signal on d(n), it is lowered as the
bit rate is increased: a=2 for 6.6 and 8.85 bit rates; a=1 for 12.65, 14.25 and 15.85 bit rates; a=0.8 for
18.25 bit rate; a=75 for 19.25 bit rate; and a=0.5 for 23.05 and 23.85 bit rates.
3. Calculates the symmetric Toepliz matrix Φ for each mode. The element of this matrix is computed by 

4. Searches signed pulses in appropriate positions and encodes them. The pulse positions for different modes
are in the tables below:
Modes 23.05 and 23.85:
 Track      Pulse                                   Positions
 1         i0, i4, i8, i12, i16, i20               0, 4, 8, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56,
                                                   60
 2         i1, i5, i9, i13, i17, i21               1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53,
                                                   57, 61

                                                                                              623
---------------------Page 624---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

 Track      Pulse                                       Positions

 3          i2, i6, i10, i14, i18, i22                 2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50,
                                                       54, 58, 62
 4          i3, i7, i11, i15, i19, i23                 3, 7, 11, 15, 19, 23, 27, 31, 35, 39, 43, 47, 51,
                                                       55, 59, 63

Modes 19.85:
 Track       Pulse                                      Positions

 1          i0, i4, i8, i12, i16,
                                                        0, 4, 8, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56,
                                                        60
 2          i1, i5, i9, i13, i17,
                                                        1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53,
                                                        57, 61
 3          i2, i6, i10, i14,
                                                        2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50,
                                                        54, 58, 62
 4          i3, i7, i11, i15,
                                                        3, 7, 11, 15, 19, 23, 27, 31, 35, 39, 43, 47, 51,
                                                        55, 59, 63

Modes 18.25:
 Track      Pulse                                       Positions

 1          i0, i4, i8, i12,
                                                        0, 4, 8, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56,
                                                        60
 2          i1, i5, i9, i13,
                                                        1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53,
                                                        57, 61
 3          i2, i6, i10, i14,
                                                        2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50,
                                                        54, 58, 62
 4          i3, i7, i11, i15,
                                                        3, 7, 11, 15, 19, 23, 27, 31, 35, 39, 43, 47, 51,
                                                        55, 59, 63

Modes 15.85:
 Track      Pulse                                        Positions

 1          i0, i4, i8,
                                                        0, 4, 8, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52,
                                                        56, 60
 2          i1, i5, i9,
                                                        1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49,
                                                        53, 57, 61
 3          i2, i6, i10,
                                                        2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50,
                                                        54, 58, 62
 4          i3, i7, i11,
                                                        3, 7, 11, 15, 19, 23, 27, 31, 35, 39, 43, 47, 51,
                                                        55, 59, 63

Modes 14.25:
 Track      Pulse                                        Positions

 1         i0, i4, i8,
                                                        0, 4, 8, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56,
                                                        60
 2         i1, i5, i9,
                                                        1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53,
                                                        57, 61

   624
---------------------Page 625---------------------

                                                                          Speech Coding Functions  9   

 Track     Pulse                                      Positions
 3         i2, i6,
                                                      2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50,
                                                      54, 58, 62
 4         i3, i7,
                                                      3, 7, 11, 15, 19, 23, 27, 31, 35, 39, 43, 47, 51,
                                                      55, 59, 63

Modes 12.65:
 Track     Pulse                                      Positions
 1        i0, i4,
                                                      0, 4, 8, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56,
                                                      60
 2        i1, i5,
                                                      1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53,
                                                      57, 61
 3        i2, i6,
                                                      2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50,
                                                      54, 58, 62
 4        i3, i7,
                                                      3, 7, 11, 15, 19, 23, 27, 31, 35, 39, 43, 47, 51,
                                                      55, 59, 63

Modes 8.85:
 Track     Pulse                                      Positions
 1        i0,
                                                      0, 4, 8, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52,
                                                      56, 60
 2        i1,
                                                      1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49,
                                                      53, 57, 61
 3        i2,
                                                      2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50,
                                                      54, 58, 62
 4        i3,
                                                      3, 7, 11, 15, 19, 23, 27, 31, 35, 39, 43, 47, 51,
                                                      55, 59, 63

Modes 6.60:
 Track    Pulse                                        Positions
 1        i0,
                                                      0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26,
                                                      28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50,
                                                      52, 54, 56, 58, 60, 62
 2        i1,
                                                      1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27,
                                                      29, 31, 33, 35,37, 39, 41, 43, 45, 47, 49, 51, 53,
                                                      55, 57, 59, 61, 63

Return Values

qplStsNoErr                         Indicates no error.

qplStsNullPtrErr                    Indicates an error when one of the specified pointers is  NULL .

qplStsRangeErr                      Indicates an error when  mode  is not a valid element of the
                                    enumerated type   QplSpchBitRate   .

AlgebraicCodebookDecode_AMRWB
Decodes the fixed (algebraic) codebook indexes.

                                                                                                625
---------------------Page 626---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

Syntax
QplStatus qplsAlgebraicCodebookDecode_AMRWB_16s (const Qpl16s* pSrcIdxs, Qpl16s*
pDstFixedCode, QplSpchBitRate mode  );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcIdxs                    Algebraic codebook indexes.

pDstFixedCode               Pointer to the algebraic code vector with 64 elements.

mode                        Coder mode.

Description
The function decodes the fixed codebook vector from the received fixed codebook index.

Return Values

qplStsNoErr                      Indicates no error.

qplStsNullPtrErr                 Indicates an error when one of the specified pointers is NULL.

qplStsRangeErr                   Indicates an error when mode is not an element of the
                                 enumerated type  QplSpchBitRate  appropriate to AMR WB.

AdaptiveCodebookGainCoeff_AMRWB
Computes the adaptive codebook gain.

Syntax
QplStatus qplsAdaptiveCodebookGainCoeff_AMRWB_16s(const Qpl16s* pSrcAdptTarget, const
Qpl16s* pSrcFltAdptVector, Qpl16s* pAdptGainCoeffs, Qpl16s* pResultAdptGain, int len      );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcAdptTarget              Pointer to the adaptive-codebook vector.

pSrcFltAdptVector           Pointer to the input vector, which is the filtered adaptive-codebook
                            vector.
pResultAdptGain             Pointer to the adaptive-codebook gain in the length of 1.

   626
---------------------Page 627---------------------

                                                                     Speech Coding Functions  9 

pAdptGainCoeffs              Pointer to the output vector with four elements; represents the
                             adaptive-codebook gain as a fraction.
len                          Length of vectors.

Description
The adaptive codebook gain is calculated using the following formula:

bounded by 0 ≤ gp ≤ 1.2.
Additionally, the function returns the gain in a different representation given by the following formula:

The mantissas Cxy , Cyy and exponents expxy , expyy for both the normalized denominator and normalized
numerator are returned in the pAdptGainCoeffs vector:
pAdptGainCoeffs [0] = Cyy
pAdptGainCoeffs [1] = expyy
pAdptGainCoeffs [2] = Cxy
pAdptGainCoeffs [3] = expxy

Return Values

qplStsNoErr                      Indicates no error.

qplStsNullPtrErr                 Indicates an error when one of the specified pointers is NULL.

qplStsSizeErr                    Indicates an error when len  is less than or equal to zero.

AdaptiveCodebookSearch_AMRWB
Performs the adaptive codebook search.

Syntax
QplStatus qplsAdaptiveCodebookSearch_AMRWB_16s(const Qpl16s* pSrcAdptTarget, const
Qpl16s* pSrcImpulseResponse, const Qpl16s* pSrcOpenLoopLag, Qpl16s* pPitchLag, Qpl16s*
pPitchLagBounds, Qpl16s* pSrcDstExcitation, Qpl16s* pFracPitchLag, Qpl16s* pAdptIndex,
int subFrame, QplSpchBitRate mode   );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcAdptTarget               Pointer to the adaptive target signal vector with 64 elements.

pSrcImpulseResponse          Pointer to the impulse response of the weighted synthesis filter
                             vector with 64 elements.
pSrcOpenLoopLag              Pointer to a vector with two elements of the OLP lags.

                                                                                          627
---------------------Page 628---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

pPitchLag                    Pointer to the output previous integral pitch lag.

pPitchLagBounds              Pointer to the bounds of the output previous integral pitch lag.

pSrcDstExcitation            Pointer to the input/output excitation vector with 321 elements.

pFracPitchLag                Pointer to the output fractional pitch lag obtained during the
                             adaptive codebook search.
pAdptIndex                   Pointer to the coded closed-loop pitch index.

subFrame                     Subframe number.

mode                         Coder mode.

Description
The function performs the adaptive codebook search. The adaptive codebook search consists of a closed-loop
pitch search followed by computation of an adaptive excitation vector. The adaptive excitation vector is
computed by interpolating the past excitation at the fractional pitch lag obtained during the closed-loop pitch
search. The adaptive codebook is searched on every subframe.

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointers is NULL.

qplStsRangeErr                    Indicates an error when  mode  is not a valid element of the
                                  enumerated type QplSpchBitRate.
qplStsSizeErr                     Indicates an error when  subFrame  is less than 0 or greater than
                                  3.

AdaptiveCodebookDecodeGetSize_AMRWB
Queries the memory length of the adaptive codebook
decode module.

Syntax
QplStatus qplsAdaptiveCodebookDecodeGetSize_AMRWB_16s(int* pDstSize        );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h , qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pDstSize                     Pointer to the output parameter to store the length in bytes, of the
                             decode module of the adaptive codebook.

Description
The function reports the size of memory needed for proper operation of the adaptive codebook decode
module.

   628
---------------------Page 629---------------------

                                                                   Speech Coding Functions  9 

Return Values

qplStsNoErr                     Indicates no error.

qplStsNullPtrErr                Indicates an error when the pDstSize pointer is NULL.

AdaptiveCodebookDecodeInit_AMRWB
Initializes the adaptive codebook decode module
memory.

Syntax
QplStatus
qplsAdaptiveCodebookDecodeInit_AMRWB_16s( QplsAdaptiveCodebookDecodeState_AMRWB_16s*
pState);

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pState                      Pointer to the memory of the adaptive codebook decode module.

Description
The function initializes the adaptive codebook decode module memory.

Return Values

qplStsNoErr                     Indicates no error.

qplStsNullPtrErr                Indicates an error when the pState pointer is NULL.

AdaptiveCodebookDecodeUpdate_AMRWB
Updates the memory of the adaptive codebook decode
module.

Syntax
QplStatus qplsAdaptiveCodebookDecodeUpdate_AMRWB_16s(int valIntPitchGain, int
valPitchLag, QplsAdaptiveCodebookDecodeState_AMRWB_16s* pState   );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

                                                                                       629
---------------------Page 630---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

Parameters

valPitchGain                Pitch gain.

valIntPitchLag              Pointer to the integral pitch lag.

pState                      Pointer to the memory of the adaptive codebook decode module.

Description
The function updates the memory of the adaptive codebook decode module with the given pitch lag and pitch
gain.

Return Values

qplStsNoErr                      Indicates no error.

qplStsNullPtrErr                 Indicates an error when the pState pointer is NULL.

AdaptiveCodebookDecode_AMRWB
Decodes the adaptive codebook.

Syntax
QplStatus qplsAdaptiveCodebookDecode_AMRWB_16s(int valAdptIndex, Qpl16s*
pResultFracPitchLag, Qpl16s* pSrcDstExcitation, Qpl16s* pPitchLag, Qpl16s*
pPitchLagBounds, int subFrame, int bfi, int unusableFrame, QplSpchBitRate mode,
QplsAdaptiveCodebookDecodeState_AMRWB_16s* pState    );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

valAdptIndex                Adaptive codebook index.

pResultFracPitchLag         Pointer to the fractional pitch lag obtained during the adaptive
                            codebook search.
pSrcDstExcitation           Pointer to the excitation vector with 321 elements.

pPitchLag                   Pointer to the integral pitch lag.

pPitchLagBounds             Pointer to the previous integral pitch lag bounds.

subFrame                    Subframe number.

bfi                         Bad frame indicator. Value "0" signifies a good frame; any other
                            value signifies a bad frame.
unusableFrame               Indicator of an unsuable frame. Value "0" signifies a lost frame with
                            content that cannot be used; any other value indicates a valid
                            frame.
mode                        Encoding mode.

pState                      Pointer to the memory of the adaptive codebook decode module.

   630
---------------------Page 631---------------------

                                                                       Speech Coding Functions  9 

Description
It performs the following steps:
1. If no errors are detected on the current frame, the function extracts integer and fractional pitch lags from
the adaptive codebook indices.
2. If errors are detected, the function recovers the integer pitch either from the previous integer pitch or
from the LTP-lag. See clause 6.2.3.4 in 3GPP TS 26.191 V5.1.0.
3. To obtain the adaptive codebook vector, the function qplsAdaptiveCodebookDecode_AMRWB applies the
same adaptive codebook computation procedure as described in the function 
AdaptiveCodebookSearch_AMRWB.

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointers is NULL.

qplStsRangeErr                    Indicates an error when  mode is not a valid element of the
                                  enumerated type QplSpchBitRate.
qplStsSizeErr                     Indicates an error when  subFrame is less than 0 or greater than
                                  3.

Quantization Functions
This section describes functions that perform quantization specific to the AMR WB speech codec.

ISFQuant_AMRWB
Quantizes the ISF.

Syntax
QplStatus qplsISFQuant_AMRWB_16s(const Qpl16s* pSrcIsf, Qpl16s* pSrcDstResidual,
Qpl16s* pDstQIsf, Qpl16s* pDstQIsfIndex, QplSpchBitRate mode       );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcIsf                      Pointer to the unquantized ISF vector with 16 elements.

pSrcDstResidual              Pointer to the quantized ISF residual vector with 16 elements from
                             the previous frame.
pDstQIsf                     Pointer to the quantized ISF vector with 16 elements.

pDstQIsfIndex                Pointer to the vector of quantized ISF indices with seven elements.
                             For 6.60 Kbps frames, only the first five elements contain valid
                             indices; for all other bit rates, all seven elements contain valid
                             indices.
mode                         Coder mode.

                                                                                            631
---------------------Page 632---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

Description
It applies a first order moving-average (MA) prediction and quantifies the residual ISF vector using a
combination of split vector quantization (SVQ) and multistage vector quantization (MSVQ).
The prediction and quantization are performed as follows. Let z(n) denotes the mean-removed ISF vector at
frame n.
The prediction residual vector r(n) is given by:
r(n) = z(n)  - p(n)
where
p(n) is the predicted LSF vector at frame n.
First order moving-average (MA) prediction is used
where:
p(n) = 1/3*ř(n-1)   ,
where
ř(n-1) is the quantized residual vector of the previous frame.
The ISF residual vector r is quantized using split-multistage vector quantization S-MSVQ. The vector is split
into two subvectors r1(n) and r2(n) of dimensions 9 and 7, respectively. The two subvectors are quantized
in two stages. In the first stage r1(n) is quantized with 8 bits and r2(n) with 8 bits.
For 8.85 ,12.65, 14.25, 15.85, 18.25, 19.85, 23.05 or 23.85 kbit/s modes, the quantization error vectors are
split in the next stage into 3 and 2 subvectors, respectively.
For 6.60 kbit/s mode, the quantization error vectors
r (2)
 i   = r - ři, i = 1, 2.
are split in the next stage into 2 and 1 subvectors, respectively. A squared error ISF distortion measure is
used in the quantization process. In general, for an input ISF or error residual subvector ri , i =1,2 a
quantized vector at index k, řk
                           i , the quantization is performed by finding the index k which minimizes

where
m and n are the first and last elements of the subvector.

Return Values

qplStsNoErr                         Indicates no error.

qplStsNullPtrErr                    Indicates an error when one of the specified pointers is  NULL .

qplStsRangeErr                      Indicates an error when  mode  is not a valid element of the
                                    enumerated type   QplSpchBitRate   .

ISFQuantDecode_AMRWB
Decodes quantized ISFs from the received codebook
index.

Syntax
QplStatus qplsISFQuantDecode_AMRWB_16s(const Qpl16s* pSrcIdxs, Qpl16s* pDstQntIsf,
Qpl16s* pSrcDstResidual, const Qpl16s* pSrcPrevQntIsf, Qpl16s* pSrcDstIsfMemory, int
bfi, QplSpchBitRate mode    );

   632
---------------------Page 633---------------------

                                                                     Speech Coding Functions  9 

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcIdxs                     Pointer to the vector with seven elements containing codebook
                             indices of the quantized LSPs.
pSrcDstResidual              Pointer to the quantized ISF residual vector with 16 elements from
                             the previous frame.
pSrcPrevQntIsf               Pointer to the quantized ISF vector with 16 elements from the
                             previous frame.
pSrcDstIsfMemory             Pointer to the vector with 64 elements containing four subframe ISF
                             sets.
pDstQntIsf                   Pointer to a destination vector with 16 elements containing
                             quantized ISF in frequency domain (0..0.5).
bfi                          Bad frame indicator: "0" indicates a valid frame, all other values
                             indicate an invalid frame.
mode                         Coder mode.

Description
If the errors are not detected on the received frame, the function decodes quantized ISFs from the received
codebook index. Otherwise, the function recovers the quantized ISFs from previous quantized ISFs using
linear interpolation.

Return Values

qplStsNoErr                      Indicates no error.

qplStsNullPtrErr                 Indicates an error when one of the specified pointers is NULL.

qplStsRangeErr                   Indicates an error when mode  is not a valid element of the
                                 enumerated type   QplSpchBitRate .

ISFQuantDTX_AMRWB
Quantizes the ISF coefficient vector in case of DTX
mode.

Syntax
QplStatus qplsISFQuantDTX_AMRWB_16s(const Qpl16s* pSrcIsf, Qpl16s* pDstQntIsf, Qpl16s*
pDstIdxs);

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

                                                                                          633
---------------------Page 634---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

Parameters

pSrcIsf                      Pointer to the unquantized ISF vector with 16 elements in the
                             frequency domain (0..0.5) .
pDstQntIsf                   Pointer to the quantized ISF vector with 16 elements.

pDstIdxs                     Pointer to the vector with five elements of quantization indices.

Description
The function quantizes the averaged ISF coefficient vector using the comfort noise ISF quantization tables.

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointers is NULL.

ISFQuantDecodeDTX_AMRWB
Decodes quantized ISFs for DTX.

Syntax
QplStatus qplsISFQuantDecodeDTX_AMRWB_16s(const Qpl16s* pSrcIdxs, Qpl16s* pDstQntIsf         );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcIdxs                     Pointer to the vector with five elements of quantization indices.

pDstQntIsf                   Pointer to the ISF vector with 16 elements in the frequency domain
                             (0..0.5) .

Description
The function decodes quantized ISFs from the received codebook index for DTX.

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointers is NULL.

GainQuant_AMRWB
Quantizes the adaptive codebook gains.

   634
---------------------Page 635---------------------

                                                                    Speech Coding Functions  9 

Syntax
QplStatus qplsGainQuant_AMRWB_16s(const Qpl16s* pSrcAdptTarget, const Qpl16s*
pSrcFltAdptVector, int valFormat, const Qpl16s* pSrcFixedVector, const Qpl16s*
pSrcFltFixedVector, const Qpl16s* pSrcCorr, Qpl16s* pSrcDstEnergyErr, Qpl16s*
pSrcDstPitchGain, int* pDstCodeGain, int valClipFlag, Qpl16s* pDstQGainIndex, int
lenSrc, QplSpchBitRate mode  );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcAdptTarget              Pointer to the input target vector x(n).

pSrcFltAdptVector           Pointer to the input filtered adaptive codebook vector y(n).

valFormat                   Format of the pSrcAdptTarget  and pSrcFltAdptVector  vectors.

pSrcFixedVector             Pointer to the input pre-filtered codebook contribution c(n).

pSrcFltFixedVector          Pointer to the input filtered codebook vector z(n).

pSrcCorr                    Pointer to the vector of correlations between the pSrcAdptTarget,
                            pSrcFltAdptVector  , pSrcFltFixedVector vectors.
pSrcDstEnergyErr            Pointer to the input/output energy error vector for the four most
                            recent subframes.
pSrcDstPitchGain            Pointer to the input/output pitch gain.

pDstCodeGain                Pointer to the output code gain.

valClipFlag                 If valClipFlag = 1 , then limit gain pitch to 1.0.

pDstQGainIndex              Pointer to the output codebook indeces found.

lenSrc                      Length of the input vectors.

mode                        Encoding mode.

Description
The adaptive codebook gain (pitch gain) and the fixed (algebraic) codebook gain are vector quantized using a
6-bit codebook for modes 8.85 and 6.60 kbit/s and using a 7-bit codebook for all the other modes.

Return Values

qplStsNoErr                      Indicates no error.

qplStsNullPtrErr                 Indicates an error when one of the specified pointers is NULL.

qplStsSizeErr                    Indicates an error when lenSrc is less than or equal to zero.

qplStsRangeErr                   Indicates an error when mode is not a valid element of the
                                 enumerated type  QplSpchBitRate .

                                                                                        635
---------------------Page 636---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

DecodeGain_AMRWB
Decodes adaptive and fixed-codebook gains.

Syntax
QplStatus qplsDecodeGain_AMRWB_16s(int valQIndex, Qpl32s valEnergy, Qpl16s*
pDstPitchGain, int* pDstCodeGain, int bfi, int prevBfi, Qpl16s* pSrcDstPastEnergy,
Qpl16s* pPrevCodeGain, Qpl16s* pSrcDstPastCodeGain, QplSpchBitRate mode       );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

valQIndex                    Index of quantization.

valEnergy                    Pointer to the input filtered adaptive codebook vector y(n).

pDstPitchGain                Pointer to the decoded pitch gain.

pDstCodeGain                 Pointer to the decoded code gain.

bfi                          Bad frame indicator.

prevBfi                      Bad frame indicator of the previous frame.

pSrcDstPastEnergy            Past quantized energies.

pPrevCodeGain                Past code gain.

pSrcDstPastCodeGain          Past code gain for frame erasures.

mode                         Decoding mode.

Description

If there are no errors detected in the frame, the function computes predicted and fixed codebook gains.
In case of frame erasure, the gains are the attenuated versions of the previous gains.

Return Values

qplStsNoErr                      Indicates no error.

qplStsNullPtrErr                 Indicates an error when one of the specified pointers is NULL.

qplStsRangeErr                   Indicates an error when mode  is not a valid element of the
                                 enumerated type   QplSpchBitRate .

EncDTXBuffer_AMRWB
Buffers the ISP coefficients and previous logarithm
energy coefficients.

   636
---------------------Page 637---------------------

                                                                      Speech Coding Functions  9 

Syntax
QplStatus qplsEncDTXBuffer_AMRWB_16s(const Qpl16s* pSrcSpch, const Qpl16s* pSrcIsp,
Qpl16s* pUpdateIndex, Qpl16s* pSrcDstIspBuffer, Qpl16s* pSrcDstLogEnergyBuffer,
QplSpchBitRate mode  );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcSpch                     Pointer to the input speech signal vector with 256 elements.

pSrcIsp                      Pointer to the ISP vector with 16 elements for this frame.

pUpdateIndex                 Holds the previous memory update index. On output, it contains the
                             current memory update index. It is circularly increased between 0
                             and 7.
pSrcDstIspBuffer             Pointer to the ISP coefficients vector with 128 elements of the eight
                             most recent frames. On output, points to the ISP coefficients of
                             eight most recent frames (including the current frame).
pSrcDstLogEnergyBuffer       Pointer to the logarithm energy coefficients vector with eight
                             elements of the eight most recent frames. On output, points to the
                             logarithm energy coefficients of eight most recent frames (including
                             the current frame).
mode                         Bit rate specifier. Values between QPL_SPCHBR_6600 and
                             QPL_SPCHBR_23850   are valid.

Description
This function buffers the ISP coefficients and previous logarithm energy coefficients. The buffered ISP
coefficients and energy coefficients are used for SID frame to extract necessary parameters. The memory
update index indicates which part of the buffer will be updated and thus saves the cost of some memory
copy operation. The logarithm energy is computed as follows:

After computation, the energy is adjusted according to the current encoder mode.
The function qplsEncDTXBuffer_AMRWB  behaves similarly to the EncDTXBuffer_GSMAMR
DecDTXBuffer_GSMAMR function of the GSM-AMR codec.

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr   Indicates an
error when one of the specified
pointers is NULL.
qplStsRangeErr                    Indicates an error when mode  is not a valid element of the
                                  enumerated type  QplSpchBitRate  .

                                                                                           637
---------------------Page 638---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

DecDTXBuffer_AMRWB
Buffers the ISF coefficients and previous logarithm
energy coefficients.

Syntax
QplStatus qplsDecDTXBuffer_AMRWB_16s(const Qpl16s* pSrcSpch, const Qpl16s* pSrcIsf,
Qpl16s* pUpdateIndex, Qpl16s* pSrcDstIsfBuffer, Qpl16s* pSrcDstLogEnergyBuffer         );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcSpch                     Pointer to the input speech signal vector with 256 elements.

pSrcIsp                      Pointer to the ISP vector with 16 elements for this frame.

pUpdateIndex                 Holds the previous memory update index. On output, it contains the
                             current memory update index. It is circularly increased between 0
                             and 7.
pSrcDstIspBuffer             Pointer to the ISP coefficients vector with 128 elements of eight
                             previous frames. On output, points to the ISP coefficients of eight
                             most recent frames (including the current frame).
pSrcDstLogEnergyBuffer       Pointer to the logarithm energy coefficients vector with eight
                             elements of eight previous frames. On output, points to the
                             logarithm energy coefficients of eight most recent frames (including
                             the current frame).

Description
This function buffers the ISF coefficients and previous logarithm energy coefficients. The buffered ISF
coefficients and energy coefficients are used by the SID frame to extract necessary parameters. The memory
update index indicates which part of the buffer will be updated and thus saves the cost of some memory
copy operation. The logarithm energy is computed as follows:

The function qplsDecDTXBuffer_AMRWB  behaves similarly to the EncDTXBuffer_GSMAMR
DecDTXBuffer_GSMAMR function of the GSM-AMR codec.

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointers is NULL.

   638
---------------------Page 639---------------------

                                                                         Speech Coding Functions  9 

AMR Wideband Plus Functions

The Intel QPL functions described in this section if properly combined can be used to construct the Extended
Adaptive Multi-Rate Wideband (AMR WB+) Speech Codec compliant to 3rd Generation Partnership Project
(3GPP) specification TS 26.273: “ANSI-C code for fixed-point Extended AMR Wideband (AMRWB+) Speech
Codec". The description of AMRWB+ codec may be found in 3GPP Technical Specification 26.290: “Extended
AMR Wideband Speech Codec; Transcoding functions" [AMRWB+].
The primitives are primarily designed to implement the well-defined, computationally expensive core
operations that comprise the codec portion of the AMRWB+ system. The AMRWB+ codec comprises an
extended adaptive multi-rate algorithm, intended for encoding 16-bit uniform PCM at the sampling rate of
16, 24, 32 and 48 KHz. The AMRWB+ codec supports AMRWB compatible modes: 6.60, 8.85, 12.65, 14.25,
15.85, 18.25, 19.85, 23.05 or 23.85 kbps for 16 KHz PCM, four special extension stereo modes: 13.6, 18.0,
24.0 kbps and 24.0 kbps for fixed internal sampling frequency only (25600 Hz) and input PCM 16 or 24 kHz
with 20ms frame length. Besides, for thirteen internal sampling frequencies: 12800, 14400, 16000, 17067,
19200, 21333, 24000, 25600, 28800, 32000, 34133, 36000, 38400 and 16, 24, 32 and 48 KHz PCM audio
AMRWB+ supports 24 extended bitrates, resulted for fixed internal frequency 25600 Hz in eight mono: 10.4,
12.0, 13.6, 15.2, 16.8, 19.2, 20.8 and 24 kbps, and sixteen stereo bitrates: from 2.0 to 8.0 kbps with step
of 0.4 kbps. For each internal sampling frequency ISF supported by AMRWB+ codec the correspondent 24
bitrates can be calculated by multiplication to ISF/25600, that is 1/2, 9/16, 5/8, 2/3, 3/4, 5/6, 15/16, 1, 9/8,
5/4, 4/3, 45/32 and 3/2 respectively. For example, for ISF=12800 with multiplier=1/2, the following bitrates
are supported: eight mono 5.2, 6.0, 6.8, 7.6, 9.6, 10.4 and 12 kbps, and sixteen stereo bitrates: from 1.0 to
4.0 with step 0.2 kbps.

SNR_AMRWBE
Computes the signal-to-noise ratio.

Syntax
QplStatus qplsSNR_AMRWBE_16s(const Qpl16s* pSrcSignal, const Qpl16s*
pSrcEstimatedSignal, int lenSrc, int lenSeg, Qpl16s* pDstSNR        );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h , qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcSignal                    Pointer to the input signal.

pSrcEstimatedSignal           Pointer to the estimated signal.

lenSrc                        Length of the signals.

lenSeg                        Length of the segments (subframes).

pDstSNR                       Pointer to the signal-to-noise ratio in dB.

Description
This function computes in decibels (dB) the average segmental signal-to-noise ratio between the lenSrc
samples of the signal pSrcSignal(x) and its estimation pSrcEstimatedSignal(e). The segmental signal-
to-noise ratio (snri) in the i-th segment is defined as follows: 

The average segmental signal-to-noise ratio SNR is computed as:

                                                                                              639
---------------------Page 640---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

where
Nseg is the number of segments.
The segment length is lenSeg samples. The results are stored in the pDstSNR.

Return Values

qplStsNoErr                      Indicates no error.

qplStsNullPtrErr                 Indicates an error when one of the specified pointer is NULL.

qplStsSizeErr                    Indicates an error when lenSrc or lenSeg is less than or equal
                                 to zero.

OpenLoopPitchSearch_AMRWBE
Extracts an OLP lag estimate from the weighted input
speech.

Syntax
QplStatus qplsOpenLoopPitchSearch_AMRWBE_16s (const Qpl16s* pSrcWgtSpch, const Qpl16s*
pSrcFltWgtSpch, Qpl16s* pPrevMedPitchLag, Qpl16s* pAdaptiveParam, Qpl16s*
pDstOpenLoopLag, Qpl16s* pToneFlag, Qpl16s* pDstOpenLoopGain, Qpl16s*
pSrcDstPrevPitchLag, Qpl16s* pSrcDstLagSwitcher, int len, Qpl16s minPitchLag, Qpl16s
maxPitchLag );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcWgtSpch                 Pointer to a vector with 320 elements containing perceptually
                            weighted speech.
pSrcFltWgtSpch              Pointer to a vector with 320 elements containing filtered through
                            high-pass filter perceptually weighted speech.
pPrevMedPitchLag            Pointer to the median filtered pitch lag of the five previous voiced
                            speech half-frames.
pAdaptiveParam              Pointer to the adaptive parameter.

pDstOpenLoopLag             Pointer to a vector with two elements of OLP lags.

pToneFlag                   Pointer to the tone flag for the VAD module.

pDstOpenLoopGain            Pointer to a vector with two elements containing optimal OLP gains.

pSrcDstPrevPitchLag         Pointer to the vector with five elements that contains the pitch lags
                            associated with the five most recent voiced speech half-frames.
pSrcDstLagSwitcher          Switches lag weighting on and off.

len                         Length of the frame.

   640
---------------------Page 641---------------------

                                                                       Speech Coding Functions  9 

minPitchLag                  Minimum pitch lag.

maxPitchLag                  Maximum pitch lag.

Description
The functionality is the same as for the function OpenLoopPitchSearch_AMRWB. The only difference is that
the function qplsOpenLoopPitchSearch_AMRWBE  has the variable range (minPitchLag <= k <=
maxPitchLag ) for computation of a windowed auto correlation. With minPitchLag=17 and
maxPitchLag =115 these functions are identical.

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointers is NULL.

qplStsSizeErr                     Indicates an error when len  is less than or equal to zero.

LPCToISP_AMRWBE
Performs LP to ISP coefficients conversion.

Syntax
QplStatus qplsLPCToISP_AMRWBE_16s(const Qpl16s* pSrcLpc, const Qpl16s* pSrcPrevIsp,
Qpl16s* pDstIsp, int lpOrder   );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcLpc                      Pointer to the input predictor coefficients.

pDstIsp                      Pointer to the output immittance spectral pairs.

pSrcPrevIsp                  Pointer to the input previous immittance spectral pairs.

lpOrder                      Order of conversion.

Description
This function is the extension of the function LPCToISP_AMRWB. If value of the parameter lpOrder = 16,
these functions are identical.

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointers is NULL.

Filtering Functions
This section describes functions that perform filtering operations specific to the AMRWB+ Speech Codec.

                                                                                           641
---------------------Page 642---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

SynthesisFilter_AMRWBE
Reconstructs the speech signal from LP coefficients
and residuals.

Syntax
QplStatus qplsSynthesisFilter_AMRWBE_16s32s_I (Qpl16s* pSrcLpc, int order, const
Qpl16s* pSrcExc, Qpl32s* pSrcDstSignal, int len     );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcLpc                      Pointer to the LP coefficients vector a0, a1,..., aorder
order                        Order of LP filter.

pSrcExc                      Pointer to the excitation vector.

pSrcDstSignal                Pointer to the synthesized and updated speech.

len                          Length of the filter.

Description
This function is identical to qplsSynthesisFilter_AMRWB but performs more accurate calculations and allows
wider range of input data that is required for the extended codec.

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointers is NULL.

QplStsSizeErr                     Indicates an error when len or order is less than or equal to
                                  zero.

Deemphasize_AMRWBE
Performs de-emphasis filtering.

Syntax
QplStatus qplsDeemphasize_AMRWBE_NR_16s_I(Qpl16s gamma, Qpl32s gammaScale, Qpl16s
*pSrcDstSignal, int len, Qpl16s* pMem    );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

   642
---------------------Page 643---------------------

                                                                       Speech Coding Functions  9 

Parameters

gamma                        De-emphasis factor.

gammaScale                   Scale factor for the parameter gamma.

pSrcDstSignal                Pointer to the source and destination vector.

len                          Length of the source and destination vector.

pMem                         Pointer to element of the memory for filtering.

Description
This function is the extension of the Deemphasize_AMRWB function. If the value of the parameter
gammaScale  = 15, these functions are identical.

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when the pSrcDst  or pMem pointer is NULL.

qplStsSizeErr                     Indicates an error when len  is less than or equal to zero.

FIRGenMidBand_AMRWBE
Computes a shape-constrained FIR filter using the
covariance method.

Syntax
QplStatus qplsFIRGenMidBand_AMRWBE_16s(const Qpl16s* pSrcSignal, const Qpl16s*
pSrcSideSignal, Qpl16s* pTaps   );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcSignal                   Pointer to the source signal, [-8...319].

pSrcSideSignal               Pointer to the real side signal [320].

pTaps                        Pointer to the FIR coefficients of length [9].

Description
This function computes a shape-constrained FIR filter minimizing the expression:

The filter coefficients are computed with the covariance method using a modified Cholesky algorithm.
See also 3GPP TS 26.290: “Extended AMR Wideband Speech Codec; Transcoding functions", clauses 5.5.2.3
[AMRWB+].

                                                                                           643
---------------------Page 644---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointer is NULL.

PostFilterLowBand_AMRWBE
Post-processes the low-band decoded signal.

Syntax
QplStatus qplsPostFilterLowBand_AMRWBE_16s(const Qpl16s* pSrcOldPitchLag, const Qpl16s*
pSrcOldPitchGain, Qpl16s* pSrcDstSignal, Qpl16s* pOldSynth, Qpl16s* pOldNoise, Qpl16s*
pFilterScale, Qpl32s pitchAdjust   );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcOldPitchLag              Pointer to the previous pitch periods for all subframes [16]

pSrcOldPitchGain             Pointer to the previous pitch gains for all subframes [16]

pSrcDstSignal                Pointer to the proceeding signal [1024].

pOldSynth                    Pointer to the synthesis memory of post-filter [503].

pOldNoise                    Pointer to the noise memory of post-filter [24].

pFilterScale                 Pointer to the noise memory of post-filter scale factor.

pitchAdjust                  Pitch adjustment flag, if it is NULL, then pitch adjustment is not
                             implemented.

Description
The decoded signal is first processed by an adaptive pitch enhancer, and then filtered through a long-term
prediction filter. Then the obtained long term error signal is low-pass filtered and subtracted from the input
signal.
See also 3GPP TS 26.290: “Extended AMR Wideband Speech Codec; Transcoding functions", clauses 6.1.3
[AMRWB+].

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointer is NULL.

Fast Fourier Transform Functions
This section describes functions that perform fast Fourier transforms specific to the AMRWB+ speech codec.

   644
---------------------Page 645---------------------

                                                                     Speech Coding Functions  9 

FFTFwd_RToPerm_AMRWBE
Computes the forward fast Fourier transform (FFT) of
a real signal.

Syntax
QplStatus qplsFFTFwd_RToPerm_AMRWBE_16s(const Qpl16s* pSrc, Qpl16s* pDst, int len       );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrc                        Pointer to the real-valued sequence.

pDst                        Pointer to the transform result.

len                         Length of the sequence, possible values 48, 96, 192, 288, 576 or
                            1152.

Description
This function computes N1 DFTs of size N2 for real source sequence pSrc. Values of N1 and N2 are functions of
the parameter len as follows:

 len          48            96            192          288           576           1152
 N1           3             3             3            9             9             9
 N2           16            32            64           32            64            128

The resulting separate transforms are then combined through radix-N1 transform. The final resulting
sequence is stored in the Perm format.

Return Values

qplStsNoErr                      Indicates no error.

qplStsNullPtrErr                 Indicates an error when one of the specified pointers is NULL.

qplStsSizeErr                    Indicates an error when len is not equal to 48, 96, 192, 288,
                                 576 or 1152.

FFTInv_PermToR_AMRWBE
Computes the inverse fast Fourier transform (FFT) of a
real signal.

Syntax
QplStatus qplsFFTInv_PermToR_AMRWBE_16s(const Qpl16s* pSrc, Qpl16s* pDst, int len       );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h

                                                                                         645
---------------------Page 646---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrc                         Pointer to the transform coefficients.

pDst                         Pointer to the real-valued sequence.

len                          Length of the sequence, possible values 48, 96, 192, 288, 576 or
                             1152.

Description
This function performs inverse FFT transform. Source data are stored in the Perm format. The results are
stored as the real-valued sequence.

Return Values

qplStsNoErr                      Indicates no error.

qplStsNullPtrErr                 Indicates an error when one of the specified pointers is NULL.

qplStsSizeErr                    Indicates an error when len is not equal to 48, 96, 192, 288,
                                 576 or 1152.

Codebook Search Functions
This section describes functions that perform codebook searching specific to the AMRWB+ speech codec.

AdaptiveCodebookSearch_AMRWBE
Performs the adaptive codebook search.

Syntax
QplStatus qplsAdaptiveCodebookSearch_AMRWBE_16s(const Qpl16s* pSrcAdptTarget, const
Qpl16s* pSrcImpulseResponse, const Qpl16s* pSrcOpenLoopLag, Qpl16s* pPitchLag, Qpl16s*
pPitchLagBounds, Qpl16s* pSrcDstExcitation, Qpl16s* pFracPitchLag, Qpl16s* pAdptIndex,
int subFrame, QplSpchBitRate mode, Qpl16s pitchOffset     );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcAdptTarget               Pointer to the adaptive target signal vector with 64 elements.

pSrcImpulseResponse          Pointer to the impulse response of the weighted synthesis filter
                             vector with 64 elements.
pSrcOpenLoopLag              Pointer to a vector with two elements of the OLP lags.

pPitchLag                    Pointer to the output previous integral pitch lag.

pPitchLagBounds              Pointer to the bounds of the output previous integral pitch lag.

   646
---------------------Page 647---------------------

                                                                     Speech Coding Functions  9 

pSrcDstExcitation           Pointer to the input/output excitation vector with 321 elements.

pFracPitchLag               Pointer to the output fractional pitch lag obtained during the
                            adaptive codebook search.
pAdptIndex                  Pointer to the coded closed-loop pitch index.

subFrame                    Subframe number.

mode                        Coder mode.

pitchOffset                 Offset for the pitch adjustment, value range (-17, 17).

Description
This function is the extension of the function AdaptiveCodebookSearch_AMRWB. The pitchOffset
parameter controls the adjustment of the search ranges. If value of pitchOffset = 0, both functions are
identical.

Return Values

qplStsNoErr                      Indicates no error.

qplStsNullPtrErr                 Indicates an error when one of the specified pointer is NULL.

qplStsSizeErr                    Indicates an error when pitchOffset  is out of the range (-17,
                                 17), or when mode has an illegal value.

AdaptiveCodebookDecode_AMRWBE
Decodes the adaptive codebook vector.

Syntax
QplStatus qplsAdaptiveCodebookDecode_AMRWBE_16s(int valAdptIndex, Qpl16s*
pSrcDstExcitation, Qpl16s* pSrcDstPitchLag, Qpl16s* pSrcDstFracPitchLag, Qpl16s*
pSrcDstPitchLagBounds, int subFrame, int bfi, Qpl16s pitchOffset     );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

valAdptIndex                Adaptive codebook index.

pSrcDstExcitation           Pointer to the excitation vector with 321 elements.

pSrcDstPitchLag             Pointer to the integral pitch lag.

pSrcDstFracPitchLag         Pointer to the fractional pitch lag obtained during the adaptive
                            codebook search.
pPitchLagBounds             Pointer to the previous integral pitch lag bounds.

subFrame                    Subframe number.

bfi                         Bad frame indicator. "0" indicated a valid frame; any other value
                            indicates an invalid frame.

                                                                                         647
---------------------Page 648---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

pitchOffset                  Offset for the pitch adjustment, value range (-17, 17).

Description
This function is similar to the function AdaptiveCodebookDecode_AMRWB but has additional parameter
pitchOffset  that controls the adjustment of the search ranges. If value of pitchOffset = 0, both
functions are identical.

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointer is NULL.

qplStsSizeErr                     Indicates an error when  pitchOffset  is out of the range (-17,
                                  17), or when  mode  has an illegal value.

Resample Functions
This section describes functions that perform different signal resampling operations specific to the AMRWB+
speech codec.

Downsample_AMRWBE
Performs the signal decimating.

Syntax
QplStatus qplsDownsample_AMRWBE_16s(const Qpl16s* pSrcSignal, int lenSrc, Qpl16s*
pDstSignal, Qpl16s* pMem, Qpl32s bandIdx     );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h , qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcSignal                   Pointer to the source signal.

lenSrc                       Length of the source vector, [640] for 8 kHz source signal, [1280]
                             for 16 kHz and [1920] for 24 kHz.
pDstSignal                   Pointer to destination signal [1024].

pMem                         Pointer to the memory for descimating [46].

bandIdx                      Index of interpolating band; possible values: 0 for 0..6.4 kHz band,
                             any other for 6.4..10.8 kHz band.

Description
This function performs downsampling of the source signal pSrcSignal with the following sample rate: 8, 16,
24 kHz. The function filters input signal to the band 0...6.4 kHz, or 6.4...10.8 kHz in accordance with the
parameter bandIdx, and downsamples (upsamples for 8 kHz input signal) to 12.6 kHz.

   648
---------------------Page 649---------------------

                                                                     Speech Coding Functions  9 

Return Values

qplStsNoErr                      Indicates no error.

qplStsNullPtrErr                 Indicates an error when one of the specified pointer is NULL.

qplStsSizeErr                    Indicates an error when lenDst  has an illegal value.

Upsample_AMRWBE
Performs signal oversampling.

Syntax
QplStatus qplsUpsample_AMRWBE_16s(const Qpl16s* pSrcSignal, Qpl16s* pSrcDstSignal, int
lenDst, Qpl16s* pMem, Qpl32s bandIdx, Qpl32s addFlag     );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcSignal                  Pointer to source signal signal [1024].

pSrcDstSignal               Pointer to the destination oversampled signal.

lenDst                      Length of destination vector, [640] for 8kHz output signal, [1280]
                            for 16kHz and [1920] for 24kHz.
pMem                        Pointer to the memory for oversampling [24].

bandIdx                     Index of interpolating band; possible values: 0 for 0..6.4k band, any
                            other value for 6.4..10.8k band.
addFlag                     Flag for adding operation; if it equals 1 then the result is added to
                            the output vector, if it equals 0 - the result is not added.

Description
This function performs the signal oversampling of the source vector pSrcSignal. This operation is inverse of
the operation described in the decsription of the function Downsample_AMRWBE.

Return Values

qplStsNoErr                      Indicates no error.

qplStsNullPtrErr                 Indicates an error when one of the specified pointer is NULL.

qplStsSizeErr                    Indicates an error when lenDst  has an illegal value.

BandSplit_AMRWBE
Splits the signal into low and high frequency
components.

Syntax
QplStatus qplsBandSplit_AMRWBE_16s(const Qpl16s* pSrcSignal, Qpl16s* pSrcDstSig2k,
Qpl16s* pDstSigHi, int len  );

                                                                                         649
---------------------Page 650---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcSignal                   Pointer to the source vector [len + 2*64].

pSrcDstSig2k                 Pointer to the source and destination low frequency vector
                             [len*5/32 + 2*10].
pDstSigHi                    Pointer to the destination high frequency vector [len].

len                          Length of the sample.

Description
This function splits the input signal (f kHz) into two bands: 0...5/32*f kHz band, and 5/32*f ... f kHz band.
The low frequency band is critically down-sampled and the side signal is computed according to the diagram
below.

Band Split Computing

See also 3GPP TS 26.290: “Extended AMR Wideband Speech Codec; Transcoding functions", clauses 5.1.2
[AMRWB+].

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointer is NULL.

qplStsSizeErr                     Indicates an error when len  is less than or equal to zero.

BandJoin_AMRWBE
Joins the low and high frequency signals.

Syntax
QplStatus qplsBandJoin_AMRWBE_16s(const Qpl16s* pSrcSig2k, const Qpl16s* pSrcSigHi,
Qpl16s* pDstSignal, int len   );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

   650
---------------------Page 651---------------------

                                                                      Speech Coding Functions  9 

Parameters

pSrcSig2k                    Pointer to the source low frequency vector [len*5/32 + 2*10].

pSrcSigHi                    Pointer to the source high frequency vector [len].

pDstSignal                   Pointer to the destination vector [len].

len                          Length of the sample.

Description
This function performs operation that is the inverse of the encoder band-splitting operation described in the
decsription of the function BandSplit_AMRWBE, that is the source low frequency signal pSrcSig2k is
oversampled with factor 32/5 and then combined with the source high frequency signal pSrcSigHi. The
result is store in the vector pDstSignal.
See also 3GPP TS 26.290: “Extended AMR Wideband Speech Codec; Transcoding functions", clauses 6.3.4
[AMRWB+].

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointer is NULL.

qplStsSizeErr                     Indicates an error when len is less than or equal to zero.

BandSplitDownsample_AMRWBE
Downsamples input signal and splits it into high and
low frequency components.

Syntax
QplStatus qplsBandSplitDownsample_AMRWBE_16s(const Qpl16s* pSrcSig, int lenSrc, Qpl16s*
pDstSigLF, Qpl16s* pDstSigHF, int lenDst, Qpl16s* pMem, Qpl16s* pInterFracMem, Qpl32s*
pCountSamp, Qpl16s resampleFactor   );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcSig                      Pointer to the source signal.

lenSrc                       Length of the source signal, [7680] for 48 kHz signal, or [7056] for
                             44.1 kHz signal.
pDstSigLF                    Pointer to the destination low frequency component.

pDstSigHF                    Pointer to the destination high frequency component.

lenDst                       Length of destination vectors.

pMem                         Pointer to the memory, [1608] elements.

pInterFracMem                Pointer to the memory for the length of interpolating fraction.

                                                                                          651
---------------------Page 652---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

                             pCountSamp Number of decimated samples.
resampleFactor               Resampling frequency scale factor.

Description
This function downsamples input signal to the desired internal sampling frequency f of the encoder and splits
it into high and low frequency components. Firstly the input signal pSrcSig is upsampled by the factor
resampleFactor , filtered by a low pass filter, and then downsampled by the factor 180. The value of the
resampleFactor  factor depends on the desired internal sampling frequency f (see below). The low
frequency component is obtained by low-pass filtering downsampled signal to f/4 kHz, and critically
downsampling result to f/2 kHz. The high frequency component is obtained by band-pass filtering to
frequencies above f/4 kHz, and critically downsampling result to f/2 kHz.
See also 3GPP TS 26.290: “Extended AMR Wideband Speech Codec; Transcoding functions", clauses 5.1
[AMRWB+].
Dependence between Values of the parameter    resampleFactor   and the Internal Sampling
Frequency
 Internal sampling frequency f, Hz  Factor for the internal frequencyValue of the parameter
                                                                   resampleFactor
 12800                            1/2                              48
 14400                            9/16                             54
 16000                            5/8                              60
 17067                            2/3                              64
 19200                            3/4                              72
 21333                            5/6                              80
 24000                            15/16                            90
 25600                            1                                96
 28800                            9/8                              108
 32000                            5/4                              120
 34133                            4/3                              128
 26000                            45/32                            135
 38400                            3/2                              144

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointer is NULL.

qplStsSizeErr                     Indicates an error when  lenSrc  or lenDst is less than or equal
                                  to zero.

BandJoinUpsample_AMRWBE
Joins high and low frequency signals and upsamples
the result.

Syntax
QplStatus qplsBandJoinUpsample_AMRWBE_16s(const Qpl16s* pSrcSigLF, const Qpl16s*
pSrcSigHF, int lenSrc, Qpl16s* pDstSig, int lenDst, Qpl16s* pMem, Qpl16s*
pInterFracMem, Qpl32s* pCountSamp, Qpl16s resampleFactor       );

Include Files
qplsc.h

   652
---------------------Page 653---------------------

                                                                     Speech Coding Functions  9 

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcSigLF                   Pointer to the low frequency signal.

pSrcSigHF                   Pointer to the high frequency signal.

lenSrc                      Length of low frequency and high frequency vectors.

pDstSig                     Pointer to the upsampled signal.

lenDst                      Length of the destination vector.

pMem                        Pointer to the memory for resampling [72].

pInterFracMem               Pointer to the memory for interpolating fraction.

pCountSamp                  Pointer to the number of oversampled samples.

resampleFactor              Downsampling frequency scale factor.

Description
This function is used by the decoder: it combines the high and low frequency signals and upsamples the
result to produce the full band output signal. This operation is inverse of the encoder band-splitting operation
performed by the function BandSplitDownsample_AMRWBE.
See also 3GPP TS 26.290: “Extended AMR Wideband Speech Codec; Transcoding functions", clauses 6.6
[AMRWB+].

Return Values

qplStsNoErr                      Indicates no error.

qplStsNullPtrErr                 Indicates an error when one of the specified pointer is NULL.

qplStsSizeErr                    Indicates an error when lenSrc  or lenDst is less than or equal
                                 to zero.

ResamplePolyphase_AMRWBE
Upsamples or downsamples the input signal to or from
the upper frequency (44.1/48 khz).

Syntax
QplStatus qplsResamplePolyphase_AMRWBE_16s(const Qpl16s* pSrcSignal, int lenSrc, Qpl16s
upFactor, Qpl16s downFactor, Qpl16s* pInterpFracMem, Qpl16s* pMem, Qpl16s* pDstSignal,
int lenDst);

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

                                                                                         653
---------------------Page 654---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

Parameters

pSrcSignal                    Pointer to the source signal.

lenSrc                        Length of the input vector.

upFactor                      Upsampling factor.

downFactor                    Downsampling factor.

pInterpFracMem                Pointer to the memory for interpolating fraction.

pMem                          Pointer to the memory for resampling, [144] for downsampling, or
                              [44] for upsampling.
pDstSignal                    Pointer to the destination resampled signal.

lenDst                        Length of the destination vector.

Description
This function performs resampling of the input signal in accordance with the values of the resampling factors
upFactor  (upsampling factor) and downFactor (downsampling factor). If upFactor < downFactor, the
function downsamples the input 44.1/48 kHz signal, if upFactor > downFactor, the function upsamples the
input signal to the 44.1/48 kHz signal. The possible combinations of the input/output frequencies and
corresponding values of resampling factors are listed in Tables 9-9 and 9-10.
See also 3GPP TS 26.290: “Extended AMR Wideband Speech Codec; Transcoding functions", clauses 5.1, 6.6
[AMRWB+].
Upsampling Mode
 Input frequency, kHz     Upsampling factor        Downsampling factor      Output frequency, kHz
 8                        12                       2                       48
 16                       12                       4                       48
 24                       12                       6                       48
 32                       12                       8                       48
 11.025                   12                       3                       44.1
 22.05                    12                       6                       44.1
Downsampling Mode
 Input frequency, kHz     Upsampling factor        Downsampling factor      Output frequency, kHz
 48                       2                        12                      8
 48                       4                        12                      16
 48                       6                        12                      24
 48                       8                        12                      32
 44.1                     3                        12                      11.025
 44.1                     6                        12                      22.05

Return Values

qplStsNoErr                        Indicates no error.

qplStsNullPtrErr                   Indicates an error when one of the specified pointer is NULL.

qplStsSizeErr                      Indicates an error when lenDst  has an illegal value.

Quantization Functions
This section describes functions that perform quantization specific to the AMRWB+ speech codec.

   654
---------------------Page 655---------------------

                                                                     Speech Coding Functions  9 

ISFQuantDecode_AMRWBE
Decodes quantized ISFs from the received codebook
index.

Syntax
QplStatus qplsISFQuantDecode_AMRWBE_16s(const Qpl16s* pSrcIdxs, Qpl16s* pDstQntIsf,
Qpl16s* pSrcDstResidual, const Qpl16s* pSrcPrevQntIsf, Qpl16s* pSrcDstIsfMemory, Qpl32s
bfi, Qpl32s splitMask );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcIdxs                    Pointer to the vector with seven elements containing codebook
                            indices of the quantized LSPs.
pDstQntIsf                  Pointer to a destination vector with 16 elements containing
                            quantized ISF in cosine domain.
pSrcDstResidual             Pointer to the quantized ISF residual vector with 16 elements from
                            the previous frame.
pSrcPrevQntIsf              Pointer to the quantized ISF vector with 16 elements from the
                            previous frame.
pSrcDstIsfMemory            Pointer to the vector with 64 elements containing four subframe ISF
                            sets.
bfi                         Bad frame indicator: "0" indicates a valid frame, all other values
                            indicate an invalid frame.
splitMask                   Binary mask for the second-stage splitting. It contains 5 significant
                            bits, low significant bit corresponds to the low number of splitting.

Description
The function decodes quantized ISFs from the received codebook index. This function is extension of the
function ISFQuantDecode_AMRWB. If the parameter splitMask is set to 0, both functions are identical.
Otherwise the function performs the second-level splitting in accordance with the splitMask.

Return Values

qplStsNoErr                      Indicates no error.

qplStsNullPtrErr                 Indicates an error when one of the specified pointer is NULL.

ISFQuantDecodeHighBand_AMRWBE
Decodes quantized ISF of HF-band signal.

Syntax
QplStatus qplsISFQuantDecodeHighBand_AMRWBE_16s(const Qpl16s* pSrcQuantIdxs, Qpl16s*
pSrcDstPastQISF, Qpl16s* pDstQISF, Qpl32s bfi, Qpl32s pitchAdjust      );

                                                                                         655
---------------------Page 656---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcQuantIdxs                Pointer to the quantization indices [2].

pSrcDstPastQISF              Pointer to the past quantized ISF [8].

pDstQISF                     Pointer to the output vector of decoded quantized ISF [8].

bfi                          Bad frame indicator. "0" indicates a valid frame; any other value
                             indicates an invalid frame.
pitchAdjust                  Controls pitch adjustment: if it equals 0, then the function does not
                             perform pitch adjustment.

Description
This function decodes quantized ISF of HF-band signal from the received codebook index if the errors are not
detected on the received frame. Otherwise, the function recovers the quantized ISFs from previous quantized
ISFs using linear interpolation.

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointer is NULL.

ISFQuantHighBand_AMRWBE
Performs ISF quantization of HF-band encoded signal.

Syntax
QplStatus qplsISFQuantHighBand_AMRWBE_16s(const Qpl16s* pSrcISF, Qpl16s*
pSrcDstPastQISF, Qpl16s* pDstQISF, Qpl16s* pQuandIdxs, Qpl32s pitchAdjust        );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcISF                      Pointer to the source vector of proceeding ISF [8].

pSrcDstPastQISF              Pointer to the past quantized ISF [8].

pDstQISF                     Pointer to the output vector of quantized ISF [8].

pQuantIdxs                   Pointer to the output quantization indices [2].

   656
---------------------Page 657---------------------

                                                                    Speech Coding Functions  9 

pitchAdjust                 Controls pitch adjustment: if it equals to 0, then the function does
                            not perform pitch adjustment.

Description
This function performs ISF quantization of HF-band encoded signal using one-stage VQ with 8 elements.
See also 3GPP TS 26.290: “Extended AMR Wideband Speech Codec; Transcoding functions", clauses 5.4
[AMRWB+].

Return Values

qplStsNoErr                      Indicates no error.

qplStsNullPtrErr                 Indicates an error when one of the specified pointer is NULL.

GainQuant_AMRWBE
Quantizes the adaptive codebook gains.

Syntax
QplStatus qplsGainQuant_AMRWBE_16s(Qpl16s* pSrcAdptTarget, const Qpl16s *
pSrcFltAdptVector, int valFormat, const Qpl16s* pSrcFixedVector, const Qpl16s*
pSrcFltFixedVector, int lenSrc, const Qpl16s* pSrcCorr, Qpl16s meanEnergy, Qpl16s*
pSrcDstPitchGain, Qpl16s* pDstCorrFactor, Qpl32s* pDstCodeGain, Qpl16s*
pDstQGainIndex );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcAdptTarget              Pointer to the input target vector x(n).

pSrcFltAdptVector           Pointer to the input filtered adaptive codebook vector y(n).

valFormat                   Format of the pSrcAdptTarget  and pSrcFltAdptVector  vectors.

pSrcFixedVector             Pointer to the input pre-filtered codebook contribution c(n).

pSrcFltFixedVector          Pointer to the input filtered codebook vector z(n).

lenSrc                      Length of the input vectors (n).

pSrcCorr                    Pointer to the vector of correlations between the pSrcAdptTarget,
                            pSrcFltAdptVector , pSrcFltFixedVector  vectors.
meanEnergy                  Average energy in the whole frame.

pSrcDstPitchGain            Pointer to the input/output pitch gain.

pDstCorrFactor              Pointer to the correction factor.

pDstCodeGain                Pointer to the output code gain.

pDstQGainIndex              Pointer to the output codebook indexes found.

                                                                                        657
---------------------Page 658---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

Description
This function quantizes the adaptive codebook gain (pitch gain) and the fixed (algebraic) codebook gain
using the same 7-bit codebook that is used in the function GainQuant_AMRWB for modes from 12.6 to 23.8
kbit/s. However, instead of using moving average prediction to obtain the predicted gain gC, it is found
directly by quantizing the average energy meanEnergy in the whole frame.

Return Values

qplStsNoErr                        Indicates no error.

qplStsNullPtrErr                   Indicates an error when one of the specified pointer is NULL .

qplStsSizeErr                      Indicates an error when  lenSrc  is less than or equal to zero.

QuantTCX_AMRWBE
Quantizes the pre-shaped spectrum in TCX mode.

Syntax
QplStatus qplsQuantTCX_AMRWBE_16s(const Qpl16s* pSrc, Qpl16s* pDst, int nSubvectors,
int nBits, Qpl16s* pDstNoiseFactor     );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h , qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrc                          Pointer to the source signal [nSubvectors *8].

pDst                          Pointer to the quantized normalized vector[ nSubvectors  *8 +
                              nSubvectors  ].
nSubvectors                   Number of subvectors.

nBits                         Number of bits to use.

pDstNoiseFactor               Pointer to the comfort noise gain factor.

Description
This function quantizes the pre-shaped spectrum in TCX mode.This function quantizes the pre-shaped
spectrum in TCX mode using lattice quantizers method. The spectrum is quantized in 8-dimensional blocks
using vector codebooks composed of subsets of the Gosset lattice. In lattice quantization, the procedure of
finding the nearest neighbour of an input vector among all codebook points is reduced to a several simple
operations - rounding the components of the vector and verifying a few constraints with no exhaustive
search. The binary indexes are computed only if a given TCX mode is retained as the best mode for a frame.
It allows to reduce computation complexity.
See also 3GPP TS 26.290: “Extended AMR Wideband Speech Codec; Transcoding functions", clause 5.3.5.7
[AMRWB+].

Return Values

qplStsNoErr                        Indicates no error.

   658
---------------------Page 659---------------------

                                                                       Speech Coding Functions  9 

qplStsNullPtrErr                  Indicates an error when one of the specified pointer is NULL.

GainQuantTCX_AMRWBE
Performs the gain optimization and quantization.

Syntax
QplStatus qplsGainQuantTCX_AMRWBE_16s(const Qpl16s* pSrcSignal, Qpl16s srcScale, const
Qpl16s* pSrcQuantSignal, int len, Qpl32s quantFlag, Qpl32s* pGain, Qpl16s* pQuantIdx         );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcSignal                   Pointer to the original weighted signal.

srcScale                     Format of input signal.

pSrcQuantSignal              Pointer to the quantized weighted signal.

len                          Length of the source vector.

quantFlag                    If equals 0, then the function computes and returns the optimal gain
                             only, else computes and returns the quantized gain and quantization
                             index.
pGain                        Pointer to the output quantized or optimal gain.

pQuantIdx                    Pointer to the output index of quantization.

Description
This function performs the gain optimization and quantization to maximize the correlation between the
original weighted signal pSrcSignal(x) and the quantized weighted signal pSrcQuantSignal (x' ). The
optimal gain g* between x and x' is computed using the following formula:

The gain g* is quantized on the logarithmic scale to a 7-bit index in the following way:

• compute the energy of the quantized weighted signal ;
• compute the RMS value rms = 4(E/len)  1/2;
• compute the index index = 28log(rms g*) + 0.5   ;
• if index < 0, then set index = 0; if index > 127, then set index = 127;
• and the quantized gain g'* = 10index/28rms

See also 3GPP TS 26.290: “Extended AMR Wideband Speech Codec; Transcoding functions", clause 5.3.5.10
[AMRWB+].

Return Values

qplStsNoErr                       Indicates no error.

                                                                                           659
---------------------Page 660---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

qplStsNullPtrErr                  Indicates an error when one of the specified pointer is NULL.

qplStsSizeErr                     Indicates an error when len  is less than or equal to zero.

GainDecodeTCX_AMRWBE
Decodes the global TCX gain.

Syntax
QplStatus qplsGainDecodeTCX_AMRWBE_16s(const Qpl16s* pSrcQuantSignal, int len, Qpl16s
quantIdx, Qpl32s bfi, Qpl16s* pSrcDstRMSval, Qpl32s* pGain      );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcQuantSignal              Pointer to the quantized signal.

len                          Length of the source signal.

quantIdx                     Index of quantization.

bfi                          Bad frame indicator. Value "0" indicates a valid frame; any other
                             value indicates an invalid frame.
pSrcDstRMSval                Pointer to the root mean square value.

pGain                        Pointer to the output global TCX gain.

Description
This function decodes the global TCX gain gTCX by inverting the 7-bit logarithmic quantization calculated in
the TCX encoder as in the function GainQuantTCX_AMRWBE.
First the RMS value of the TCX target signal pSrcQuantSignal(x') is computed as

From the received 7-bit index 0 ≤ quantIdx ≤ 127, the TCX gain pGain can be computed
pGain* = 10quantIdx /28*4rms

See also 3GPP TS 26.290: “Extended AMR Wideband Speech Codec; Transcoding functions", clause 6.1.2
[AMRWB+].

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointer is NULL.

qplStsSizeErr                     Indicates an error when len  is less than or equal to zero.

   660
---------------------Page 661---------------------

                                                                    Speech Coding Functions  9 

EncodeMux_AMRWBE
Encodes and multiplexes subvectors into several
packets.

Syntax
QplStatus qplsEncodeMux_AMRWBE_16s(const Qpl16s* pSrc, int nSubvectors, const int*
pPacketSizes, Qpl16s* pDstParams, int nPackets   );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrc                        Pointer to the rounded subvectors [nSubvectors*8 + nSubvectors ].

nSubvectors                 Number of subvectors.

pPacketSizes                Pointer to the vector of size of each packet [nPackets].

pDstParams                  Multiplexed parameters [( pPacketSizes[0]+3)/4 +...+
                            (pPacketSizes [nPackets]+3)/4].
nPackets                    Number of packets.

Description
This function encodes the TCX parameters and puts them in one or several binary packets for transmission.
See also 3GPP TS 26.290: “Extended AMR Wideband Speech Codec; Transcoding functions", clause 5.6
[AMRWB+].

Return Values

qplStsNoErr                      Indicates no error.

qplStsNullPtrErr                 Indicates an error when one of the specified pointer is NULL.

DecodeDemux_AMRWBE
Demultiplexes and decodes subvectors from several
packets.

Syntax
QplStatus qplsDecodeDemux_AMRWBE_16s(const Qpl16s* pSrcParams, const Qpl32s*
pPacketSizes, const Qpl32s* pBFI, int nPackets, Qpl16s* pDst, int nSubvectors     );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

                                                                                       661
---------------------Page 662---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

Parameters

pSrcParams                  Demultiplexed parameters [(  pPacketSizes [0]+3)/4 +...+
                            (pPacketSizes [nPackets ]+3)/4].
pPacketSizes                Pointer to the vector of size of each packet [nPackets].

pBFI                        Pointer to the vector of bad frame indicator for each packet
                            [nPackets ].
nPackets                    Number of packets.

pDst                        Pointer to the rounded subvectors [nSubvectors *8].

nSubvectors                 Number of subvectors.

Description
This function demultiplexes and decodes subvectors from several packets, that is performs inverse operation
to the encoding procedure performed by the function EncodeMux_AMRWBE.

Return Values

qplStsNoErr                      Indicates no error.

qplStsNullPtrErr                 Indicates an error when one of the specified pointer is NULL.

GSM Full Rate Functions
This section describes the Intel QPL functions that can be used in implementing speech codecs following the
GSM 06.10, 06.11, 06.12, 06.31, and 06.32 recommendations.

RPEQuantDecode_GSMFR
Performs APCM inverse quantization.

Syntax
QplStatus qplsRPEQuantDecode_GSMFR_16s (const Qpl16s* pSrc, Qpl16s ampl, Qpl16s
amplSfs, Qpl16s* pDst  );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrc                        Pointer to the input vector [13] of the RPE samples.

ampl                        The block amplitude.

amplSfs                     Scale factor of the block amplitude.

pDst                        Pointer to the output reconstructed long-term residual vector [13].

   662
---------------------Page 663---------------------

                                                                        Speech Coding Functions  9 

Description
This function performs APCM inverse quantization of the input RPE samples. The output reconstructed long-
term residual vector is formed as 

Return Values

qplStsNoErr                        Indicates no error.

qplStsNullPtrErr                   Indicates an error when one of the specified pointer is NULL.

qplStsScaleRangeErr                Indicates an error when amplSfs  is less than zero.

Deemphasize_GSMFR
Performs de-emphasis filtering.

Syntax
QplStatus qplsDeemphasize_GSMFR_16s_I (Qpl16s* pSrcDst, int len, Qpl16s* pMem          );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h , qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcDst                       Pointer to the input short-term synthesized signal and output post-
                              processed speech vector [ len].
len                           Length of the input residual and output speech vectors.

pMem                          Pointer to the filter memory element.

Description
This function performs de-emphasis of the input synthesized signal by filtering it through the filter with the
following transfer function:
H(z) = 1/(1 - α*z  -1)
where α = 0.86 (28180 in Q15).
The initial memory of the filter will be set to zero. The filtered speech signal is scaled up by multiple of 2 and
then stored in pSrcDst with truncation of the three least significant bits.

Return Values

qplStsNoErr                        Indicates no error.

qplStsNullPtrErr                   Indicates an error when one of the specified pointer is NULL.

qplStsRangeErr                     Indicates an error when len  is less than or equal to zero.

                                                                                             663
---------------------Page 664---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

ShortTermAnalysisFilter_GSMFR
Performs short-term analysis filtering.

Syntax
QplStatus qplsShortTermAnalysisFilter_GSMFR_16s_I (const Qpl16s* pRC, Qpl16s*
pSrcDstSpch, int len, Qpl16s* pMem    );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h , qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pRC                          Pointer to the input reflection coefficients vector [8]: a1, a2,..., a8.

pSrcDstSpch                  Pointer to the input pre-processed speech and output short term
                             residual vector [len].
len                          Length of the input speech and output residual vectors.

pMem                         Pointer to the filter memory vector [8]: m0, m1,..., m7.

Description
This function performs filtering of the input pre-processed speech vector s( n) and stores the result in the
output short-term residual vector r( n) as given below: r0 = s(n)
ri = ri-1 + ai * mi-1, i= 1,...,8
m0 = s (n)
mi = mi-1 + ai * ri-1, i = 1,...,7
r (n) = r8
where
mi, i = 0,...,7 is the filter memory and ri, i = 0,...,8 is the reusable local memory.
The initial filter memory vector will be zeroed.

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointer is NULL.

qplStsRangeErr                    Indicates an error when  len is less than or equal to zero.

ShortTermSynthesisFilter_GSMFR
Performs short-term synthesis filtering.

Syntax
QplStatus qplsShortTermSynthesisFilter_GSMFR_16s (const Qpl16s* pRC, const Qpl16s*
pSrcResidual, Qpl16s* pDstSpch, int len, Qpl16s* pMem       );

   664
---------------------Page 665---------------------

                                                                         Speech Coding Functions  9  

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h , qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pRC                           Pointer to the input reflection coefficients vector [8]: Pointer to the
                              input reflection coefficients vector [8]: a1, a2,..., a8.
pSrcResidual                  Pointer to the input reconstructed short term residual vector [len ].

pDstSpch                      Pointer to the output speech vector [ len].

len                           Length of the input residual and output speech vectors.

pMem                          Pointer to the filter memory vector [8]: m0, m1,..., m7.

Description
This function performs filtering of the input reconstructed short-term residual r( n) and stores the result in
the output speech vector s( n) as given below:
s0 = r( n)
si = si-1 - a9-i * m8-i , i = 1,...,8
m8-i = m7-i + - a9-i * si , i = 1,...,7
s (n) = s8
m0 = s (n)
where
mi , i = 0,...,7 is the filter memory and si , i = 0,...,8 is the reusable local memory.
The initial filter memory vector will be zeroed.

Return Values

qplStsNoErr                        Indicates no error.

qplStsNullPtrErr                   Indicates an error when one of the specified pointer is NULL .

qplStsRangeErr                     Indicates an error when  len  is less than or equal to zero.

HighPassFilter_GSMFR
Performs high-pass filtering of the input speech signal.

Syntax
QplStatus qplsHighPassFilter_GSMFR_16s (const Qpl16s* pSrc, Qpl16s* pDst, int len, int*
pMem);

Include Files
qplsc.h

                                                                                              665
---------------------Page 666---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

Domain Dependencies
Headers: qplcore.h , qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrc                          Pointer to the source speech vector [len].

pDst                          Pointer to the destination filtered vector [len].

len                           Length of the source and destination vectors.

pMem                          Pointer to the filter memory vector [2].

Description
This function filters the input speech signal according to the transfer function:
H(z) = 0.5(1 - z  -1 /(1 - α*z -1)
where
α = 0.99899.
The initial filter memory will be set to zero.

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointer is NULL.

qplStsSizeErr                     Indicates an error when  len  is less than or equal to zero.

Schur_GSMFR
Estimates the reflection coefficients by Schur
recursion.

Syntax
QplStatus qplsSchur_GSMFR_32s16s (const Qpl32s* pSrc, Qpl16s* pDst, int dstLen          );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h , qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrc                          Pointer to the input autocorrelation vector [dstLen+1].

pDst                          Pointer to the output reflection coefficients vector [dstLen].

dstLen                        The number of reflection coefficients to estimate.

Description
This function implements the Schur algorithm according to GSM 06.10 clause 4.2.5.

   666
---------------------Page 667---------------------

                                                                      Speech Coding Functions  9 

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointer is NULL.

qplStsSizeErr                     Indicates an error when dstLen  is less or equal to zero, or
                                  dstLen is less than 9.

WeightingFilter_GSMFR
Calculates the weighting filter.

Syntax
QplStatus qplsWeightingFilter_GSMFR_16s (const Qpl16s* pSrc, Qpl16s* pDst, int dstLen         );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrc                         Pointer to the input long-term residual vector [-5,..,dstLen+4].

pDst                         Pointer to the filtered output vector [dstLen].

dstLen                       The number of filtered elements to calculate.

Description
This function performs filtering of the input signal by symmetric FIR filter with predefined taps given below:
taps[i]=[-134, -374, 0, 2054, 5741, 8192, 5741, 2054, 0, -374, -134], i=0,..,10
The filtering is performing according to formula:

The result of filtering is stored in pDst.

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointer is NULL.

qplStsSizeErr                     Indicates an error when len is less than or equal to zero.

Preemphasize_GSMFR
Computes pre-emphasis of a speech signal.

Syntax
QplStatus qplsPreemphasize_GSMFR_16s(const Qpl16s* pSrc, Qpl16s* pDst, int* pMem, int
len);

                                                                                           667
---------------------Page 668---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h , qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrc                         Pointer to the offset-free input speech signal.

pDst                         Pointer to the pre-emphasized output signal.

pMem                         Pointer to the filter memory value.

len                          Length of the input and output signals.

Description
This function computes pre-emphasis of the input speech according to the difference signal pre-emphasis
equation:
H(z) = 1 - γ*z -1

for γ = -0.86 and pSrc[-1] = pMem[0].
The result of filtering is stored in pDst. The memory value pMem[0] is updated by pSrc[n-1]. For proper use
of this function in GSM Full Rate codec, the memory value will be initialized to zero.
The function qplsPreemphasize_GSMFR  performs NR rounding.

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointer is NULL.

qplStsSizeErr                     Indicates an error when  len is less than or equal to zero.

See Also
Rounding Modes for Speech Codecs

G.722.1 Functions

This chapter describes the Intel QPL functions that can be used in implementing speech codecs following the
ITU-T recommendations G.722.1.
These functions are used in the Intel QPL G.722.1 Speech Encoder-Decodersample downloadable from http://
www.intel.com/cd/software/products/asmo-na/eng/220046.htm.

DCTFwd_G722, DCTFwd_G7221
Computes the forward DCT of a signal.

Syntax
QplStatus qplsDCTFwd_G722_16s(const Qpl16s* pSrc, Qpl16s* pDst       );
QplStatus qplsDCTFwd_G7221_16s (const Qpl16s* pSrc, Qpl16s* pDst, int len         );

   668
---------------------Page 669---------------------

                                                                      Speech Coding Functions  9 

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrc                         Pointer to the source vector.

pDst                         Pointer to the destination vector.

len                          Number of elements on the source and destination vectors, possible
                             values: 320, 640.

Description
The function qplsDCTFWD_G722 computes the forward DCT of the fixed length [320]. The function
qplsDCTFWD_G7221  computes the forward DCT of the length len. The calculation is performed according to
the following formula:

Return Values

qplStsNoErr                      Indicates no error.

qplStsNullPtrErr                 Indicates an error when one of the specified pointer is NULL.

qplStsSizeErr                    Indicates an error when the len has an illegal value.

DCTInv_ G722, DCTInvG7221
Computes the inverse discrete cosine transform (DCT)
of a signal.

Syntax
QplStatus qplsDCTInv_G722_16s (const Qpl16s* pSrc, Qpl16s* pDst      );
QplStatus qplsDCTInv_G7221_16s (const Qpl16s* pSrc, Qpl16s* pDst, int len       );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrc                         Pointer to the source vector.

pDst                         Pointer to the destination vector.

len                          Number of elements on the source and destination vectors, possible
                             values: 320, 640.

                                                                                          669
---------------------Page 670---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

Description
The function qplsDCTInv_G722 computes the DCT of the fixed length [320]. The function
qplsDCTInv_G7221  computes the inverse DCT of the length len. The calculation is performed according to
the following formula:

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointer is NULL.

qplStsSizeErr                     Indicates an error when the len  has an illegal value.

DecomposeMLTToDCT_G722,DecomposeMLTToDCT_G7221
Decomposes the MLT input signal to the form of the
DCT input signal.

Syntax
QplStatus qplsDecomposeMLTToDCT_G722_16s(const Qpl16s* pSrcSpch, Qpl16s*
pSrcDstSpchOld, Qpl16s* pDstSpchDecomposed     );
QplStatus qplsDecomposeMLTToDCT_G7221_16s(const Qpl16s* pSrcSpch, Qpl16s*
pSrcDstSpchOld, Qpl16s* pDstSpchDecomposed, int len      );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcSpch                     Pointer to the source vector.

pSrcSpchOld                  Pointer to the source/destination vector of the previous speech
                             frame.
pDstSpchDecomposed           Pointer to the destination decomposed speech vector.

len                          Number of elements on the source and destination vectors, valid
                             values: 320, 640.

Description
These functions decompose the input signal by windowing, overlapping and summation to the form suitable
for the DCT operation required for modulated lapped transform (MLT) coefficients calculation. The function
qplsDecomposeMLTToDCT_G722    operates with the vector of the fixed length [320]. The function
qplsDecomposeMLTToDCT_G7221    operates with the vector of the len length.
If l = len, l2 = len /2, and v=pDstSpchDecomposed, then the calculation is performed as follows:

where

   670
---------------------Page 671---------------------

                                                                     Speech Coding Functions  9 

and

The input signal pSrcSpch is stored in pSrcDstSpchOld for use in the next frame.

Return Values

qplStsNoErr                      Indicates no error.

qplStsNullPtrErr                 Indicates an error when one of the specified pointer is NULL.

qplStsSizeErr                    Indicates an error when the len has an illegal value.

DecomposeDCTToMLT_G722, DecomposeDCTToMLT_G7221
Decomposes inverse DCT output signal to the form of
the MLT output signal.

Syntax
QplStatus qplsDecomposeDCTToMLT_G722_16s(const Qpl16s* pSrcSpchDecomposed, Qpl16s*
pSrcDstSpchDecomposedOld, Qpl16s* pDstSpch    );
QplStatus qplsDecomposeDCTToMLT_G7221_16s(const Qpl16s* pSrcSpchDecomposed, Qpl16s*
pSrcDstSpchDecomposedOld, Qpl16s* pDstSpch, int len    );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcSpchDecomposed                    Pointer to the source vectorPointer to the source
                                      windowed speech vector [320 or  len ].
pSrcDstSpchDecomposedOld              Pointer to the source and destination windowed speech
                                      vector [160 or len/2] of the previous frame.
pDstSpch                              Pointer to the destination speech vector [320 or len].

len                                   Number of elements on the source and destination
                                      vectors, valid values: 320, 640.

Description
These functions perform inverse decomposition of the inverse DCT output by windowing, overlapping and
summation, and restore speech signal. The function qplsDecomposeDCTToMLT_G722 operates with the
source vector of the fixed length [320]. The function qplsDecomposeDCTToMLT_G7221 operates with the
source vector of the len length.
If l = len, l2 = len /2, and u=pSrcSpchDecomposed, uold=pSrcDstSpchDecomposedOld , y=pDstSpch,
then the calculation is performed as follows:

where

                                                                                         671
---------------------Page 672---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

The unused second half of the input signal is stored for use with the next frame:

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointer is NULL.

qplStsSizeErr                     Indicates an error when the len has an illegal value.

HuffmanEncode_G722
Performs Huffman encoding of the quantized
amplitude envelope indexes.

Syntax
QplStatus qplsHuffmanEncode_G722_16s32u(int category, int qntAmpEnvIndex, const Qpl16s*
pSrcMLTCoeffs, Qpl32u* pDstCode, int* pCodeLength     );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

category                     The category of the Modulated Lapped Transform (MLT) region in
                             the range of [0-6].
qntAmpEnvIndex               The quantized amplitude envelope index in the range of [0-63].

pSrcMLTCoeffs                Pointer to the source vector [20] of raw MLT coefficients.

pDstCode                     Pointer to the output Huffman code.

pCodeLength                  Pointer to the output Huffman code length in bits.

Description
This function performs Huffman encoding of the quantized index of the amplitude envelope of one of the 20
regions of the MLT coefficients.

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointer is NULL.

QplStsScaleRangeErr               Indicates an error when category  or qntAmpEnvIndex  is out of
                                  proper range.

G.726 Functions
This section describes Intel QPL functions that can be used in implementing speech codecs following the ITU-T
recommendations G.726 with Annex A.

   672
---------------------Page 673---------------------

                                                                     Speech Coding Functions  9 
These functions are used in the Intel QPL G.726 Speech Encoder-Decoder sample downloadable from http://
www.intel.com/cd/software/products/asmo-na/eng/220046.htm.

EncodeGetStateSize_G726
Informative function, returns the number of bytes
needed for encoder memory.

Syntax
QplStatus qplsEncodeGetStateSize_G726_16s8u (unsigned int* pEncSize      );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pEncSize                    Pointer to the output memory size in bytes.

Description
This function gets information about the amount of memory needed to process the G.726 ADPCM
compression.

Return Values

qplStsNoErr                      Indicates no error.

QplStsNullPtrErr                 Indicates an error when the pEncSize pointer is NULL.

EncodeInit_G726
Initializes the memory for the ADPCM encoder.

Syntax
QplStatus qplsEncodeInit_G726_16s8u (QplsEncoderState_G726_16s* pEncMem, QplSpchBitRate
rate);

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pEncMem                     Pointer to the input memory buffer of size needed to properly
                            initialize the G.726 encoder.

                                                                                         673
---------------------Page 674---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

rate                         Encode bit rate of the G.726 encoder, must be one of
                             QPL_SPCHBR_16000  , QPL_SPCHBR_24000  , QPL_SPCHBR_32000 , or
                             QPL_SPCHBR_40000  .

Description
This function initializes the memory given by the pointer pEncMem to enable G.726 ADPCM compression
starting from the reset state.

Return Values

qplStsNoErr                       Indicates no error.

QplStsNullPtrErr                  Indicates an error when the  pEncMem  pointer is NULL.

qplStsBadArgErr                   Indicates an error when  rate is not equal to one of the
                                  admissible encoding bit rates: QPL_SPCHBR_16000  ,
                                  QPL_SPCHBR_24000  , QPL_SPCHBR_32000  , or QPL_SPCHBR_40000 .

Encode_G726
Performs ADPCM compression of the uniform PCM
input.

Syntax
QplStatus qplsEncode_G726_16s8u (QplsEncoderState_G726_16s* pEncMem , const Qpl16s*
pSrc, Qpl8u* pDst, unsigned int len    );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h , qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pEncMem                      Pointer to the memory buffer that has been initialized for ADPCM
                             encode.
pSrc                         Pointer to the uniform PCM input speech vector.

pDst                         Pointer to the ADPCM bit-stream output vector.

len                          The length of input/output vectors.

Description
This function performs ADPCM compression of the 14-bit uniform PCM speech input (Recommendation G.726,
Annex A) with the bit rate on which the G.726 encoder (with memory pointed to by pEncMem) was initialized
to operate. Each byte of the output vector contains ADPCM compressed value of two, three, four, or five
binary digits for 16, 24, 32 or 40 Kbit/s bit-rate ADPCM compression, respectively.
The Mu-Law or A-Law PCM input should be expanded to 14-bit uniform PCM prior to ADPCM compression
(see Recommendation G.726). This expansion may be done, for example, by first applying the functions 
MuLawToLin or ALawToMuLaw, which expand 8-bit Mu-Law or A-Law PCM, respectively, into linear 16-bit
PCM.

   674
---------------------Page 675---------------------

                                                                     Speech Coding Functions  9 

The linear 16-bit PCM input must be shifted two bits to the right (divided by four) to achieve the 14-bit
uniform PCM input appropriate for the function qplsEncode_G726.

Return Values

qplStsNoErr                      Indicates no error.

qplStsNullPtrErr                 Indicates an error when one of the specified pointer is NULL.

qplStsBadArgErr                  Indicates an error when the len is less than or equal to zero.

DecodeGetStateSize_G726
Informative function, returns the number of bytes
needed for decoder memory.

Syntax
QplStatus qplsDecodeGetStateSize_G726_8u16s (unsigned int* pDecSize      );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pDecSize                     Pointer to the output memory size in bytes.

Description
This function reports the amount of memory needed to process the G.726 ADPCM decompression.

Return Values

qplStsNoErr                      Indicates no error.

QplStsNullPtrErr                 Indicates an error when the pDecSize  pointer is NULL.

DecodeInit_G726
Initializes the memory for the G.726 decoder.

Syntax
QplStatus qplsDecodeInit_G726_8u16s (QplsDecoderState_G726_16s* pDecMem, QplSpchBitRate
rate, QplPCMLaw law );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

                                                                                          675
---------------------Page 676---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

Parameters

pDecMem                      Pointer to the input memory buffer of size needed to properly
                             initialize the G.726 decoder.
rate                         Decode bit rate of the G.726 decoder, must be one of
                             QPL_SPCHBR_16000  , QPL_SPCHBR_24000 , QPL_SPCHBR_32000 , or
                             QPL_SPCHBR_40000  .
law                          Output speech PCM law: must be one of   QPL_PCM_MULAW  ,
                             QPL_PCM_ALAW  or QPL_PCM_LINEAR .

Description
This function initializes the memory given by the pointer pDecMem to enable ADPCM decompression starting
from the reset state.

Return Values

qplStsNoErr                       Indicates no error.

QplStsNullPtrErr                  Indicates an error when the pDecMem  pointer is NULL.

qplStsBadArgErr                   Indicates an error when rate or law has an illegal value.

Decode_G726
Performs decompression of the ADPCM bit-stream.

Syntax
QplStatus qplsDecode_G726_8u16s (QplsDecoderState_G726_16s* pDecMem, const Qpl8u* pSrc,
Qpl16s* pDst, unsigned int len   );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pDecMem                      Pointer to the memory buffer that has been initialized for G.726
                             ADPCM decoder.
pSrc                         Pointer to the input vector that contains two, three, four, or five
                             binary digits per byte for 16, 24, 32, or 40 Kbit/s ADPCM bit-stream,
                             respectively.
pDst                         Pointer to the 16-bit linear PCM speech output vector.

len                          The length of input/output vectors.

Description
This function performs decompression of the ADPCM bit-stream input (Recommendation G.726) into 16-bit
linear PCM. The input bit-stream must be ADPCM compressed on the bit rate for which the G.726 decoder
was initialized to operate.

   676
---------------------Page 677---------------------

                                                                       Speech Coding Functions  9 

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointer is NULL.

qplStsBadArgErr                   Indicates an error when the len is less than or equal to zero.

G.728 Functions
This section describes Intel QPL functions that can be used in implementing speech codecs following ITU-T*
recommendation G.728 with Annexes I, H [ITU728].
These functions are used in the Intel QPL G.728 Speech Encoder-Decoder sample downloadable from http://
www.intel.com/cd/software/products/asmo-na/eng/220046.htm.

IIRGetStateSize_G728
Gets the size of IIR state structure to be used.

Syntax
QplStatus qplsIIR16sGetStateSize_G728_16s (int* pSize      );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSize                        Pointer to the output IIR state size value.

Description
This function returns the minimal size of memory to be allocated for proper use of the IIR filter.

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when the pSize  pointer is NULL.

IIR_Init_G728
Initializes the IIR state structure.

Syntax
QplStatus qplsIIR16sInit_G728_16s (QplsIIRState16s_G728_16s* pMem       );

Include Files
qplsc.h

                                                                                           677
---------------------Page 678---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

Domain Dependencies
Headers: qplcore.h , qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pMem                          Pointer to the memory allocated for IIR filter.

Description
This function initializes the IIR state structure using the given memory block.

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when the  pMem  pointer is NULL.

IIR_G728
Applies IIR filter to multiple samples.

Syntax
QplStatus qplsIIR16s_G728_16s (const Qpl16s* pCoeffs, const Qpl16s* pSrcQntSpeech,
Qpl16s* pDstWgtSpeech, int len, QplsIIRState16s_G728_16s* pMem        );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h , qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pCoeffs                       Pointer to the filter coefficients vector [20]: b0, ..., b9, a0, ..., a9 (in
                              Q14).
pSrcQntSpeech                 Pointer to the source vector [len].

pDstWgtSpeech                 Pointer to the destination vector [len].

len                           The number of source and destination samples.

pMem                          Pointer to the IIR filter state structure.

Description
This function calculates the synthesized speech output by filtering the input quantized speech through the IIR
filter one at a time according to the transfer function:

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointer is NULL.

   678
---------------------Page 679---------------------

                                                                       Speech Coding Functions  9 

SynthesisFilterGetStateSize_G728
Gets the size of synthesis filter state structure.

Syntax
QplStatus qplsSynthesisFilterGetStateSize_G728_16s (int* pSize       );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSize                        Pointer to the output size value of the synthesis filter state
                             structure.

Description
This function returns the minimal size of memory to be allocated for proper use of the synthesis filter.

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when the pSize  pointer is NULL.

SynthesisFilterInit_G728
Initializes the synthesis filter state structure.

Syntax
QplStatus qplsSynthesisFilterInit_G728_16s (QplsSynthesisFilterState_G728_16s* pMem         );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pMem                         Pointer to the memory allocated for synthesis filter.

Description
This function initializes synthesis filter state structure using the given memory block.

Return Values

qplStsNoErr                       Indicates no error.

                                                                                           679
---------------------Page 680---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

qplStsNullPtrErr                  Indicates an error when the pMem  pointer is NULL.

SyntesisFilter_G728
Applies the synthesis filter to multiple samples.

Syntax
QplStatus qplsSyntesisFilterZeroInput_G728_16s (const Qpl16s* pCoeffs, Qpl16s*
pSrcDstExc, Qpl16s excSfs, Qpl16s* pDstSpeech, Qpl16s* pSpeechSfs,
QplsSynthesisFilterState_G728_16s* pMem    );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pCoeffs                      Pointer to the filter coefficients vector [51]: a0 , ..., a50 in Q14
                             format.
pSrcDstExc                   Pointer to the input/output gain-scaled excitation vector [5].

excSfs                       The input scale of the previous gain-scaled excitation vector.

pDstSpeech                   Pointer to the output quantized speech vector [5].

pSpeechSfs                   The output scale of the quantized speech vector.

pMem                         Pointer to the synthesis filter state structure.

Description
This function computes the decoded speech vector as the sum of the zero-input response and the zero-state
response of the synthesis filter according to the transfer function:

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointer is NULL.

CombinedFilterGetStateSize_G728
Gets the size of combined filter state structure.

Syntax
QplStatus qplsCombinedFilterGetStateSize_G728_16s (int* pSize       );

Include Files
qplsc.h

   680
---------------------Page 681---------------------

                                                                      Speech Coding Functions  9 

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSize                        Pointer to the output size value of the combined filter state
                             structure.

Description
This function returns the minimal size of memory to be allocated for proper use of the combined filter.

Return Values

qplStsNoErr                      Indicates no error.

qplStsNullPtrErr                 Indicates an error when the pSize  pointer is NULL.

CombinedFilterInit_G728
Initializes the combined filter state structure.

Syntax
QplStatus qplsCombinedFilterInit_G728_16s (QplsCombinedFilterState_G728_16s* pMem        );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pMem                         Pointer to the memory allocated for the combined filter.

Description
This function initializes combined filter state structure using the given memory block.

Return Values

qplStsNoErr                      Indicates no error.

qplStsNullPtrErr                 Indicates an error when the pMem  pointer is NULL.

CombinedFilter_G728
Applies the combined filter to multiple samples.

Syntax
QplStatus qplsCombinedFilterZeroInput_G728_16s(const Qpl16s* pSyntCoeff, const Qpl16s*
pWgtCoeff, Qpl16s* pDstWgtZIR, QplsCombinedFilterState_G728_16s* pMem      );

                                                                                          681
---------------------Page 682---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

QplStatus qplsCombinedFilterZeroState_G728_16s(const Qpl16s* pSyntCoeff, const Qpl16s*
pWgtCoeff, Qpl16s* pSrcDstExc, Qpl16s excSfs, Qpl16s* pDstSpeech, Qpl16s* pSpeechSfs,
QplsCombinedFilterState_G728_16s* pMem     );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h , qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSyntCoeff                    Pointer to the filter coefficients vector [50]: a1, ..., a50 in Q14
                              format.
pWgtCoeff                     Pointer to the filter coefficients vector [20]: B1 , ..., B10, A1 , ..., A10
                              in Q14 format.
pSrcDstExc                    Pointer to the output gain-scaled excitation vector [5].

excSfs                        The input scale of the previous gain-scaled excitation vector.

pDstWgtZIR                    Pointer to the output zero input response vector [5] of the combined
                              filter.
pDstSpeech                    Pointer to the output quantized speech vector [5].

pSpeechSfs                    The output scale of the quantized speech vector.

pMem                          Pointer to the combined filter state structure.

Description
qplsCombinedFilterZeroInput_G728    . This function calculates the zero-input response of the combined
filter by superposing two filters, specifically, the 50s-order synthesis filter and the 10s-order IIR filter
according to the transfer function:

qplsCombinedFilterZeroState_G728_16s     . This function first performs filtering of the gain-scaled
excitation vector through the zero-state combined filter (see the above function). The memory of combined
filter is then updated by adding zero-state responses of the synthesis and the IIR filters which it is combined
of. The quantized speech output vector is obtained as a by-product of the memory updates.

Return Values

qplStsNoErr                        Indicates no error.

qplStsNullPtrErr                   Indicates an error when one of the specified pointer is NULL.

PostFilterGetStateSize_G728
Gets the size of the post filter state structure.

Syntax
QplStatus qplsPostFilterGetStateSize_G728_16s (int* pSize        );

Include Files
qplsc.h

   682
---------------------Page 683---------------------

                                                                      Speech Coding Functions  9 

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSize                        Pointer to the output size value of the post filter state structure.

Description
This function returns the minimal size of memory to be allocated for proper use of the post filter.

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when the pSize pointer is NULL.

PostFilterInit_G728
Initializes the post filter state structure.

Syntax
QplStatus qplsPostFilterInit_G728_16s (QplsPostFilterState_G728_16s* pMem       );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pMem                         Pointer to the memory allocated for the post filter.

Description
This function initializes the post filter state structure using the given memory block.

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when the pMem pointer is NULL.

PostFilter_G728
Applies the post filter to multiple samples.

Syntax
QplStatus qplsPostFilter_G728_16s (Qpl16s gl, Qpl16s glb, Qpl16s kp, Qpl16s tiltz,
const Qpl16s* pCoeffs, const Qpl16s* pSrc, Qpl16s* pDst, QplsPostFilterState_G728_16s*
pMem);

                                                                                          683
---------------------Page 684---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h , qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

gl                            The LTP scaling factor.

glb                           The LTP product term.

kp                            The LTP lag, pitch period of the current frame.

tiltz                         The STP tilt-compensation coefficient.

pCoeffs                       Pointer to the post filter coefficients vector [20]: B1, ..., B10, A1 , ...,
                              A10.
pSrc                          Pointer to the input speech vector [5]; elements -kp ,...,-1 must be
                              given as memory of the LTP filter.
pDst                          Pointer to the output post-filtered speech vector [5].

pMem                          Pointer to the post filter state structure.

Description
This function performs filtering of input samples by one at a time according to the transfer function that is
comprised of LTP filter and STP filter parts:

Return Values

qplStsNoErr                        Indicates no error.

qplStsNullPtrErr                   Indicates an error when one of the specified pointer is NULL.

PostFilterAdapterGetStateSize_G728
Gets the size of the QplsPostFilterAdapterState
structure to be used.

Syntax
QplStatus qplsPostFilterAdapterGetStateSize_G728 (int* pSize        );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h , qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

   684
---------------------Page 685---------------------

                                                                     Speech Coding Functions  9 

Parameters

pSize                       Pointer to the output QplsPostFilterAdapterState  structure size
                            value.

Description

This function returns the minimal size of memory to be allocated for proper use of the postfilter adapter.

Return Values

qplStsNoErr                      Indicates no error.

qplStsNullPtrErr                 Indicates an error when the pSize pointer is NULL.

PostFilterAdapterStateInit_G728
Initializes the QplsPostFilterAdapterState
structure.

Syntax
QplStatus qplsPostFilterAdapterStateInit_G728( QplsPostFilterAdapterState* pMem      );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pMem                        Pointer to the memory allocated for postfilter adapter.

Description
This function initializes the QplsPostFilterAdapterState structure using the memory block given by
pMem.

Return Values

qplStsNoErr                      Indicates no error.

qplStsNullPtrErr                 Indicates an error when the pMem pointer is NULL.

LPCInverseFilter_G728
Computes the LPC prediction residual.

Syntax
QplStatus qplsLPCInverseFilter_G728_16s (const Qpl16s* pSrcSpeech, const Qpl16s*
pCoeffs, Qpl16s* pDstResidual, QplsPostFilterAdapterState_G728* pMem     );

Include Files
qplsc.h

                                                                                         685
---------------------Page 686---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

Domain Dependencies
Headers: qplcore.h , qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcSpeech                    Pointer to the quantized speech buffer [-240...0...4].
                              Pointer to the 10 th
pCoeffs                                          -order LPC filter coefficients [10].

pDstResidual                  Pointer to the LPC prediction residual vector [-140...0...99].

pMem                          Pointer to the postfilter adapter memory.

Description
This function computes the LPC prediction residual vector for the current decoded speech vector. The 10th-
order LPC inverse filter implements the following function:

Return Values

qplStsNoErr                        Indicates no error.

qplStsNullPtrErr                   Indicates an error when at least one of the specified pointers is
                                   NULL.

PitchPeriodExtraction_G728
Extracts pitch period from the LPC prediction residual.
QplStatus qplsPitchPeriodExtraction_G728_16s (const Qpl16s* pSrcResidual, int*
pPitchPeriod, QplsPostFilterAdapterState_G728* pMem       );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h , qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcResidual                  Pointer to the LPC undecimated residual vector d[-140,99].

pPitchPeriod                  Pointer to the pitch period of the previous frame.

pMem                          Pointer to the postfilter adapter memory.

Description
The function extracts the pitch period once per frame. It assumes that the input vector contains the LPC
prediction residual of previous frames (samples [-139,80]) and of four vectors of the current frame stored,
respectively, in elements [80,84], [85,89], [90,94], and [95,99]. The prediction history for the previous
frame is stored in the elements [-139,80].

   686
---------------------Page 687---------------------

                                                                     Speech Coding Functions  9 

Return Values

qplStsNoErr                      Indicates no error.

qplStsNullPtrErr                 Indicates an error when one of the specified pointer is NULL.

WinHybridGetStateSize_G728
Gets the size of hybrid windowing module state
structure.

Syntax
QplStatus qplsWinHybridGetStateSize_G728_16s (int M, int L, int N, int DIM, int*
pSize);

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

M                           The input length of the LPC window.

L                           The input adaptation cycle size in samples.

N                           The input number of non-recursive window samples.

DIM                         The input block size used for block scaling of the input speech by
                            the function qplsWinHybrid_G728 .
pSize                       Pointer to the output size value of the hybrid windowing module
                            state structure.

Description
This function returns the minimal size of memory to be allocated for proper use of the hybrid windowing
module according to the given window parameters.

Return Values

qplStsNoErr                      Indicates no error.

qplStsNullPtrErr                 Indicates an error when the pSize pointer is NULL.

qplStsSizeErr                    Indicates an error when L, M or N are less than or equal to zero.

WinHybridInit_G728
Initializes the hybrid windowing module state
structure.

Syntax
QplStatus qplsWinHybridInit_G728_16s (const Qpl16s* pWinTab, int M, int L, int N, int
DIM, Qpl16s a2L, QplsWinHybridState_G728_16s* pMem    );

                                                                                         687
---------------------Page 688---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pWinTab                     The input vector of windowing coefficients.

M                           The input length of LPC window. Must be not less than 10.

L                           The input adaptation cycle size in samples.

N                           The input number of non-recursive window samples.

a2L                         The  a2L multiple used in calculation of the recursive component in
                            hybrid windowing module.
N                           The input number of non-recursive window samples.

Description
This function initializes the hybrid windowing module state structure using the given memory block. The
recursive component and the previous speech samples are zeroed.

Return Values

qplStsNoErr                      Indicates no error.

qplStsNullPtrErr                 Indicates an error when the pMem pointer is NULL.

WinHybrid_G728
Applies the hybrid windowing.

Syntax
QplStatus qplsWinHybridBlock_G728_16s(Qpl16s bfi, const Qpl16s* pSrc, const Qpl16s*
pSrcSfs, Qpl16s* pDst, QplsWinHybridState_G728_16s* pMem     );
QplStatus qplsWinHybrid_G728_16s(Qpl16s bfi, const Qpl16s* pSrc, Qpl16s* pDst,
QplsWinHybridState_G728_16s* pMem   );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

bfi                         The input bad frame indicator: “1” indicates an invalid frame, any
                            other value indicates a valid frame.
pSrc                        Pointer to the input speech vector [20].

   688
---------------------Page 689---------------------

                                                                       Speech Coding Functions  9  

pSrcSfs                      Pointer to the input vector [5] of scale factors for elements of the
                             input speech vector. Each element of the  pSrcSfs  vector may
                             specify a separate scale factor for a block of input speech vector
                             elements. Thus,  pSrcSfs [0] is the scale factor of the elements
                             pSrc [0],..pSrc[DIM-1]; pSrcSfs[1] is the scale factor for
                             pSrc [ DIM],..pSrc[2*DIM-1], and so on, where  DIM is a block length
                             that must be defined by the function WinHybridInit_G728.
pDst                         Pointer to the output reflection coefficients vector [M+1], where M is
                             the length of the LPC window defined in the function 
                             WinHybridInit_G728.
pMem                         Pointer to the post filter state structure.

Description
This function first applies the window to the input speech vector and then calculates the autocorrelation
coefficients needed in LPC analysis by the formula:

where the recursive component of adaptation cycle is calculated as follows:

The recursive part is calculated using the data calculated in previous adaptation cycle and stored in module
memory.
A white noise correction is applied to autocorrelation coefficients by increasing the energy as follows:
rm(0) = 257/256*rm(0)
The recursive component and previous speech samples are stored in the module memory and may be used
in the next adaptation cycle.
If the bad frame indicator is on, then only 10 autocorrelation coefficients are calculated and output.

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointer is NULL.

LevinsonDurbin_G728
Calculates LP coefficients from the autocorrelation
coefficients.

Syntax
QplStatus qplsLevinsonDurbin_G728_16s_Sfs(const Qpl16s* pSrcAutoCorr, int order,
Qpl16s* pDstLPC, Qpl16s* pDstRC1, Qpl16s* pDstResidualEnergy, Qpl16s* pDstScaleFactor          );
QplStatus qplsLevinsonDurbin_G728_16s_ISfs(const Qpl16s* pSrcAutoCorr, int numSrcLPC,
int order, Qpl16s* pSrcDstLPC, Qpl16s* pSrcDstResidualEnergy, Qpl16s*
pSrcDstScaleFactor  );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h , qpls.h

                                                                                            689
---------------------Page 690---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcAutoCorr                  Pointer to the input autocorrelation coefficients vector [order+1].

order                         The input number of LP coefficients to calculate.

numSrcLPC                     The input number of pre-calculated LPCs.

pDstLPC                       Pointer to the output LPC vector [ order].

pDstRC1                       Pointer to the first output RC vector.

pSrcDstLPC                    Pointer to the input/output LPC vector [order].

pDstResidualEnergy            Pointer to the output residual energy.

pSrcDstResidualEnergy         Pointer to the input/output residual energy of the pre-calculated
                              LPC.
pDstScaleFactor               Pointer to the output scale factor of the LPC vector.

pSrcDstScaleFactor            Pointer to the input scale factor of the pre-calculated LPC and the
                              output scale factor of the output LPC vector.

Description

qplsLevinsonDurbin_G728_16s_Sfs    . This function may be used to calculate LP coefficients by solving the
following set of linear equations:

where ai, i = 0,1,...,order-1    are the LP coefficients to be calculated and stored in the output LPC
vector. The description of the Levinson-Durbin algorithm used by this function may be found in the
description of the function LevinsonDurbin_G729.
Both qplsLevinsonDurbin_G728    and qplsLevinsonDurbin_G729B    calculate mathematically the same, but
not bit exact LPCs. The difference is that the qplsLevinsonDurbin_G729B function outputs LPCs in Q12
format, while the qplsLevinsonDurbin_G728  function automatically rescales the LPCs if overflow occurs.
qplsLevinsonDurbin_G728_16s_Isfs    . This function may be used to continue Levinson-Durbin recursion
for bigger order. The LPCs, their scale factor and the residual energy of the previous recursion and the
additional autocorrelation coefficients are used to resume recursion.

Return Values

qplStsNoErr                        Indicates no error.

qplStsNullPtrErr                   Indicates an error when one of the specified pointer is NULL.

qplStsRangeErr                     Indicates an error when order  is less than or equal to zero, or
                                   when  order < numSrcLPC   for the in-place function.

CodebookSearch_G728
Searches the codebook for the best code vector.

Syntax
QplStatus qplsCodebookSearch_G728_16s(const Qpl16s* pSrcCorr, const Qpl16s* pSrcEnergy,
int* pDstShapeIdx, int* pDstGainIdx, Qpl16s* pDstCodebookIdx, QplSpchBitRate rate           );

   690
---------------------Page 691---------------------

                                                                     Speech Coding Functions  9 

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcCorr                    Pointer to the input vector [5] of time-reversed convolution of the
                            target signal.
pSrcEnergy                  Pointer to the input vector [128] of the energy of convolved shape
                            codevector.
pDstShapeIdx                Pointer to the output best 7-bit shape codebook index.

pDstGainIdx                 Pointer to the output best 3-bit gain codebook index.

pDstCodebookIdx             Pointer to the output best codebook index to be transmitted.

rate                        Input coding bit rate.

Description
This function implements the “Error calculator and best codebook index selector” block used to search
through the gain codebook and the shape codebook for the best combination of the gain and shape codebook
indexes.

Return Values

qplStsNoErr                      Indicates no error.

qplStsNullPtrErr                 Indicates an error when one of the specified pointer is NULL.

QplStsRangeErr                   Indicates an error when rate is not one of the acceptable
                                 values QPL_SPCHBR_16000  , QPL_SPCHBR_12800 or
                                 QPL_SPCHBR_9600   for the 16, 12.8 or 9.6 Kbit/s coding bit rates,
                                 respectively.

CodebookSearchTCQ_G728
Performs codebook search by trellis-coded
quantization.

Syntax
QplStatus qplsCodebookSearchTCQ_G728_16s8u (const Qpl16s pSrc[5], const Qpl16s
pSrcLPC[10], Qpl8u pDst[5], Qpl16s pSrcDstWindow[20], Qpl16s pSrcDstResidual[8],
Qpl32s* pSrcDstBestNode, Qpl32s_EC_Sfs invGain, Qpl32s_EC_Sfs excGain      );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

                                                                                         691
---------------------Page 692---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

Parameters

pSrc                          Pointer to the input speech frame vector.

pSrcLPC                       Pointer to the LPC coefficients vector.

pDst                          Pointers to the output vector containing the indeces of the “best
                              path”.
pSrcDstWindow                 Pointer to the synthesis filter hybrid window vector.

pSrcDstResidual               Pointer to the input/output quantized residuals vector.

pSrcDstBestNode               Pointer to input/output trellis survivor node value.

invGain                       Inverted gain scaled value, structure with gain value and its scale.

excGain                       Linear excitation gain scaled value.

Description
The function performs codebook search by the trellis-coded quantization (TCQ) for given gains. TCQ trellis is
parsed for best path and survivor node. For every next stage one of the two incoming branches is selected
and marked as 'new' survivor. The final trellis survivor node and best path indexes are stored in
pSrcDstBestNode   and pDst respectively. For detailed description of the TCQ see [ITU728] Annex J, clause
4.1.1.

Return Values

qplStsNoErr                        Indicates no error.

qplStsNullPtrErr                   Indicates an error when one of the specified pointers is NULL.

ImpulseResponseEnergy_G728
Implements shape codebook vector convolution and
energy calculation.

Syntax
QplStatus qplsImpulseResponseEnergy_G728_16s(const Qpl16s* pSrcImpResp, Qpl16s*
pDstEnergy );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h , qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcImpResp                   Pointer to the input impulse response vector [5] of the synthesis
                              and weighted filter.
pDstEnergy                    Pointer to the output energy vector [128] of the convolved shape
                              codevector.

Description
This function implements the “Shape codevector convolution and energy calculator” block used to calculate
the energy of the convolved shape codevector.

   692
---------------------Page 693---------------------

                                                                     Speech Coding Functions  9 

Return Values

qplStsNoErr                      Indicates no error.

qplStsNullPtrErr                 Indicates an error when one of the specified pointer is NULL.

Voice Enhancement Functions
This section describes the Intel QPL functions for echo control, noise removal, automatic audio level control.

Echo Canceller Functions
The functions described in this section implement building blocks that can be used to create an acoustic and
network echo cancellers compliant to the appropriate ITU-T Recommendations: G.168-2000, and G.167
(superseded by G.161, P.340).

SubbandProcessGetSize
Calculates size of the subband process state structure.

Syntax
QplStatus qplsSubbandProcessGetSize_32f(int order, int windowLen, int* pStateSize, int*
pInitBufSize, int* pBufSize  );
QplStatus qplsSubbandProcessGetSize_16s(int order, int windowLen, int* pStateSize, int*
pInitBufSize, int* pBufSize  );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters
                             Number of subbands is equal to 2order  - 1
order                                                                 + 1.

windowLen                    Length of window.

pStateSize                   Pointer to the computed value of buffer size for the subband process
                             state structure.
pInitBufSize                 Pointer to the computed buffer size for use in the initialization
                             function.
pBufSize                     Pointer to the computed size of work buffer.

Description
These functions calculate the sizes of memory buffers required for the functions SubbandAnalysis and 
SubbandAnalysis to operate.

Return Values

qplStsNoErr                      Indicates no error.

                                                                                          693
---------------------Page 694---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

qplStsNullPtrErr                  Indicates an error when one of the specified pointers is NULL.

qplStsBadArgErr                   Indicates an error when order is less than or equal to zero or
                                  when  windowLen  is not divisible by 2order.

SubbandProcessInit
Initializes the subband process state structure.

Syntax
QplStatus qplsSubbandProcessInit_32f(QplsSubbandProcessState_32f* pState, int order,
int frameSize, int windowLen, const Qpl32f* pWindow, Qpl8u* pInitBuf       );
QplStatus qplsSubbandProcessInit_16s(QplsSubbandProcessState_16s* pState, int order,
int frameSize, int windowLen, const Qpl32s* pWindow, Qpl8u* pInitBuf       );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pState                       Pointer to the subband process state structure.

order                        Number of subbands is equal to 2 order  - 1 + 1.

frameSize                    Size of frame. Must be in range from 1 to 2order.

windowLen                    Window length.

pWindow                      Pointer to window coefficients . May be NULL if the order, frameSize
                             and windowLen  are equal to one of the predefined sets: (5, 24, 128)
                             or (6, 44, 256). In this case the predefined window is used.
pInitBuf                     Pointer to the initialized buffer.

Description
These functions initialize the state structure for the subband process in the external buffer. The size of this
buffer must be calculated by the function SubbandProcessGetSize beforehand. The functions 
SubbandAnalysis and SubbandAnalysis use this state structure in their operation.

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointers is NULL.

qplStsBadArgErr                   Indicates an error when order is less or equal to zero, or when
                                  windowLen  is not divisible by 2order, or when frameSize is less
                                  than or equal to 0, or when pWindow is NULL and the
                                  appropriate internal window does not exist.

SubbandAnalysis
Decomposes a frame into a complex subband
representation.

   694
---------------------Page 695---------------------

                                                                     Speech Coding Functions  9 

Syntax
QplStatus qplsSubbandAnalysis_32f32fc(const Qpl32f* pSignal, Qpl32fc* pSubbands,
QplsSubbandProcessState_32f* pState, Qpl8u* pBuf    );
QplStatus qplsSubbandAnalysis_16s32sc_Sfs(const Qpl16s* pSignal, Qpl32sc* pSubbands,
QplsSubbandProcessState_16s* pState, int scaleFactor, Qpl8u* pBuf     );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pState                      Pointer to the subband process state structure.

pSignal                     Pointer to the source vector. Vector length must be equal to the
                            frame size which was used to initialize the subband process
                            algorithm by the function SubbandProcessInit.
pSubbands                   Pointer to the resulting subband vector. Vector length is equal to the
                            number of subbands calculated as 2 order-1 + 1, where order  is
                            specified in the function SubbandProcessInit.
pBuf                        Pointer to the work buffer of size specified by the parameter
                            pBufSize  in the qplsSubbandProcessGetSize function. This buffer
                            must be allocated by the user.

Description
These functions perform subband analysis using the oversampled DFT filter bank.
Computation steps are as follows:
1) Calculate the weighted sum as

for j = 0,..., fftLen - 1, fftLen = 2 order.
Here x denotes the input sample buffer of size windowLen.
2) Calculate and return the Fast Fourier Transform of X.

Return Values

qplStsNoErr                      Indicates no error.

qplStsNullPtrErr                 Indicates an error when one of the specified pointers is NULL.

SubbandSynthesis
Reconstructs frame from a complex subband
representation.

Syntax
QplStatus qplsSubbandSynthesis_32fc32f(const Qpl32fc* pSubbands, Qpl32f* pSignal,
QplsSubbandProcessState_32f* pState, Qpl8u* pBuf    );

                                                                                         695
---------------------Page 696---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

QplStatus qplsSubbandSynthesis_32sc16s_Sfs(const Qpl32sc* pSubbands, Qpl16s* pSignal,
QplsSubbandProcessState_16s* pState, int scaleFactor, Qpl8u* pBuf       );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pState                       Pointer to the subband process state structure.

pSubbands                    Pointer to the resulting subband vector. Vector length is equal to the
                             number of subbands calculated as 2 order  - 1 + 1, where order is
                             specified in the function SubbandProcessInit.
pSignal                      Pointer to the destination signal vector. Vector length is equal to
                             frame size which was used to initialize the subband process
                             algorithm by the functionSubbandProcessInit.
pBuf                         Pointer to the work buffer of size computed by the function
                             qplsSubbandProcessGetSize (returned via  pBufSize  parameter).

Description
These functions perform subband synthesis using the oversampled DFT filter bank.
Computation steps are as follows:
1) Calculates IX as the inverse Fast Fourier Transform of the input subband sample X. Transform length is
fftLen = 2order.
2) Shifts internal buffer by frameSize and sets to zero the undefined buffer values.
3) Updates buffer values as
x(j):= x(j) + window( j) * IX(j % fftLen),
for j = 0, ..., windowLen - 1
4) Returns most recent frameSize samples from the buffer.

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointers is NULL.

SubbandControllerGetSize_EC
Calculates size of the subband controller state
structure.

Syntax
QplStatus qplsSubbandControllerGetSize_EC_32f(int numSubbands, int frameSize, int
numSegments, qplECFrequency sampleFreq, int* pSize     );
QplStatus qplsSubbandControllerGetSize_EC_16s(int numSubbands, int frameSize, int
numSegments, qplECFrequency sampleFreq, int* pSize     );

   696
---------------------Page 697---------------------

                                                                    Speech Coding Functions  9 

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

numSubbands                 Number of subbands.

frameSize                   Size of the frame.

numSegments                 Number of segments.

sampleFreq                  Sample frequency.

pSize                       Pointer to the computed buffer size value.

Description
These functions calculate the sizes of memory required for the function SubbandControllerUpdate_EC and 
SubbandController_EC to operate.

Return Values

qplStsNoErr                      Indicates no error.

qplStsNullPtrErr                 Indicates an error when pSize pointer is NULL.

qplStsBadArgErr                  Indicates an error when numSubbands is less than or equal to
                                 zero, or numSegment is less than or equal to zero, or frameSize
                                 is less than or equal to zero.

SubbandControllerInit_EC
Initializes the subband controller state structure.

Syntax
QplStatus qplsSubbandControllerInit_EC_32f(QplsSubbandControllerState_EC_32f* pState,
int numSubbands, int frameSize, int numSegments, qplECFrequency sampleFreq     );
QplStatus qplsSubbandControllerInit_EC_16s(QplsSubbandControllerState_EC_16s* pState,
int numSubbands, int frameSize, int numSegments, qplECFrequency sampleFreq     );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pState                      Pointer to the subband controller state structure.

numSubbands                 Number of subbands.

                                                                                        697
---------------------Page 698---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

frameSize                   Size of the frame.

numSegments                 Number of segments.

sampleFreq                  Sample frequency.

Description
These functions initialize the state structure and the internal data of the subband controller algorithm. The
functions SubbandControllerUpdate_EC and SubbandController_EC use this memory in their operation.

Return Values

qplStsNoErr                      Indicates no error.

qplStsNullPtrErr                 Indicates an error when one of the specified pointers is NULL.

qplStsBadArgErr                  Indicates an error when numSubbands is less than or equal to
                                 zero, or numSegments is less than or equal to zero, or frameSize
                                 is less than or equal to zero.

SubbandControllerUpdate_EC
Updates controller state and returns the step sizes.

Syntax
QplStatus qplsSubbandControllerUpdate_EC_32f(const Qpl32f* pSrcRin, const Qpl32f*
pSrcSin, const Qpl32fc** ppSrcRinSubbandsHistory, const Qpl32fc* pSrcSinSubbands,
double* pDstStepSize, QplsSubbandControllerState_EC_32f* pState     );
QplStatus qplsSubbandControllerUpdate_EC_16s(const Qpl16s* pSrcRin, const Qpl16s*
pSrcSin, const Qpl32sc** ppSrcRinSubbandsHistory, const Qpl32sc* pSrcSinSubbands,
QplAECScaled32s* pDstStepSize, QplsSubbandControllerState_EC_16s* pState      );
QplStatus qplsSubbandAPControllerUpdate_EC_32f(Qpl32fc** ppSrcRinSubbandsHistory, const
Qpl32fc* pSrcSinSubbands, double* pDstStepSize, Qpl32f learningRate,
QplsSubbandControllerState_EC_32f* pState   );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pState                      Pointer to the subband controller state structure.

pSrcRin                     Pointer to receive-in signal frame.

pSrcSin                     Pointer to send-in signal frame. Frame size is specified in the
                            function SubbandControllerInit_EC.
ppSrcRinSubbandsHistory     Pointer to an array of pointers to the most recent receive-in blocks.
                            Size of the array is equal to numSegments specified in the function 
                            SubbandControllerInit_EC.

   698
---------------------Page 699---------------------

                                                                     Speech Coding Functions  9 

pSrcSinSubbands              Pointer to subband representation of send-in signal frame (or NULL).
                             Size of the array is equal to numSubbands specified in the function 
                             SubbandControllerInit_EC.
pDstStepSize                 Pointer to the vector of step sizes. Vector length is equal to
                             numSubbands  specified in the function SubbandControllerInit_EC.
learningRate                 Learning rate parameter, positive value 0-1.

Description
These functions update the internal state of the subband controller and return the step size values for further
use in the adaptation of the coefficients.

Return Values

qplStsNoErr                      Indicates no error.

qplStsNullPtrErr                 Indicates an error when any of the specified pointers is NULL.

qplStsRangeErr                   Indicates an error when learningRate  is negative, or greater
                                 than 1.

SubbandController_EC
Updates filter coefficients and returns output gain
coefficients.

Syntax
QplStatus qplsSubbandController_EC_32f(const Qpl32fc* pSrcAdaptiveFilterErr, const
Qpl32fc* pSrcFixedFilterErr, Qpl32fc** ppDstAdaptiveCoefs, Qpl32fc** ppDstFixedCoefs,
Qpl32f* pDstSGain, QplsSubbandControllerState_EC_32f* pState     );
QplStatus qplsSubbandController_EC_16s(const Qpl32sc* pSrcAdaptiveFilterErr, const
Qpl32sc* pSrcFixedFilterErr, Qpl32sc** pDstpAdaptiveCoefs, Qpl32sc** ppFixedCoefs,
Qpl32s* pDstSGain, QplsSubbandControllerState_EC_16s* pState     );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pState                       Pointer to the subband state structure.

pSrcAdaptiveFilterErr        Pointer to the adaptive filter error vector. Vector length is equal to
                             numSubbands , specified in the function SubbandControllerInit_EC.
pSrcFixedFilterErr           Pointer to the fixed filter error vector. Vector length is equal to
                             numSubbands .
ppDstAdaptiveCoefs           Pointer to an array of pointers to the adaptive filter coefficients
                             vectors. Size of the array is equal to numSegments specified in the
                             function SubbandControllerInit_EC.
ppDstFixedCoefs              Pointer to an array of pointers to the fixed filter coefficients vectors.
                             Size of the array is equal to numSegments specified in the function 
                             SubbandControllerInit_EC.

                                                                                          699
---------------------Page 700---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

pDstSGain                      Pointer to the send gain coefficient.

Description

These functions compare powers of adaptive filter error and fixed filter error and track changes of adaptive
filter coefficients power.
If the adaptive filter has a significantly smaller error and is stable (which is indicated by coefficients power
changing slowly), its coefficients are copied to the fixed filter. This case corresponds to “no double-talk”
mode.
If the fixed filter has a significantly smaller error, its coefficients are copied to the adaptive filter. This case
corresponds to the double-talk mode.
Send gain coefficient calculation (non-linear processor technology) is based on presence of the double-talk
mode and changes of receive-in and send-in signal powers.
The subband controller state structure pState must be initialized by the function SubbandControllerInit_EC
beforehand.

Return Values

qplStsNoErr                         Indicates no error.

qplStsNullPtrErr                    Indicates an error when one of the specified pointers is  NULL .

SubbandControllerReset_EC
Resets the subband controller state.

Syntax
QplStatus qplsSubbandControllerReset_EC_32f(QplsSubbandControllerState_EC_32f* pState               );
QplStatus qplsSubbandControllerReset_EC_16s(QplsSubbandControllerState_EC_16s* pState               );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h , qplvm.h , qpls.h
Libraries: qplcore.lib, qplvm.lib , qpls.lib

Parameters

pState                         Pointer to the subband controller state structure.

Description
These functions reset the subband controller state. You can use these functions after an interruption in
adaptation process occurred.

Return Values

qplStsNoErr                         Indicates no error.

qplStsNullPtrErr                    Indicates an error when the   pState  pointer is NULL.

   700
---------------------Page 701---------------------

                                                                     Speech Coding Functions  9 

SubbandControllerDTGetSize_EC
Calculates the size of the subband DT controller state
structure.

Syntax
QplStatus qplsSubbandControllerDTGetSize_EC_16s(int numSubbands, int frameSize, int
numSegments, qplPCMFrequency sampleFreq, int* pSize    );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

numSubbands                 Number of subbands.

frameSize                   Size of the frame.

numSegments                 Number of segments.

sampleFreq                  Sample frequency.

pSize                       Pointer to the computed buffer size value.

Description
This function calculates the size of memory required for the state structure and the internal data of the
subband DT controller algorithm.

Return Values

qplStsNoErr                      Indicates no error.

qplStsNullPtrErr                 Indicates an error when pSize pointer is NULL.

qplStsBadArgErr                  Indicates an error when numSubbands  is less than or equal to
                                 zero, or numSegment is less than or equal to zero, or frameSize
                                 is less than or equal to zero.

SubbandControllerDTInit_EC
Initializes the subband DT controller state structure.

Syntax
QplStatus qplsSubbandControllerDTInit_EC_16s(QplsSubbandControllerDTState_EC_16s*
pState, int numSubbands, int frameSize, int numSegments, qplPMCFrequency sampleFreq       );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

                                                                                         701
---------------------Page 702---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

Parameters

pState                       Pointer to the subband controller DT state structure to be created.

numSubbands                  Number of subbands.

frameSize                    Size of the frame.

numSegments                  Number of segments.

sampleFreq                   Sample frequency.

Description

This function initializes the state structure and the internal data of the subband DT controller algorithm. The
size of the required memory must be computed using the function
beforehandSubbandControllerDTGetSize_EC.
This state structure is used by the functions SubbandControllerDT_EC and SubbandControllerDTUpdate_EC.

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when the pointer  pState is NULL.

qplStsBadArgErr                   Indicates an error when  numSubbands  is less than or equal to
                                  zero, or numSegments  is less than or equal to zero, or frameSize
                                  is less than or equal to zero.

SubbandControllerDTReset_EC
Resets the subband DT controller state.

Syntax
QplStatus qplsSubbandControllerDTReset_EC_16s(QplsSubbandControllerState_EC_16s*
pState);

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h , qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pState                       Pointer to the subband controller DT state structure.

Description
This function resets the subband controller state. It can be used after an interruption in adaptation process
occurred.

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when the pointer  pState is NULL.

   702
---------------------Page 703---------------------

                                                                      Speech Coding Functions  9 

SubbandControllerDT_EC
Updates filter coefficients and returns output gain
coefficients.

Syntax
QplStatus qplsSubbandControllerDT_EC_16s(const Qpl32sc* pSrcAdaptiveFilterErr, const
Qpl32sc* pSrcFixedFilterErr, Qpl32sc** ppDstAdaptiveCoefs, Qpl32sc** ppDstFixedCoefs,
Qpl64s* pSrcDstFilterPwr, int* pDstStsAdapt, Qpl64s pwrDelta, int filterUpdateEnabled,
int adaptationEnabled, int startSubband, QplsSubbandControllerDTState_EC_16s* pState        );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pState                       Pointer to state structure of the subband DT controller.

pSrcAdaptiveFilterErr        Pointer to the input adaptive filter error vector. Vector length is
                             equal to numSubbands , specified in the function 
                             SubbandControllerDTInit_EC.
pSrcFixedFilterErr           Pointer to the input fixed filter error vector. Vector length is equal to
                             numSubbands .
ppDstAdaptiveCoefs           Pointer to an array of pointers to the adaptive filter coefficients
                             vectors. Size of the array is equal to numSegments specified in
                             iSubbandControllerDTInit_EC.
ppDstFixedCoefs              Pointer to an array of pointers to the fixed filter coefficients vectors.
                             Size of the array is equal to numSegments specified in 
                             SubbandControllerDTInit_EC.
pSrcDstFilterPwr             Pointer to an input/output power of adaptive filter coefficient.

pDstStsAdapt                 Pointer to output flag which shows the state of the controller.
                             pDstStsAdapt  = -1 - coefficients of the adaptive filter have been
                             copied to the fixed filter;
                             pDstStsAdapt  = 0 - coefficients of the adaptive and fixed filters are
                             not changed;
                             pDstStsAdapt  = 1 - coefficients of the fixed filter have been copied
                             to the fixed filter.
pwrDelta                     Difference between the power of the adaptive filter coefficients of
                             the current frame and the power of the adaptive filter coefficients of
                             the previous frame.
filterUpdateEnabled          Difference between the power of the adaptive filter coefficients of
                             the current frame and the power of the adaptive filter coefficients of
                             the previous frame.
adaptationEnabled            Indicates if an adaptation is enabled or not.

startSubband                 Indicates the number of subband the filtering starts from (0 ≤
                             startSubband  < numSubbands ).

                                                                                          703
---------------------Page 704---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

Description

This function compares powers of the adaptive filter error and fixed filter error, and tracks changes of the
adaptive filter coefficients power.
If the adaptive filter has a significantly smaller error and is stable (which is indicated by coefficients power
changing slowly), its coefficients are copied to the fixed filter. If the fixed filter has a significantly smaller
error or adaptive filter is not stable (which is indicated by coefficients power changing rapidly), its coefficients
are copied to the adaptive filter. Output flag pDstStsAdapt shows if there were conservations or
restorations of the adaptive filter coefficients.
The subband DT controller state structure pState must be initialized by the function 
SubbandControllerDTInit_EC beforehand.

Return Values

qplStsNoErr                        Indicates no error.

qplStsNullPtrErr                   Indicates an error when one of the specified pointers is NULL .

qplStsBadArgErr                    Indicates an error when  startSubband   is less than zero or
                                   greater than or equal to the numSubbands  .

SubbandControllerDTUpdate_EC
Updates the state of the DT controller and returns the
step sizes.

Syntax
QplStatus qplsSubbandControllerDTUpdate_EC_16s(const Qpl32sc** ppSrcRinSubbandsHistory,
const Qpl32sc* pSrcSinSubbands, const Qpl32sc* pSrcFilterErr, Qpl32s_EC_Sfs*
pDstStepSize, int* pIsDT, int* pDisabledNLP, int startSubband,
QplsSubbandControllerDTState_EC_16s* pState      );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h , qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pState                        Pointer to state structure of the subband DT controller.

ppSrcRinSubbandsHistory       Pointer to an array of pointers to the most recent receive-in blocks.
                              Size of the array is equal to numSegments  specified in the function 
                              SubbandControllerDTInit_EC.
pSrcSinSubbands               Pointer to subband representation of send-in signal frame (or  NULL ).
                              Size of the array is equal to numSubbands  specified in the function 
                              SubbandControllerDTInit_EC.
pSrcFilterErr                 Pointer to the input filter error vector. Vector length is equal to
                              numSubbands   specified in iSubbandControllerDTInit_EC.
pDstStepSize                  Pointer to the vector of step sizes. Vector length is equal to
                              numSubbands   specified in SubbandControllerDTInit_EC.
isDT                          Pointer to the indicator that indicates the double-talk condition.

   704
---------------------Page 705---------------------

                                                                       Speech Coding Functions  9 

disabledNLP                  Pointer to the indicator that indicates whether NLP is disable. If it
                             equals 1 - NLP is disabled, if it equals 0 - NLP is not disabled.
startSubband                 Indicates the number of subband the filtering starts from (0 ≤
                             startSubband   < numSubbands ).

Description

This function updates the internal state of the subband DT controller and return the step size values for
further use in the coefficients adaptation process.
The subband DT controller state structure pState must be initialized by the function
qplsSubbandControllerDTInit_EC beforehand.

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointers is NULL.

qplStsBadArgErr                   Indicates an error when startSubband   is less than zero or
                                  greater than or equal to the numSubbands .

ToneDetectGetStateSize_EC
Calculates size of the tone detector state structure.

Syntax
QplStatus qplsToneDetectGetStateSize_EC_16s(qplECFrequency sampleFreq, int* pSize         );
QplStatus qplsToneDetectGetStateSize_EC_32f(qplECFrequency sampleFreq, int* pSize         );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

sampleFreq                   Sample frequency.

pSize                        Pointer to the computed buffer size value.

Description
These functions calculate the size of memory buffers required for the function ToneDetect_EC to operate.

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when the pSize  pointer is NULL.

qplStsRangeErr                    Indicates an error when sampleFreq   is not a valid element of
                                  the enumerated type  QplFrequency  .

                                                                                           705
---------------------Page 706---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

ToneDetectInit_EC
Initializes the tone detector state structure.

Syntax
QplStatus qplsToneDetectInit_EC_16s(QplsToneDetectState_EC_16s* pState, qplECFrequency
sampleFreq);
QplStatus qplsToneDetectInit_EC_32f(QplsToneDetectState_EC_32f* pState, qplECFrequency
sampleFreq);

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pState                      Pointer to the tone detector state structure.

sampleFreq                  Sample frequency.

Description
These functions initialize the tone detector state structure that is used by the functionToneDetect_EC in the
external buffer. Its size must be calculated by the function ToneDetectGetStateSize_EC beforehand.

Return Values

qplStsNoErr                      Indicates no error.

qplStsNullPtrErr                 Indicates an error when pState  pointer is NULL.

qplStsRangeErr                   Indicates an error when sampleFreq  is not a valid element of
                                 the enumerated type  QplFrequency  .

ToneDetect_EC
Detects the signal of 2100 Hz frequency with every
450 ms phase reversal.
QplStatus qplsToneDetect_EC_16s(const Qpl16s* pSignal, int len, int* pResult,
QplsToneDetectState_EC_16s* pState   );
QplStatus qplsToneDetect_EC_32f(const Qpl32f* pSignal, int len, int* pResult,
QplsToneDetectState_EC_32f* pState   );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

   706
---------------------Page 707---------------------

                                                                       Speech Coding Functions  9 

Parameters

pState                       Pointer to the tone detector state structure.

pSignal                      Pointer to signal vector.

len                          Number of samples in signal vector.

pResult                      Pointer to the result value. If the value is not zero, this means that
                             the tone was detected.

Description

These functions apply an IIR band-pass filter centered at 2100 Hz frequency. Functions compare powers of
the signal before and after the filter.
High-level signal after the filter with periodical short blips is considered as the tone detected.

     NOTE
     Detection can occur when summary length of processed signal vectors is equal to or greater than 900
     ms.

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointers is NULL.

qplStsBadArgErr                   Indicates an error when len  is less than or equal to zero.

FullbandControllerGetSize_EC
Calculates size of the fullband controller state
structure.

Syntax
QplStatus qplsFullbandControllerGetSize_EC_32f(int frameSize, int tapLen,
qplECFrequency sampleFreq, int* pSize    );
QplStatus qplsFullbandControllerGetSize_EC_16s(int frameSize, Int tapLen,
qplECFrequency sampleFreq, int* pSize    );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

frameSize                    Size of the frame.

tapLen                       Number of tap values.

sampleFreq                   Sample frequency.

pSize                        Pointer to the computed buffer size value.

                                                                                           707
---------------------Page 708---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

Description
These functions calculate the sizes of memory buffers required for the functions FullbandControllerUpdate_EC
and FullbandController_EC to operate.

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when pSize  pointer NULL.

qplStsBadArgErr                   Indicates an error when frameSize  is less than or equal to
                                  zero, or tapLen is less than or equal to zero.

FullbandControllerInit_EC
Initializes the fullband controller state structure.

Syntax
QplStatus qplsFullbandControllerInit_EC_32f(QplsFullbandControllerState_EC_32f* pState,
int frameSize, int tapLen, qplECFrequency sampleFreq      );
QplStatus qplsFullbandControllerInit_EC_16s(QplsFullbandControllerState_EC_16s* pState,
int frameSize, int tapLen, qplECFrequency sampleFreq      );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pState                       Pointer to the memory buffer required for the fullband controller
                             state structure to be initialized. The size of the memory buffer must
                             be computed by qplsFullbandControllerGetSize_EC function and
                             returned via pSize parameter.
frameSize                    Size of the frame.

tapLen                       Number of tap values.

sampleFreq                   Sample frequency.

Description
These functions initialize in the external buffer the fullband controller state structure used by the functions
The FullbandControllerUpdate_EC and FullbandController_EC. The size of the buffer must be calculated by
the function FullbandControllerGetSize_EC beforehand.

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when pState  pointer is NULL.

qplStsBadArgErr                   Indicates an error when frameSize  is less than or equal to
                                  zero, or tapLen is less than or equal to zero.

   708
---------------------Page 709---------------------

                                                                     Speech Coding Functions  9 

FullbandControllerUpdate_EC
Updates the fullband controller state and returns the
step sizes.

Syntax
QplStatus qplsFullbandControllerUpdate_EC_32f(const Qpl32f* pSrcRin, const Qpl32f*
pSrcSin, Qpl32f* pDstStepSize, QplsFullbandControllerState_EC_32f* pState      );
QplStatus qplsFullbandControllerUpdate_EC_16s(const Qpl16s* pSrcRin, const Qpl16s*
pSrcSin, QplAECScaled32s* pDstStepSize, QplsFullbandControllerState_EC_16s* pState       );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pState                      Pointer to the fullband controller state structure.

pSrcRin                     Pointer to the receive-in signal history. The history length is tapLen
                            + frameSize , where tapLen  and frameSize are specified in the
                            function FullbandControllerInit_EC.
pSrcSin                     Pointer to the send-in signal frame. The frame size is specified in
                            the function FullbandControllerInit_EC.
pDstStepSize                Pointer to the vector of step sizes. Vector length is equal to
                            frameSize  specified in the function FullbandControllerInit_EC.

Description
These functions update the internal state of fullband controller and return the step size values for use in the
coefficients adaptation process.

Return Values

qplStsNoErr                      Indicates no error.

qplStsNullPtrErr                 Indicates an error when one of the specified pointers is NULL.

FullbandController_EC
The main fullband controller function which updates
filter coefficients and returns output gain coefficients.

Syntax
QplStatus qplsFullbandController_EC_32f(const Qpl32f* pAdaptiveFilterErr, const Qpl32f*
pFixedFilterErr, Qpl32f* pAdaptiveCoefs, Qpl32f* pFixedCoefs, Qpl32f* pSGain,
QplsFullbandControllerState_EC_32f* pState   );
QplStatus qplsFullbandController_EC_16s(const Qpl16s* pAdaptiveFilterErr, const Qpl16s*
pFixedFilterErr, Qpl16s* pAdaptiveCoefs, Qpl16s* pFixedCoefs, Qpl32s* pSGain,
QplsFullbandControllerState_EC_16s* pState   );

                                                                                         709
---------------------Page 710---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h , qplvm.h , qpls.h
Libraries: qplcore.lib, qplvm.lib , qpls.lib

Parameters

pState                        Pointer to the fullband controller state structure.

pAdaptiveFilterErr            Pointer to the vector of adaptive filter output. Vector length is equal
                              to frameSize  , specified in the function FullbandControllerInit_EC.
pFixedFilterErr               Pointer to the vector of fixed filter output. Vector length is equal to
                              frameSize  , specified in the function FullbandControllerInit_EC.
pAdaptiveCoefs                Pointer to the adaptive filter coefficients vectors. Vector length is
                              equal to  tapLen , specified in the function FullbandControllerInit_EC.
pFixedCoefs                   Pointer to the fixed filter coefficients vectors. Vector length is equal
                              to tapLen , specified in the function FullbandControllerInit_EC.
pSGain                        Pointer to the send gain coefficient.

Description

These functions compare powers of adaptive filter error and fixed filter error and track changes of adaptive
filter coefficients power.
If the adaptive filter has a significantly smaller error and is stable (which is indicated by coefficients power
changing slowly), its coefficients are copied to the fixed filter. This case corresponds to “no double-talk”
mode.
If the fixed filter has a significantly smaller error, its coefficients are copied to the adaptive filter. This case
corresponds to the double-talk mode.
Send gain coefficient calculation (non-linear processor technology) is based on presence of the double-talk
mode and changes of receive-in and send-in signal powers.

Return Values

qplStsNoErr                         Indicates no error.

qplStsNullPtrErr                    Indicates an error when one of the specified pointers is NULL .

FullbandControllerReset_EC
Resets fullband controller state.

Syntax
QplStatus qplsFullbandControllerReset_EC_32f(QplsFullbandControllerState_EC_32f*
pState );
QplStatus qplsFullbandControllerReset_EC_16s(QplsFullbandControllerState_EC_16s*
pState );

Include Files
qplsc.h

   710
---------------------Page 711---------------------

                                                                      Speech Coding Functions  9 

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pState                       Pointer to the fullband controller state structure.

Description
These functions reset the fullband controller state. You can use these functions after an interruption in
adaptation process occurred.

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when the pState pointer is NULL.

FIR_EC
Computes finite impulse response (FIR) filter results.

Syntax
QplStatus qplsFIR_EC_16s(const Qpl16s* pSrcSpchRef, const Qpl16s* pSrcSpch, Qpl16s*
pDstSpch, int len, Qpl16s* pSrcTaps, Int tapsLen     );
QplStatus qplsFIR_EC_32f(const Qpl32f* pSrcSpchRef, const Qpl32f* pSrcSpch, Qpl32f*
pDstSpch, int len, Qpl32f* pSrcTaps, Int tapsLen     );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcSpchRef                  Pointer to the source original receive-out signal (Rout ) of length
                             (tapsLen + len ) .
pSrcSpch                     Pointer to the send-in signal (S in) with echo path.

pDstSpch                     Pointer to the destination send-out signal (Sout ) which is echo-free.

len                          Length of source and destination signals.

pSrcTaps                     Vector of FIR filter taps.

tapsLen                      Number of taps in the FIR filter.

Description

These function perform FIR filtering.

                                                                                          711
---------------------Page 712---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

Return Values

qplStsNoErr                      Indicates no error.

qplStsNullPtrErr                 Indicates an error when one of the specified pointers is NULL.

FIRSubband_EC, FIRSubbandLow_EC
Computes the frequency-domain adaptive filter output

Syntax
QplStatus qplsFIRSubband_EC_32fc(Qpl32fc** ppSrcSignalIn, Qpl32fc** ppSrcCoefs,
Qpl32fc* pDstSignalOut, int numSegments, int len    );
QplStatus qplsFIRSubband_EC_32sc_Sfs(Qpl32sc** ppSrcSignalIn, Qpl32sc** ppSrcCoefs,
Qpl32sc* pDstSignalOut, int numSegments, int len, int scaleFactor     );
QplStatus qplsFIRSubbandLow_EC_32sc_Sfs(const Qpl32sc** ppSrcSignal, const Qpl32sc**
ppCoefs, int numSegments, Qpl32sc* pDstSignal, int startSubband, int numSubbands, int
scaleFactor);

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

ppSrcSignalIn , ppSrcSignal Pointer to the two-dimensional vector of size [numSegments]*[ len]
                            containing the pointers to the most recent complex-valued FFT
                            spectra in input audio signal.
ppSrcCoefs , ppCoefs        Pointer to the two-dimensional vector of size [numSegments]*[ len]
                            containing the pointers to the filter coefficients vector of size [len].
pDstSignalOut , pDstSignal  Pointer to the complex-valued filter output vector.

numSegments                 Number of filter segments (0 < numSegments  < 256).

len, numSubbands            Number of filter subbands (0 < len, numSubbands  < 4097).

startSubband                Number of subbands to skip before filtering (0£ startSubband <
                            numSubbands ).
scaleFactor                 Saturation fixed scale factor (-32 < scaleFactor < 32), for
                            qplsFIRSubbandLow_EC_32sc_Sfs    function (0 ≤ scaleFactor < 32).

Description
These functions perform FIR filtering of the input two-dimensional spectra vector.
The qplsFIRSubbandLow_EC_32sc_Sfs   function performs filtering without 64-bit integer overflow check.
For startSubband=0, if no overflow occurs this function is equivalent to the function
qplsFIRSubband_EC_32sc_Sfs   with len equals to numSubbands.

Return Values

qplStsNoErr                      Indicates no error.

   712
---------------------Page 713---------------------

                                                                   Speech Coding Functions  9 

qplStsNullPtrErr                Indicates an error when one of the specified pointers is NULL.

qplStsLengthErr                 Indicates an error when len has an illegal value.

qplStsRangeErr                  Indicates an error when numSegments, startSubband or
                                scaleFactor  is out of the specified range.

FIRSubbandCoeffUpdate_EC, FIRSubbandLowCoeffUpdate_EC
Updates the adaptive filter coefficients

Syntax
QplStatus qplsFIRSubbandCoeffUpdate_EC_32fc_I(const double* pSrcStepSize, const
Qpl32fc** ppSrcFilterInput, const Qpl32fc* pSrcError, Qpl32fc** ppSrcDstCoefs, int
numSegments, int len );
QplStatus qplsFIRSubbandCoeffUpdate_EC_32sc_I(const Qpl32s_EC_Sfs* pSrcStepSize, const
Qpl32sc** ppSrcFilterInput, const Qpl32sc* pSrcError, Qpl32sc** ppSrcDstCoefsQ15, int
numSegments, int len, int scaleFactorCoef  );
QplStatus qplsFIRSubbandLowCoeffUpdate_EC_32sc_I(const Qpl32sc** ppSrcFilterInput,
const Qpl32sc* pSrcError, Qpl32sc** ppSrcDstCoefsQ15, int numSegments, Qpl32sc*
pDstProdStepErrQ, const Qpl32s_EC_Sfs* pSrcAdaptStepSize, int startSubband, int
numSubbands, int scaleFactorCoef );
QplStatus qplsFIRSubbandAPCoeffUpdate_EC_32fc_I(Qpl64f** ppSrcStepSize, const Qpl32fc**
ppSrcFilterInput, const Qpl32fc** ppSrcError, Qpl32fc** ppSrcDstCoefs, Qpl32u
numSegments, Qpl32u len, Qpl32u apOrder  );

Include Files
qplsc.h

Domain Dependencies
Headers: qplcore.h, qplvm.h, qpls.h
Libraries: qplcore.lib, qplvm.lib, qpls.lib

Parameters

pSrcStepSize,              Pointer to the adaptive filter step size vector of size len or
pSrcAdaptStepSize          numSubbands . For the integer functions step size vector elements are
                           represented as a scaled integer values where variable x of type
                           Qpl32s_EC_Sfs  corresponds to the floating point value
                           x.val*2^x.sf .
ppSrcStepSize              Pointer to the array containing pSrcStepSize.

apOrder                    Affine projection order.

ppSrcFilterInput           Pointer to the array of pointers to the most recent input blocks (for
                           example, Xn, Xn-1, ..., Xn-L+1). These are the complex-valued
                           vectors that contain the FFT of the input signal. The dimension of
                           ppSrcFilterInput  is [numSegments]*[len] or
                           [numSegments ]*[ numSubbands].
pSrcError                  Pointer to the complex-valued vector containing the filter error. Its
                           dimension is [len] or [numSubbands].
ppSrcError                 Pointer to the array containing pSrcError.

                                                                                      713
---------------------Page 714---------------------

 9    Intel® Query Processing Library Reference Manual, Volume 1: Signal Processing

ppSrcDstCoefs ,              Pointer to the array of pointers to the filter coefficient vectors. They
ppSrcDstCoefsQ15             are the complex-valued vectors containing the filter coefficients. The
                             dimension of ppSrcDstCoefs  is [numSegments]*[ len] or
                             [numSegments ]*[numSubbands ].
startSubband                 Number of subbands to skip before filtering (0 ≤ startSubband <
                             numSubbands ).
numSegments                  Number of filter segments (L) (0 < numSegments  < 256).

len, numSubbands             Number of adaptive filter subbands and length of the input and
                             output vectors.
scaleFactorCoef              Fixed scale factor for filter coefficients (0 < scaleFactorCoef < 32).

pDstProdStepErrQ             Pointer to the output vector of filter error and step size product.

Description
These functions update the adaptive filter coefficients according to the given step size and filter error
independently in each frequency subband.
The function qplsFIRSubbandLowCoeffUpdate_EC_32sc_I   computes the product between step size, error
and coefficients without 64-bit integer overflow check. For startSubband=0, if no overflow occurs this
function is equivalent to qplsFIRSubbandCoeffUpdate_EC_32sc_I with len equal to numSubbands.

Return Values

qplStsNoErr                       Indicates no error.

qplStsNullPtrErr                  Indicates an error when one of the specified pointers is NULL.

qplStsLengthErr                   Indicates an error when len has an illegal value.

qplStsRangeErr                    Indicates an error when pSrcStepSize [i]< 0, or when
                                  numSegments  or sc