Developer Reference

  • 2020
  • 10/21/2020
  • Public Content
Contents

Convert

Converts the data type of a vector and stores the results in a second vector.

Syntax

IppStatus ippsConvert_8s16s(const Ipp8s*
pSrc
,Ipp16s*
pDst
, int
len
);
IppStatus ippsConvert_8s32f(const Ipp8s*
pSrc
, Ipp32f*
pDst
, int
len
);
IppStatus ippsConvert_8u32f(const Ipp8u*
pSrc
, Ipp32f*
pDst
, int
len
);
IppStatus ippsConvert_8u8s_Sfs(const Ipp8u*
pSrc
, Ipp8s*
pDst
, int
len
, IppRoundMode
rndMode
, int
scaleFactor
);
IppStatus ippsConvert_8s8u(const Ipp8s*
pSrc
, Ipp8u*
pDst
, int
len
);
IppStatus ippsConvert_16s8s_Sfs(const Ipp16s*
pSrc
, Ipp8s*
pDst
, Ipp32u
len
, IppRoundMode
rndMode
, int
scaleFactor
);
IppStatus ippsConvert_16s32s(const Ipp16s*
pSrc
, Ipp32s*
pDst
, int
len
);
IppStatus ippsConvert_16s32f(const Ipp16s*
pSrc
, Ipp32f*
pDst
, int
len
);
IppStatus ippsConvert_16u32f(const Ipp16u*
pSrc
, Ipp32f*
pDst
, int
len
);
IppStatus ippsConvert_32s16s(const Ipp32s*
pSrc
, Ipp16s*
pDst
, int
len
);
IppStatus ippsConvert_32s32f(const Ipp32s*
pSrc
, Ipp32f*
pDst
, int
len
);
IppStatus ippsConvert_32s64f(const Ipp32s*
pSrc
, Ipp64f*
pDst
, int
len
);
IppStatus ippsConvert_32f64f(const Ipp32f*
pSrc
, Ipp64f*
pDst
, int
len
);
IppStatus ippsConvert_64s64f(const Ipp64s*
pSrc
, Ipp64f*
pDst
, Ipp32u
len
);
IppStatus ippsConvert_64f32f(const Ipp64f*
pSrc
, Ipp32f*
pDst
, int
len
);
IppStatus ippsConvert_16s32f_Sfs(const Ipp16s*
pSrc
, Ipp32f*
pDst
, int
len
, int
scaleFactor
);
IppStatus ippsConvert_16s64f_Sfs(const Ipp16s*
pSrc
, Ipp64f*
pDst
, int
len
, int
scaleFactor
);
IppStatus ippsConvert_32s16s_Sfs(const Ipp32s*
pSrc
, Ipp16s*
pDst
, int
len
, int
scaleFactor
);
IppStatus ippsConvert_32s32f_Sfs(const Ipp32s*
pSrc
, Ipp32f*
pDst
, int
len
, int
scaleFactor
);
IppStatus ippsConvert_32s64f_Sfs(const Ipp32s*
pSrc
, Ipp64f*
pDst
, int
len
, int
scaleFactor
);
IppStatus ippsConvert_32f8s_Sfs(const Ipp32f*
pSrc
, Ipp8s*
pDst
, int
len
, IppRoundMode
rndMode
, int
scaleFactor
);
IppStatus ippsConvert_32f8u_Sfs(const Ipp32f*
pSrc
, Ipp8u*
pDst
, int
len
, IppRoundMode
rndMode
, int
scaleFactor
);
IppStatus ippsConvert_32f16s_Sfs(const Ipp32f*
pSrc
, Ipp16s*
pDst
, int
len
, IppRoundMode
rndMode
, int
scaleFactor
);
IppStatus ippsConvert_32f16u_Sfs(const Ipp32f*
pSrc
, Ipp16u*
pDst
, int
len
, IppRoundMode
rndMode
, int
scaleFactor
);
IppStatus ippsConvert_32f32s_Sfs(const Ipp32f*
pSrc
, Ipp32s*
pDst
, int
len
, IppRoundMode
rndMode
, int
scaleFactor
);
IppStatus ippsConvert_64f8s_Sfs(const Ipp64f*
pSrc
, Ipp8s*
pDst
, int
len
, IppRoundMode
rndMode
, int
scaleFactor
);
IppStatus ippsConvert_64f8u_Sfs(const Ipp64f*
pSrc
, Ipp8u*
pDst
, int
len
, IppRoundMode
rndMode
, int
scaleFactor
);
IppStatus ippsConvert_64f16u_Sfs(const Ipp64f*
pSrc
, Ipp16u*
pDst
, int
len
, IppRoundMode
rndMode
, int
scaleFactor
);
IppStatus ippsConvert_64s32s_Sfs(const Ipp64s*
pSrc
, Ipp32s*
pDst
, int
len
, IppRoundMode
rndMode
, int
scaleFactor
);
IppStatus ippsConvert_64f16s_Sfs(const Ipp64f*
pSrc
, Ipp16s*
pDst
, int
len
, IppRoundMode
rndMode
, int
scaleFactor
);
IppStatus ippsConvert_64f32s_Sfs(const Ipp64f*
pSrc
, Ipp32s*
pDst
, int
len
, IppRoundMode
rndMode
, int
scaleFactor
);
IppStatus ippsConvert_64f64s_Sfs(const Ipp64f*
pSrc
, Ipp64s*
pDst
, Ipp32u
len
, IppRoundMode
rndMode
, int
scaleFactor
);
IppStatus ippsConvert_24u32u(const Ipp8u*
pSrc
, Ipp32u*
pDst
, int
len
);
IppStatus ippsConvert_24u32f(const Ipp8u*
pSrc
, Ipp32f*
pDst
, int
len
);
IppStatus ippsConvert_32u24u_Sfs(const Ipp32u*
pSrc
, Ipp8u*
pDst
, int
len
, int
scaleFactor
);
IppStatus ippsConvert_32f24u_Sfs(const Ipp32f*
pSrc
, Ipp8u*
pDst
, int
len
, int
scaleFactor
);
IppStatus ippsConvert_24s32s(const Ipp8u*
pSrc
, Ipp32s*
pDst
, int
len
);
IppStatus ippsConvert_24s32f(const Ipp8u*
pSrc
, Ipp32f*
pDst
, int
len
);
IppStatus ippsConvert_32s24s_Sfs(const Ipp32s*
pSrc
, Ipp8u*
pDst
, int
len
, int
scaleFactor
);
IppStatus ippsConvert_32f24s_Sfs(const Ipp32f*
pSrc
, Ipp8u*
pDst
, int
len
, int
scaleFactor
);
IppStatus ippsConvert_16s16f(const Ipp16s*
pSrc
, Ipp16f*
pDst
, int
len
, IppRoundMode
rndMode
);
IppStatus ippsConvert_32f16f(const Ipp32f*
pSrc
, Ipp16f*
pDst
, int
len
, IppRoundMode
rndMode
);
IppStatus ippsConvert_16f16s_Sfs(const Ipp16f*
pSrc
, Ipp16s*
pDst
, int
len
, IppRoundMode
rndMode
, int
scaleFactor
);
IppStatus ippsConvert_16f32f(const Ipp16f*
pSrc
, Ipp32f*
pDst
, int
len
);
Include Files
ipps.h
Domain Dependencies
Headers:
ippcore.h
,
ippvm.h
Libraries:
ippcore.lib
,
ippvm.lib
Parameters
pSrc
Pointer to the source vector.
pDst
Pointer to the destination vector.
rndMode
Rounding mode, the following values are possible:
ippRndZero
floating-point values are truncated to zero
ippRndNear
floating-point values are rounded to the nearest even integer when the fractional part equals 0.5; otherwise they are rounded to the nearest integer
ippRndFinancial
floating-point values are rounded down to the nearest integer when the fractional part is less than 0.5, or rounded up to the nearest integer if the fractional part is equal or greater than 0.5.
len
Number of elements in the vector.
scaleFactor
Scale factor, refer to Integer Scaling.
Description
This function converts the type of data contained in the vector
pSrc
and stores the results in
pDst
.
Functions with the
Sfs
suffix perform scaling of the result value in accordance with the
scaleFactor
value. The converted result is saturated if it exceeds the output data range.
Functions that operate with
16f
data do not support the
ippRndFinancial
rounding mode.
Return Values
ippStsNoErr
Indicates no error.
ippStsNullPtrErr
Indicates an error when the
pDst
or
pSrc
pointer is
NULL
.
ippStsSizeErr
Indicates an error when
len
is less than or equal to 0.
ippStsRoundModeNotSupportedErr
Indicates an error when the specified rounding mode is not supported.

Example



    
/******************************************************************************* * Copyright 2015-2020 Intel Corporation. * * This software and the related documents are Intel copyrighted materials, and * your use of them is governed by the express license under which they were * provided to you (License). Unless the License provides otherwise, you may not * use, modify, copy, publish, distribute, disclose or transmit this software or * the related documents without Intel's prior written permission. * * This software and the related documents are provided as is, with no express * or implied warranties, other than those that are expressly stated in the * License. *******************************************************************************/ #include <stdio.h> #include "ipp.h" /* Next two defines are created to simplify code reading and understanding */ #define EXIT_MAIN exitLine: /* Label for Exit */ #define check_sts(st) if((st) != ippStsNoErr) goto exitLine; /* Go to Exit if Intel(R) Integrated Performance Primitives(Intel(R) IPP) function returned status different from ippStsNoErr */ /* Results of ippMalloc() are not validated because Intel(R) IPP functions perform bad arguments check and will return an appropriate status */ int main() { IppStatus status; Ipp32s src32s[2] = { 33000, -33000 }; Ipp32f src32f[2] = { 126.6, -125.4 }; Ipp32f src_32f[2] = { 113.12, -113.6 }; Ipp32f src1_32f[5] = { -2.5, -2.4, 1.4, 1.5, 1.6 }; Ipp8s src_8s[2] = { 125, -125 }; Ipp8u src8[1] = { 255 }; Ipp32f dst32f[1]; Ipp16s dst16[2]; Ipp16s dst_16s[2]; Ipp8u dst8u[2]; Ipp8s dstN8[2]; Ipp8s dstZ8[2]; Ipp8s dstF8[5]; int scaleFactor = 0; // no scaling check_sts(status = ippsConvert_8s16s(src_8s, dst_16s, 2)); printf("\n ippsConvert_8s16s Source: %d %d; Result: %d %d\n", src_8s[0], src_8s[1], dst_16s[0], dst_16s[1]); check_sts(status = ippsConvert_8u32f(src8, dst32f, 1)); printf("\n ippsConvert_8u32f Source: %d; Result: %.1f\n", src8[0], dst32f[0]); check_sts(status = ippsConvert_32s16s(src32s, dst16, 2)); printf("\n ippsConvert_32s16s Source: %d %d; Result: %d %d\n", src32s[0], src32s[1], dst16[0], dst16[1]); check_sts(status = ippsConvert_32f8s_Sfs(src32f, dstN8, 2, ippRndNear, scaleFactor)); printf("\n ippsConvert_32f8s_Sfs : ippRndNear\n Source: %.1f %.1f; Result: %d %d\n", src32f[0], src32f[1], dstN8[0], dstN8[1]); check_sts(status = ippsConvert_32f8s_Sfs(src32f, dstZ8, 2, ippRndZero, scaleFactor)); printf("\n ippsConvert_32f8s_Sfs : ippRndZero\n Source: %.1f %.1f; Result: %d %d\n", src32f[0], src32f[1], dstZ8[0], dstZ8[1]); check_sts(status = ippsConvert_32f8u_Sfs(src_32f, dst8u, 2, ippRndNear, scaleFactor)); printf("\n ippsConvert_32f8u_Sfs : ippRndNear\n Source: %.1f %.1f; Result: %d %d\n", src_32f[0], src_32f[1], dst8u[0], dst8u[1]); check_sts(status = ippsConvert_32f8s_Sfs(src1_32f, dstF8, 5, ippRndFinancial, scaleFactor)); printf("\n ippsConvert_32f8u_Sfs : ippRndFinancial\n Source: %.1f %.1f %.1f %.1f %.1f; Result: %d %d %d %d %d\n", src1_32f[0], src1_32f[1], src1_32f[2], src1_32f[3], src1_32f[4], dstF8[0], dstF8[1], dstF8[2], dstF8[3], dstF8[4]); EXIT_MAIN printf("\nExit status %d (%s)\n", (int)status, ippGetStatusString(status)); return (int)status; } /* The function ippsConvert_32f16f has the following specific when it processes the number that are not in the range [MinVal16f..MaxVal16f]: If x > MaxVal16f then{ If(rndMode == IppRndNear) then{ y = Convert_32f16f(x) = +INF } If(rndMode == IppRndZero) then{ If(x == +INF) then{ y = Convert_32f16f(x) = +INF }else { y = Convert_32f16f(x) = MaxVal16f } } } If x < MinVal16f then{ If(rndMode == IppRndNear) then{ y = Convert_32f16f(x) = -INF } If(rndMode == IppRndZero) then{ If(x == -INF) then{ y = Convert_32f16f(x) = -INF }else { y = Convert_32f16f(x) = M in Val16f } } } */

Product and Performance Information

1

Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors. These optimizations include SSE2, SSE3, and SSSE3 instruction sets and other optimizations. Intel does not guarantee the availability, functionality, or effectiveness of any optimization on microprocessors not manufactured by Intel. Microprocessor-dependent optimizations in this product are intended for use with Intel microprocessors. Certain optimizations not specific to Intel microarchitecture are reserved for Intel microprocessors. Please refer to the applicable product User and Reference Guides for more information regarding the specific instruction sets covered by this notice.

Notice revision #20110804