FIRSparse

Filters a source vector through a sparse FIR filter.

Syntax

Intel IPP style:

typedef struct {
    Ipp16u  numTaps;
    Ipp16u  stateIndex;
    Ipp32f *pState;
    Ipp32f *pCoeffs;
    Ipp16u  maxDelay;
    Ipp32s *pTapDelay;
} IppsqFIRSparseState_32f;

IppStatus ippsqFIRSparse_32f (const Ipp32f *pSrc , Ipp32f *pDst , Ipp32u srcLen , Ipp32f* buffer , IppsqFIRSparseState_32f *pSpec );

typedef struct {
    Ipp16u  numTaps;
    Ipp16u  stateIndex;
    Ipp16s *pState;
    Ipp16s *pCoeffs;
    Ipp16u  maxDelay;
    Ipp32s *pTapDelay;
} IppsqFIRSparseState_16s;

IppStatus ippsqFIRSparseQ15_16s_Rms (const Ipp16s *pSrc , Ipp16s *pDst , Ipp32u srcLen , Ipp16s* buffer , Ipp32s *pScratchOut , IppsqFIRSparseState_16s *pSpec );

typedef struct {
    Ipp16u  numTaps;
    Ipp16u  stateIndex;
    Ipp32s *pState;
    Ipp32s *pCoeffs;
    Ipp16u  maxDelay;
    Ipp32s *pTapDelay;
} IppsqFIRSparseState_32s;

IppStatus ippsqFIRSparseQ31_32s_Rm (const Ipp32s *pSrc , Ipp32s *pDst , Ipp32u srcLen , Ipp32s* buffer , IppsqFIRSparseState_32s *pSpec );

DSP style:

typedef struct {
    Ipp16u  numTaps;
    Ipp16u  stateIndex;
    Ipp32f *pState;
    Ipp32f *pCoeffs;
    Ipp16u  maxDelay;
    Ipp32s *pTapDelay;
} ippsq_fir_sparse_instance_f32;

void ippsq_fir_sparse_init_f32 (ippsq_fir_sparse_instance_f32 *S , uint16_t numTaps , float32_t *pCoeffs , float32_t *pState , int32_t *pTapDelay , uint16_t maxDelay , uint32_t blockSize );

void ippsq_fir_sparse_f32 (ippsq_fir_sparse_instance_f32 *S , float32_t *pSrc , float32_t *pDst , float32_t *pScratchIn , uint32_t blockSize );

typedef struct {
    Ipp16u  numTaps;
    Ipp16u  stateIndex;
    Ipp16s *pState;
    Ipp16s *pCoeffs;
    Ipp16u  maxDelay;
    Ipp32s *pTapDelay;
} ippsq_fir_sparse_instance_q15;

void ippsq_fir_sparse_init_q15 (ippsq_fir_sparse_instance_q15 *S , uint16_t numTaps , q15_t *pCoeffs , q15_t *pState , int32_t *pTapDelay , uint16_t maxDelay , uint32_t blockSize );

void ippsq_fir_sparse_q15 (ippsq_fir_sparse_instance_q15 *S , q15_t *pSrc , q15_t *pDst , q15_t *pScratchIn , q31_t *pScratchOut , uint32_t blockSize );

typedef struct {
    Ipp16u  numTaps;
    Ipp16u  stateIndex;
    Ipp32s *pState;
    Ipp32s *pCoeffs;
    Ipp16u  maxDelay;
    Ipp32s *pTapDelay;
} ippsq_fir_sparse_instance_q31;

void ippsq_fir_sparse_init_q31 (ippsq_fir_sparse_instance_q31 *S , uint16_t numTaps , q31_t *pCoeffs , q31_t *pState , int32_t *pTapDelay , uint16_t maxDelay , uint32_t blockSize );

void ippsq_fir_sparse_q31 (ippsq_fir_sparse_instance_q31 *S , q31_t *pSrc , q31_t *pDst , q31_t *pScratchIn , 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.

numTaps

Number of elements in the array containing the non-zero tap values.

pCoeffs

Pointer to the array containing the non-zero tap values. The number of elements in the array is numTaps.

pTapDelay

Pointer to the array containing positions of the non-zero tap values. The number of elements in the array is numTaps.

maxDelay

Value of the largest element in the pTapDelay array.

pState

Pointer to the array containing the delay line values. The number of elements in the array is maxDelay + srcLen.

stateIndex

Pointer to the oldest sample in the state buffer pState.

Buffer, pScratchIn, pScratchOut

A temporary buffer of srcLen size.

Description

This function applies a sparse FIR filter to srcLen elements of the source vector pSrc, and stores the results in pDst.

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



where:

  • x(n) is the sample to be filtered

  • pCoeffs(i) is the i-th non-zero tap value

  • pTapDelay(i) is the i-th non-zero tap position

After calculations, the function updates the delay line values stored in the state structure.

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: The FIR filter structure pSpec specifies the following filter parameters:

  • number of non-zero taps numTaps

  • non-zero tap values pCoeffs

  • non-zero tap positions pTapDelay

  • delay line values pState

Before using the ippsqFIRSparse function, initialize all fields of the pSpec structure by setting proper values to stateIndex (should be set to zero), numTaps, maxDelay and assigning pointers to arrays.

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.

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 maxDelay + blockSize – 1.

Scaling, Truncation, Saturation

Intel IPP style:

Function Description
ippsqFIRSparseQ15_16s_Rms

The pSrc, pDst, pCoeffs, pState, and buffer values are represented in Q15 format. The function uses the 32-bit internal pScratchOut buffer for accumulation results and provides only one guard bit. Multiplication of Q15 numbers results in a Q2.30 number stored in pScratchOut. The function is not protected from internal overflow. In the end, the function shifts the pScratchOut data right by 15 bits and saturates it in the [IPP_MIN_16S, IPP_MAX_16S] range.

ippsqFIRSparseQ31_32s_Rm

The pSrc, pDst, pCoeffs, pState, and buffer values are represented in Q31 format. The function uses the 32-bit pDst 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 pDst data left by 1 bit and does not perform saturation.

DSP style:

Function Description
ippsq_fir_sparse_q15

The pSrc, pDst, pCoeffs, pState, and pScratchIn values are represented in Q15 format and pScratchOut is in Q31. The function uses the 32-bit internal pScratchOut buffer for accumulation results and provides only one guard bit. Multiplication of Q15 numbers results in a Q2.30 number stored in pScratchOut. The function is not protected from internal overflow. In the end, the function shifts the pScratchOut data right by 15 bits and saturates it in the [IPP_MIN_16S, IPP_MAX_16S] range.

ippsq_fir_sparse_q31

The pSrc, pDst, pCoeffs, pState, and pScratchIn values are represented in Q31 format. The function uses the 32-bit pDst 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 pDst data left by 1 bit and does not perform saturation.

Return Values

ippStsNoErr

Indicates no error.

ippStsNullPtrErr

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