CrossCorr

Computes the cross-correlation of two vectors.

Syntax

Intel IPP style:

IppStatus ippsqCrossCorr_32f(const Ipp32f* pSrc1 , Ipp32u src1Len , const Ipp32f* pSrc2 , Ipp32u src2Len , Ipp32f* pDst , Ipp32u dstLen , Ipp32s lowLag );

IppStatus ippsqCrossCorrQ15_16s_Rms(const Ipp16s* pSrc1 , Ipp32u src1Len , const Ipp16s* pSrc2 , Ipp32u src2Len , Ipp16s* pDst , Ipp32u dstLen , Ipp32s lowLag );

IppStatus ippsqCrossCorrFastQ15_16s_Rm(const Ipp16s* pSrc1 , Ipp32u src1Len , const Ipp16s* pSrc2 , Ipp32u src2Len , Ipp16s* pDst , Ipp32u dstLen , Ipp32s lowLag );

IppStatus ippsqCrossCorrQ31_32s_Rm(const Ipp32s* pSrc1 , Ipp32u src1Len , const Ipp32s* pSrc2 , Ipp32u src2Len , Ipp32s* pDst , Ipp32u dstLen , Ipp32s lowLag );

IppStatus ippsqCrossCorrFastQ31_32s_Rm(const Ipp32s* pSrc1 , Ipp32u src1Len , const Ipp32s* pSrc2 , Ipp32u src2Len , Ipp32s* pDst , Ipp32u dstLen , Ipp32s lowLag );

DSP style:

void ippsq_correlate_f32(const float32_t *pSrc1 , uint32_t src1Len , const float32_t *pSrc2 , uint32_t src2Len , float32_t *pDst );

void ippsq_correlate_q15(const q15_t *pSrc1 , uint32_t src1Len , const q15_t *pSrc2 , uint32_t src2Len , q15_t *pDst );

void ippsq_correlate_opt_q15(const q15_t *pSrc1 , uint32_t src1Len , const q15_t *pSrc2 , uint32_t src2Len , q15_t *pDst , q15_t *pBuffer );

void ippsq_correlate_fast_q15(const q15_t *pSrc1 , uint32_t src1Len , const q15_t *pSrc2 , uint32_t src2Len , q15_t *pDst );

void ippsq_correlate_fast_opt_q15(const q15_t *pSrc1 , uint32_t src1Len , const q15_t *pSrc2 , uint32_t src2Len , q15_t *pDst , q15_t *pBuffer );

void ippsq_correlate_q31(const q31_t *pSrc1 , uint32_t src1Len , const q31_t *pSrc2 , uint32_t src2Len , q31_t *pDst );

void ippsq_correlate_fast_q31(const q31_t *pSrc1 , uint32_t src1Len , const q31_t *pSrc2 , uint32_t src2Len , q31_t *pDst );

Include Files

ippsq.h

dsp.h

Parameters

pSrc1, pSrc2

Pointers to the source vectors.

src1Len, src2Len

Number of elements in the source vectors.

pDst

Pointer to the vector that stores the computed cross-correlation of the pSrc1 and pSrc2.

dstLen

Number of elements in the pDst vector. This value determines the range of lags at which the cross-correlation is computed.

lowLag

Lower value of the range of lags at which the cross-correaltion is computed.

pBuffer

Intermediate buffer; can be NULL.

Description

These functions compute the cross-correlation of src1Len elements of the pSrc1 vector and src2Len elements of the pSrc2 vector, and stores the result in the pDst vector. The result is computed by the following formula:



where

  • 0 ≤ndstLen



Intel IPP style:

  • If lowLag is 0, the correlation maximum is in pDst[0]

  • If the number of elements in the dstLen array is 2*MAX(src1Len, src2Len)-1 and lowLag is 1-MAX(src1Len, src2Len), the correlation maximum is in the center of the array.

Function flavors with the _Rm suffix round the result down.

Function flavors with the _Rms suffix round down and saturate the resulting value if it exceeds the data range.

DSP style: For correlation functions, the number of elements in the pDst array is 2*MAX(src1Len, src2Len)-1; the correlation maximum is in the center of the array.

Scaling, Truncation, Saturation

Intel IPP style:

Function Description
ippsqCrossCorrQ15_16s_Rms

The pSrc1, pSrc2, and pDst values are represented in Q15 format. The function uses a 64-bit internal accumulator in Q34.30 format, so it preserves full precision of intermediate calculations and avoids internal overflow. In the end, the function shifts the accumulator right by 15 bits and saturates it in the [IPP_MIN_16S, IPP_MAX_16S] range.

ippsqCrossCorrFastQ15_16s_Rm

The pSrc1, pSrc2, and pDst values are represented in Q15 format. The function uses a 32-bit internal 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 accumulator right by 15 bits and does not perform saturation.

ippsqCrossCorrQ31_32s_Rm

The pSrc1, pSrc2, and pDst values are represented in Q31 format. The function uses a 64-bit internal accumulator in Q2.62 format and provides only one guard bit. The function is not protected from internal overflow. In the end, the function shifts the accumulator right by 31 bits and does not perform saturation.

ippsqCrossCorrFastQ31_32s_Rm

The pSrc, pDst, pTaps, and pDlyLine values are represented in Q31 format. The function uses a 32-bit internal accumulator in Q2.30 format. The function shifts right the result of multiplication of Q31 numbers, truncates it to Q2.30 format, and adds it to the accumulator. The function is not protected from internal overflow and provides less precision because it discards low 32 bits after multiplication. In the end, the function shifts the accumulator left by 1 bit and does not perform saturation.

DSP style:

Function Description
ippsq_correlate_q15, ippsq_correlate_opt_q15, ippsq_correlate_fast_opt_q15

The pSrc1, pSrc2, and pDst values are represented in Q15 format. The function uses a 64-bit internal accumulator in Q34.30 format, so it preserves full precision of intermediate calculations and avoids internal overflow. In the end, the function shifts the accumulator right by 15 bits and saturates it in the [IPP_MIN_16S, IPP_MAX_16S] range.

ippsq_correlate_fast_q15

The pSrc1, pSrc2, and pDst values are represented in Q15 format. The function uses a 32-bit internal 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 accumulator right by 15 bits and does not perform saturation.

ippsq_correlate_q31

The pSrc1, pSrc2, and pDst values are represented in Q31 format. The function uses a 64-bit internal accumulator in Q2.62 format and provides only one guard bit. The function is not protected from internal overflow. In the end, the function shifts the accumulator right by 31 bits and does not perform saturation.

ippsq_correlate_fast_q31

The pSrc1, pSrc2, and pDst values are represented in Q31 format. The function uses a 32-bit internal accumulator in Q2.30 format. The function shifts right the result of multiplication of Q31 numbers, truncates it to Q2.30 format, and adds it to the accumulator. The function is not protected from internal overflow and provides less precision because it discards low 32 bits after multiplication. In the end, the function shifts the accumulator 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.