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

RShiftC

Shifts bits in vector elements to the right.

Syntax

IppStatus ippsRShiftC_8u(const Ipp8u* pSrc, int val, Ipp8u* pDst, int len);

IppStatus ippsRShiftC_16s(const Ipp16s* pSrc, int val, Ipp16s* pDst, int len);

IppStatus ippsRShiftC_16u(const Ipp16u* pSrc, int val, Ipp16u* pDst, int len);

IppStatus ippsRShiftC_32s(const Ipp32s* pSrc, int val, Ipp32s* pDst, int len);

IppStatus ippsRShiftC_8u_I(int val, Ipp8u* pSrcDst, int len);

IppStatus ippsRShiftC_16u_I(int val, Ipp16u* pSrcDst, int len);

IppStatus ippsRShiftC_16s_I(int val, Ipp16s* pSrcDst, int len);

IppStatus ippsRShiftC_32s_I(int val, Ipp32s* pSrcDst, int len);

Include Files

ipps.h

Domain Dependencies

Headers: ippcore.h, ippvm.h

Libraries: ippcore.lib, ippvm.lib

Parameters

val

Number of bits by which the function shifts each element of the vector pSrc or pSrcDst.

pSrc

Pointer to the source vector.

pDst

Pointer to the destination vector.

pSrcDst

Pointer to the source and destination vector for the in-place operation.

len

Number of elements in the vector.

Description

This function shifts each element of the vector pSrc by val bits to the right, and stores the result in pDst.

The in-place flavors of ippsRShiftC shift each element of the vector pSrcDst by val bits to the right and store the result in pSrcDst.

Note that the arithmetic shift is realized for signed data, and the logical shift for unsigned data.

Return Values

ippStsNoErr

Indicates no error.

ippStsNullPtrErr

Indicates an error when the pSrc, pDst, or pSrcDst pointer is NULL.

ippStsSizeErr

Indicates an error when len is less than or equal to zero.

Example

The code example below shows how the logical and shift functions can be used in the saturate operation. The data are converted to the unsigned char range [0...255].

void saturate(void) {
      Ipp16s x[8] = {1000, -257, 127, 4, 5, 0, 7, 8}, lo[8], hi[8];
      IppStatus status = ippsNot_16u((Ipp16u*)x, (Ipp16u*)lo, 8);
      ippsRShiftC_16s_I(15, lo, 8);
      ippsCopy_16s(x, hi, 8);
      ippsSubCRev_16s_ISfs(255, hi, 8, 0);
      ippsRShiftC_16s_I(15, hi, 8);
      ippsAnd_16u_I((Ipp16u*)lo, (Ipp16u*)x, 8);
      ippsOr_16u_I((Ipp16u*)hi, (Ipp16u*)x, 8);
      ippsAndC_16u_I(255, (Ipp16u*)x, 8);
      printf_16s("saturate =", x, 8, status); 
} 

Output:

    saturate =  255 0 127 4 5 0 7 8