IIR
IIR
Filters a source vector through an IIR filter.
Syntax
Case 1: Not-in-place operation on integer samples
IppStatus ippsIIR32f_16s_Sfs(const Ipp16s*
pSrc
, Ipp16s*
pDst
, int
len
, IppsIIRState32f_16s*
pState
, int
scaleFactor
);
IppStatus ippsIIR64f_16s_Sfs(const Ipp16s*
pSrc
, Ipp16s*
pDst
, int
len
, IppsIIRState64f_16s*
pState
, int
scaleFactor
);
IppStatus ippsIIR64f_32s_Sfs(const Ipp32s*
pSrc
, Ipp32s*
pDst
, int
len
, IppsIIRState64f_32s*
pState
, int
scaleFactor
);
IppStatus ippsIIR32fc_16sc_Sfs(const Ipp16sc*
pSrc
, Ipp16sc*
pDst
, int
len
, IppsIIRState32fc_16sc*
pState
, int
scaleFactor
);
IppStatus ippsIIR64fc_16sc_Sfs(const Ipp16sc*
pSrc
, Ipp16sc*
pDst
, int
len
, IppsIIRState64fc_16sc*
pState
, int
scaleFactor
);
IppStatus ippsIIR64fc_32sc_Sfs(const Ipp32sc*
pSrc
, Ipp32sc*
pDst
, int
len
, IppsIIRState64fc_32sc*
pState
, int
scaleFactor
);
Case 2: Not-in-place operation on floating point samples
IppStatus ippsIIR_32f(const Ipp32f*
pSrc
, Ipp32f*
pDst
, int
len
, IppsIIRState_32f*
pState
);
IppStatus ippsIIR_64f(const Ipp64f*
pSrc
, Ipp64f*
pDst
, int
len
, IppsIIRState_64f*
pState
);
IppStatus ippsIIR64f_32f(const Ipp32f*
pSrc
, Ipp32f*
pDst
, int
len
, IppsIIRState64f_32f*
pState
);
IppStatus ippsIIR_32fc(const Ipp32fc*
pSrc
, Ipp32fc*
pDst
, int
len
, IppsIIRState_32fc*
pState
);
IppStatus ippsIIR_64fc(const Ipp64fc*
pSrc
, Ipp64fc*
pDst
, int
len
, IppsIIRState_64fc*
pState
);
IppStatus ippsIIR64fc_32fc(const Ipp32fc*
pSrc
, Ipp32fc*
pDst
, int
len
, IppsIIRState64fc_32fc*
pState
);
Case 3: In-place operation on integer samples
IppStatus ippsIIR32f_16s_ISfs(Ipp16s*
pSrcDst
, int
len
, IppsIIRState32f_16s*
pState
, int
scaleFactor
);
IppStatus ippsIIR32fc_16sc_ISfs(Ipp16sc*
pSrcDst
, int
len
, IppsIIRState32fc_16sc*
pState
, int
scaleFactor
);
IppStatus ippsIIR64f_16s_ISfs(Ipp16s*
pSrcDst
, int
len
, IppsIIRState64f_16s*
pState
, int
scaleFactor
);
IppStatus ippsIIR64f_32s_ISfs(Ipp32s*
pSrcDst
, int
len
, IppsIIRState64f_32s*
pState
, int
scaleFactor
);
IppStatus ippsIIR64fc_16sc_ISfs(Ipp16sc*
pSrcDst
, int
len
, IppsIIRState64fc_16sc*
pState
, int
scaleFactor
);
IppStatus ippsIIR64fc_32sc_ISfs(Ipp32sc*
pSrcDst
, int
len
, IppsIIRState64fc_32sc*
pState
, int
scaleFactor
);
Case 4: In-place operation on floating point samples
IppStatus ippsIIR_32f_I(Ipp32f*
pSrcDst
, int
len
, IppsIIRState_32f*
pState
);
IppStatus ippsIIR_64f_I(Ipp64f*
pSrcDst
, int
len
, IppsIIRState_64f*
pState
);
IppStatus ippsIIR64f_32f_I(Ipp32f*
pSrcDst
, int
len
, IppsIIRState64f_32f*
pState
);
IppStatus ippsIIR_32fc_I(Ipp32fc*
pSrcDst
, int
len
, IppsIIRState_32fc*
pState
);
IppStatus ippsIIR_64fc_I(Ipp64fc*
pSrcDst
, int
len
, IppsIIRState_64fc*
pState
);
IppStatus ippsIIR64fc_32fc_I(Ipp32fc*
pSrcDst
, int
len
, IppsIIRState64fc_32fc*
pState
);
Case 4: Operation with specified number of vector
IppStatus ippsIIR_32f_P(const Ipp32f**
ppSrc
, Ipp32f**
ppDst
, int
len
, int
nChannels
, IppsIIRState_32f**
ppState
);
IppStatus ippsIIR64f_32s_PSfs(const Ipp32s**
ppSrc
, Ipp32s**
ppDst
, int
len
, int
nChannels
, IppsIIRState64f_32s**
ppState
, int*
pScaleFactor
);
IppStatus ippsIIR_32f_IP(Ipp32f**
ppSrcDst
, int
len
, int
nChannels
, IppsIIRState_32f**
ppState
);
IppStatus ippsIIR64f_32s_IPSfs(Ipp32s**
ppSrcDst
, int
len
, int
nChannels
, IppsIIRState64f_32s**
ppState
, int*
pScaleFactor
);
Include Files
ipps.h
Domain Dependencies
Headers:
ippcore.h
,
ippvm.h
Libraries:
ippcore.lib
,
ippvm.lib
Parameters
- pState
- Pointer to the IIR filter state structure.
- ppState
- Pointer to the array of the pointers to the IIR filter state structures.
- pSrc
- Pointer to the source vector.
- ppSrc
- Pointer to the array of pointers to the source vectors.
- pDst
- Pointer to the destination vector.
- ppDst
- Pointer to the array of pointers to the destination vector.
- pSrcDst
- Pointer to the source and destination vector for the in-place operations.
- ppSrcDst
- Pointer to the array of pointers to the source and destination vectors for the in-place operations.
- len
- Number of elements of the vector to be filtered.
- nChannels
- Number of vectors to be filtered.
- scaleFactor
- Scale factor, refer to Integer Scaling.
- pScaleFactor
- Pointer to the scale factor.
Description
This function filters
len
elements of the source vector pSrc
or pSrcDst
through an IIR filter, and stores the results in pDst
or pSrcDst
, respectively. The filter parameters are specified in pState
.The output of the integer sample is scaled according to scaleFactor
and can be saturated.Do not modify the
scaleFactor
value unless the state structure is changed.The filter state must be initialized before calling the function
ippsIIR
. Specify the number of taps tapsLen
, the tap values in pTaps
, the delay line values in pDlyLine
, and the order
or numBq
value beforehand.Function flavors described in the
Case 4
filter simultaneously the nChannels
source vectors. Each vector must have the len
elements and is filtered with its own state structure. These state structures must be initialized beforehand.Example demonstrates how to use the function
ippsIIR
to filter a sample. The function ippsConvert_64f32s_Sfs
converts floating-point taps into integer data type before calling ippsIIRInitAlloc_32s
.Return Values
- ippStsNoErr
- Indicates no error.
- ippStsNullPtrErr
- Indicates an error when one of the specified pointers isNULL.
- ippStsSizeErr
- Indicates an error whenlenis less or equal to 0.
- ippStsChannelErr
- Indicates an error whennChannelsis less or equal to 0.
- ippStsContextMatchErr
- Indicates an error when the state identifier is incorrect.
Example
/*******************************************************************************
* Copyright 2015-2021 Intel Corporation.
*
* This software and the related documents are Intel copyrighted materials, and
* your use of them is governed by the express license under which they were
* provided to you (License). Unless the License provides otherwise, you may not
* use, modify, copy, publish, distribute, disclose or transmit this software or
* the related documents without Intel's prior written permission.
*
* This software and the related documents are provided as is, with no express
* or implied warranties, other than those that are expressly stated in the
* License.
*******************************************************************************/
#include <math.h>
#include <stdio.h>
#include "ipp.h"
#undef NUMITERS
#define NUMITERS 150
/* Next two defines are created to simplify code reading and understanding */
#define EXIT_MAIN exitLine: /* Label for Exit */
#define check_sts(st) if((st) != ippStsNoErr) goto exitLine; /* Go to Exit if Intel(R) Integrated Primitives (Intel(R) IPP) function returned status different from ippStsNoErr */
/* Results of ippMalloc() are not validated because Intel(R) IPP functions perform bad arguments check and will return an appropriate status */
int main()
{
int n = 0, i = 0, specSize = 0, bufferSize = 0;
IppStatus status;
IppsIIRState_32f *pIIRState = NULL; /* Pointer to Intel(R) IPP state structure */
IppsFIRSpec_32f *pFIRSpec = NULL; /* Pointer to FIR Spec structure */
Ipp32f *x = ippsMalloc_32f(NUMITERS + 10),
*y = ippsMalloc_32f(NUMITERS),
*z = ippsMalloc_32f(NUMITERS);
const float taps[] = {
0.0051f, 0.0180f, 0.0591f, 0.1245f, 0.1869f, 0.2127f, 0.1869f,
0.1245f, 0.0591f, 0.0180f, 0.0051f, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
Ipp8u* pBuf = NULL; /* Pointer to the work buffers */
for (n = 0; n < NUMITERS; ++n) x[n] = (float)sin(IPP_2PI *n *0.2);
check_sts( status = ippsIIRGetStateSize_32f(10, &bufferSize) )
pBuf = ippsMalloc_8u(bufferSize);
check_sts( status = ippsIIRInit_32f(&pIIRState, taps, 10, NULL, pBuf) )
check_sts( status = status = ippsIIR_32f(x, y, NUMITERS, pIIRState) )
ippsFree(pBuf); pBuf = NULL;
for (i = 120; i < 120+5; i++) printf("%f,", y[i]);
printf("\n");
check_sts( status = ippsFIRSRGetSize(11, ipp32f, &specSize, &bufferSize) )
pFIRSpec = (IppsFIRSpec_32f *)ippsMalloc_8u(specSize);
pBuf = ippsMalloc_8u(bufferSize);
check_sts( status = ippsFIRSRInit_32f(taps, 11, ippAlgDirect, pFIRSpec) )
check_sts( status = ippsFIRSR_32f(x, z, NUMITERS, pFIRSpec, NULL, NULL, pBuf) )
for (i = 120; i < 120+5; i++) printf("%f,", z[i]);
printf("\n");
EXIT_MAIN
ippsFree(pBuf);
ippsFree(z);
ippsFree(y);
ippsFree(x);
printf("Exit status %d (%s)\n", (int)status, ippGetStatusString(status));
return (int)status;
}