Intel® Integrated Performance Primitives (Intel® IPP) Developer Guide and Reference

ID 790148
Date 6/24/2024
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

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 array pSrc.

pDst

Pointer to the destination array.

pDstLen

Pointer to the length of the destination array pDst.

factor

Factor by which the signal is down-sampled. That is, factor - 1 samples are discarded from every block of factor samples in pSrc.

pPhase

Pointer to the input phase value that determines which of the samples within each block of factor samples from pSrc is not discarded and copied to pDst. The value of pPhase is 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 the pDst, pSrc, pDstLen, or pPhase pointer is NULL.

ippStsSizeErr

Indicates an error when srcLen is less than or equal to 0.

ippStsSampleFactorErr

Indicates an error when factor is less than or equal to 0.

ippStsSamplePhaseErr

Indicates an error when pPhase is negative, or bigger than or equal to factor.

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