FIR

Directly filters a source vector through a single-rate FIR filter.

Syntax

Intel IPP style:

IppStatus ippsqFIRDirect_32f (const Ipp32f *pSrc , Ipp32f *pDst , Ipp32u srcLen , const Ipp32f* pTaps , Ipp32u tapsLen , Ipp32f* pDlyLine );

IppStatus ippsqFIRDirectQ15_16s_Rms (const Ipp16s *pSrc , Ipp16s *pDst , Ipp32u srcLen , const Ipp16s* pTaps , Ipp32u tapsLen , Ipp16s* pDlyLine );

IppStatus ippsqFIRDirectFastQ15_16s_Rms (const Ipp16s *pSrc , Ipp16s *pDst , Ipp32u srcLen , const Ipp16s* pTaps , Ipp32u tapsLen , Ipp16s* pDlyLine );

IppStatus ippsqFIRDirectQ31_32s_Rm (const Ipp32s *pSrc , Ipp32s *pDst , Ipp32u srcLen , const Ipp32s* pTaps , Ipp32u tapsLen , Ipp32s* pDlyLine );

IppStatus ippsqFIRDirectFastQ31_32s_Rm (const Ipp32s *pSrc , Ipp32s *pDst , Ipp32u srcLen , const Ipp32s* pTaps , Ipp32u tapsLen , Ipp32s* pDlyLine );

DSP style:

typedef struct {
    Ipp16u  numTaps;
    Ipp32f *pState;
    Ipp32f *pCoeffs;
} ippsq_fir_instance_f32;

void ippsq_fir_init_f32 (ippsq_fir_instance_f32 *S , uint16_t numTaps , float32_t *pCoeffs , float32_t *pState , uint32_t blockSize );

void ippsq_fir_f32 (const ippsq_fir_instance_f32 *S , float32_t *pSrc , float32_t *pDst , uint32_t blockSize );

typedef struct {
    Ipp16u  numTaps;
    Ipp16s *pState;
    Ipp16s *pCoeffs;
} ippsq_fir_instance_q15;

ippsq_status ippsq_fir_init_q15 (ippsq_fir_instance_q15 *S , uint16_t numTaps , q15_t *pCoeffs , q15_t *pState , uint32_t blockSize );

void ippsq_fir_q15 (const ippsq_fir_instance_q15 *S , q15_t *pSrc , q15_t *pDst , uint32_t blockSize );

void ippsq_fir_fast_q15 (const ippsq_fir_instance_q15 *S , q15_t *pSrc , q15_t *pDst , uint32_t blockSize );

typedef struct {
    Ipp16u  numTaps;
    Ipp32s *pState;
    Ipp32s *pCoeffs;
} ippsq_fir_instance_q31;

void ippsq_fir_init_q31 (ippsq_fir_instance_q31 *S , uint16_t numTaps , q31_t *pCoeffs , q31_t *pState , uint32_t blockSize );

void ippsq_fir_q31 (const ippsq_fir_instance_q31 *S , q31_t *pSrc , q31_t *pDst , uint32_t blockSize );

void ippsq_fir_fast_q31 (const ippsq_fir_instance_q31 *S , q31_t *pSrc , q31_t *pDst , uint32_t blockSize );

Include Files

ippsq.h

dsp.h

Parameters

pSrc

Pointer to the source vector.

pDst

Pointer to the destination vector.

srcLen, blockSize

Number of elements in the source/destination vectors; can be zero.

pTaps, pCoeffs

Pointer to the array containing the tap values. The number of elements in the array is tapsLen (numTaps for DSP).

tapsLen, numTaps

Number of elements in the array containing the tap values.

pDlyLine, pState

Pointer to the array containing the delay line values.

Description

This function passes a source vector pSrc containing srcLen samples through a single-rate filter, and stores the resulting srcLen samples in pDst. The values of filter coefficients (taps) are specified in the tapsLen-length array pTaps.

The function copies the last tapsLen input samples from pSrc to the beginning of pDlyLine. The number of elements in the pDlyLine array must be at least tapsLen + srcLen - 1.

The input samples are stored in pDlyLine in the following order:

x[-tapsLen+1], x[-tapsLen+2], ..., x[0], x[1], ..., x[ srcLen -1]

The return value y(n) is defined by the formula for a single-rate FIR filter:



where

  • x(n) denotes the sample to be filtered

  • h(i) denotes the tap values

Note

Parameters in the above description have Intel IPP-style names. For the corresponding DSP-style parameter names, refer to the Parameters section.

Intel IPP style:

Note

When using Intel IPP-style functions, it is advisable to initialize pDlyLine with zeros. Otherwise, the first tapsLen-1 values of the output are invalid.

Function flavors with the _Rm suffix round down the resulting value.

Function flavors with the _Rms suffix round down the resulting value and perform saturation if the resulting value exceeds the data range.

When using Intel IPP-style APIs, you do not need to call any initialization functions. Intel IPP-style functions directly get all necessary parameters as arguments.

DSP style: Each function type (f32, q15, and q31) has its own state structure, which must be initialized with the corresponding initialization function. The initialization function copies arguments into the state structure and sets the pState array to zero. The number of elements in the pState array should be at least numTaps + blockSize – 1.

Scaling, Truncation, Saturation

Intel IPP style:

Function Description
ippsqFIRDirectQ15_16s_Rms

The pSrc, pDst, pTaps, and pDlyLine values are represented in Q15 format. The function uses a 64-bit internal accumulator in Q34.30 format, so it preserves full precision of intermediate calculations and avoids internal overflow. In the end, the function shifts the accumulator right by 15 bits and saturates it in the [IPP_MIN_16S, IPP_MAX_16S] range.

ippsqFIRDirectFastQ15_16s_Rms

The pSrc, pDst, pTaps, and pDlyLine values are represented in Q15 format. The function uses a 32-bit internal accumulator in Q2.30 format and provides only one guard bit. The function is not protected from internal overflow. In the end, the function shifts the accumulator right by 15 bits and does not perform saturation.

ippsqFIRDirectQ31_32s_Rm

The pSrc, pDst, pTaps, and pDlyLine values are represented in Q31 format. The function uses a 64-bit internal accumulator in Q2.62 format and provides only one guard bit. The function is not protected from internal overflow. In the end, the function shifts the accumulator right by 31 bits and does not perform saturation.

ippsqFIRDirectFastQ31_32s_Rm

The pSrc, pDst, pTaps, and pDlyLine values are represented in Q31 format. The function uses a 32-bit internal accumulator in Q2.30 format. The function shifts right the result of multiplication of Q31 numbers, truncates it to Q2.30 format, and adds it to the accumulator. The function is not protected from internal overflow and provides less precision because it discards low 32 bits after multiplication. In the end, the function shifts the accumulator left by 1 bit and does not perform saturation.

DSP style:

Function Description
ippsq_fir_q15

The pSrc, pDst, pCoeffs, and pState values are represented in Q15 format. The function uses a 64-bit internal accumulator in Q34.30 format, so it preserves full precision of intermediate calculations and avoids internal overflow. In the end, the function shifts the accumulator right by 15 bits and saturates it in the [IPP_MIN_16S, IPP_MAX_16S] range.

ippsq_fir_fast_q15

The pSrc, pDst, pCoeffs, and pState values are represented in Q15 format. The function uses a 32-bit internal accumulator in Q2.30 format and provides only one guard bit. The function is not protected from internal overflow. In the end, the function shifts the accumulator right by 15 bits and does not perform saturation.

ippsq_fir_q31

The pSrc, pDst, pCoeffs, and pState values are represented in Q31 format. The function uses a 64-bit internal accumulator in Q2.62 format and provides only one guard bit. The function is not protected from internal overflow. In the end, the function shifts the accumulator right by 31 bits and does not perform saturation.

ippsq_fir_fast_q31

The pSrc, pDst, pCoeffs, and pState values are represented in Q31 format. The function uses a 32-bit internal accumulator in Q2.30 format. The function shifts right the result of multiplication of Q31 numbers, truncates it to Q2.30 format, and adds it to the accumulator. The function is not protected from internal overflow and provides less precision because it discards low 32 bits after multiplication. In the end, the function shifts the accumulator left by 1 bit and does not perform saturation.

Return Values

ippStsNoErr

Indicates no error.

ippStsSizeErr

Indicates an error when tapsLen is equal to zero.

ippStsNullPtrErr

Indicates an error when any of the specified pointers is NULL.
For more complete information about compiler optimizations, see our Optimization Notice.