ResamplePolyphase, ResamplePolyphaseFixed
ResamplePolyphase
, ResamplePolyphaseFixed
Resample input data using polyphase filters.
Syntax
IppStatus ippsResamplePolyphase_16s(const Ipp16s*
pSrc
, int
len
, Ipp16s*
pDst
, Ipp64f
factor
, Ipp32f
norm
, Ipp64f*
pTime
, int*
pOutlen
, const IppsResamplingPolyphase_16s*
pSpec
);
IppStatus ippsResamplePolyphase_32f(const Ipp32f*
pSrc
, int
len
, Ipp32f*
pDst
, Ipp64f
factor
, Ipp32f
norm
, Ipp64f*
pTime
, int*
pOutlen
, const IppsResamplingPolyphase_32f*
pSpec
);
IppStatus ippsResamplePolyphaseFixed_16s(const Ipp16s*
pSrc
, int
len
, Ipp16s*
pDst
, Ipp32f
norm
, Ipp64f*
pTime
, int*
pOutlen
, const IppsResamplingPolyphaseFixed_16s*
pSpec
);
IppStatus ippsResamplePolyphaseFixed_32f(const Ipp32f*
pSrc
, int
len
, Ipp32f*
pDst
, Ipp32f
norm
, Ipp64f*
pTime
, int*
pOutlen
, const IppsResamplingPolyphaseFixed_32f*
pSpec
);
Include Files
ipps.h
Domain Dependencies
Headers:
ippcore.h
,
ippvm.h
Libraries:
ippcore.lib
,
ippvm.lib
Parameters
- pSrc
- The pointer to the input vector.
- pDst
- The pointer to the output vector.
- len
- The number of input vector elements to resample.
- norm
- The norm factor for output samples.
- factor
- The resampling factor.
- pTime
- The pointer to the start time of resampling (in input vector elements). Keeps the input sample number and the phase for the first output sample from the next input data portion.
- pOutlen
- The number of calculated output vector elements.
- pSpec
- The pointer to the resampling state structure.
Description
These functions convert data from the input vector changing their frequency and compute all output samples that can be correctly calculated for the given input and the filter length. For the
ippsResamplePolyphase
function, the ratio of output and input frequencies is defined by the factor
argument. For the ippsResamplePolyphaseFixed
function, this ratio is defined during creation of the resampling structure. The value for pTime
[0] defines the time value for which the first output sample is calculated. Input vector with indices less than
pTime
[0]
contains the history data of filters. The history length is equal to flen
/2 for ippsResamplePolyphaseFixed
function , and [1/2window
*max(1, 1/factor
)]+1 for ippsResamplePolyphase
function. Here flen
is the filter length and window
is the size of the ideal lowpass filter window. The input vector must contain the same number of elements with indices greater than pTime
[0] + len
for the right filter wing for the last element. After function execution, the time value is updated and
pOutlen
[0] contains the number of calculated output samples. The output samples are multiplied by
norm
* min (1, factor
) before saturation. Return Values
- ippStsNoErr
- Indicates no error.
- ippStsNullPtrErr
- Indicates an error whenpSpec,pSrc,pDst,pTimeorpOutlenpointer isNULL.
- ippStsSizeErr
- Indicates an error whenlenis less than or equal to 0.
- ippStsBadArgErr
- Indicates an error whenfactoris less than or equal to 0.
Example
The code example below demonstrates resampling of the input mono pcm file.
void resampleIPP( int inRate, // input frequency int outRate, // output frequency FILE *infd, // input pcm file FILE *outfd) // output pcm file { short *inBuf,*outBuf; int bufsize=4096; int history=128; double time=history; int lastread=history; int inCount=0,outCount=0,inLen,outLen; int size,len,height; IppsResamplingPolyphaseFixed_16s *state; ippsResamplePolyphaseFixedGetSize_16s(inRate,outRate,2*(history-1),&size,&len, &height,ippAlgHintAccurate); state=(IppsResamlingPolyphaseFixed_16s*)ippsMalloc_8u(size); ippsResamplePolyphaseFixedInit_16s(inRate,outRate,2*(history-1),0.95f,9.0f,state, ippAlgHintAccurate); inBuf=ippsMalloc_16s(bufsize+history+2); outBuf=ippsMalloc_16s((int)((bufsize-history)*outRate/(float)inRate+2)); ippsZero_16s(inBuf,history); while ((inLen=fread(inBuf+lastread,sizeof(short),bufsize-lastread,infd))>0) { inCount+=inLen; lastread+=inLen; ippsResamplePolyphaseFixed_16s(inBuf,lastread-history-(int)time, outBuf,0.98f,&time,&outLen,state); fwrite(outBuf,outLen,sizeof(short),outfd); outCount+=outLen; ippsMove_16s(inBuf+(int)time-history,inBuf,lastread+history-(int)time); lastread-=(int)time-history; time-=(int)time-history; } ippsZero_16s(inBuf+lastread,history); ippsResamplePolyphaseFixed_16s(inBuf,lastread-(int)time, outBuf,0.98f,&time,&outLen,state); fwrite(outBuf,outLen,sizeof(short),outfd); outCount+=outLen; printf("%d inputs resampled to %d outputs\n",inCount,outCount); ippsFree(outBuf); ippsFree(inBuf); ippsFree (state); }