SampleDown
SampleDown
Down-samples a signal, conceptually decreasing its sampling rate by an integer factor.
Syntax
IppStatus ippsSampleDown_16s(const Ipp16s*
pSrc
, int
srcLen
, Ipp16s*
pDst
, int*
pDstLen
, int
factor
, int*
pPhase
);
IppStatus ippsSampleDown_32f(const Ipp32f*
pSrc
, int
srcLen
, Ipp32f*
pDst
, int*
pDstLen
, int
factor
, int*
pPhase
);
IppStatus ippsSampleDown_64f(const Ipp64f*
pSrc
, int
srcLen
, Ipp64f*
pDst
, int*
pDstLen
, int
factor
, int*
pPhase
);
IppStatus ippsSampleDown_16sc(const Ipp16sc*
pSrc
, int
srcLen
, Ipp16sc*
pDst
, int*
pDstLen
, int
factor
, int*
pPhase
);
IppStatus ippsSampleDown_32fc(const Ipp32fc*
pSrc
, int
srcLen
, Ipp32fc*
pDst
, int*
pDstLen
, int
factor
, int*
pPhase
);
IppStatus ippsSampleDown_64fc(const Ipp64fc*
pSrc
, int
srcLen
, Ipp64fc*
pDst
, int*
pDstLen
, int
factor
, int*
pPhase
);
Include Files
ipps.h
Domain Dependencies
Headers:
ippcore.h
,
ippvm.h
Libraries:
ippcore.lib
,
ippvm.lib
Parameters
- pSrc
- Pointer to the source array holding the samples to be down-sampled.
- srcLen
- Number of samples in the input arraypSrc.
- pDst
- Pointer to the destination array.
- pDstLen
- Pointer to the length of the destination arraypDst.
- factor
- Factor by which the signal is down-sampled. That is,factor- 1 samples are discarded from every block offactorsamples inpSrc.
- pPhase
- Pointer to the input phase value that determines which of the samples within each block offactorsamples frompSrcis not discarded and copied topDst. The value ofpPhaseis required to be in the range [0;factor-1].
Description
This function down-samples the
srcLen
-length source array pSrc
by factor factor
with phase pPhase
, and stores the result in the array pDst
, ignoring its length value by the pDstLen
address.Down-sampling discards
factor
- 1 samples from pSrc
, copying one sample from each block of factor
samples from pSrc
to pDst
. The pPhase
argument determines which of the samples in each block is not discarded and where it lies within each input block of factor
samples. The value of pPhase
is required to be in the range [0; factor
-1]. The length of the destination array is stored by the pDstLen
address.The
pPhase
value is the phase of an source array sample. It is also a returned output phase which can be used as an input phase for the first sample in the next block to process. Use pPhase
for block mode processing to get a continuous output signal.You can use the FIR multi-rate filter to combine filtering and resampling, for example, for antialiasing filtering before the sub-sampling procedure.
The
ippsSampleDown
functionality can be described as follows:pDstLen
= (srcLen
+ factor
- 1 - phase
)/factor
pDst
[n]= pSrc
[factor
* n + phase
]0
≤
n < pDstLen
phase
= (factor
+ phase
- srcLen
%factor
)%factor
Return Values
- ippStsNoErr
- Indicates no error.
- ippStsNullPtrErr
- Indicates an error when thepDst,pSrc,pDstLen, orpPhasepointer isNULL.
- ippStsSizeErr
- Indicates an error whensrcLenis less than or equal to 0.
- ippStsSampleFactorErr
- Indicates an error whenfactoris less than or equal to 0.
- ippStsSamplePhaseErr
- Indicates an error whenpPhaseis negative, or bigger than or equal tofactor.
Example
The example below shows how to use the function
ippsSampleDown
.void sampling( void ) { Ipp16s x[8] = { 1,2,3,4,5,6,7,8 }; Ipp16s y[8] = {9,10,11,12,13,14,15,16}, z[8]; int dstLen1, dstLen2, phase = 2; IppStatus st = ippsSampleDown_16s(x, 8, z, &dstLen1, 3, &phase); st = ippsSampleDown_16s(y, 8, z+dstLen1, &dstLen2, 3, &phase); printf_16s(“down-sampling =”, z, dstLen1+dstLen2, st); }
Output:
down-sampling = 3 6 9 12 15