/*
// Copyright 2015 2018 Intel Corporation All Rights Reserved.
//
// The source code, information and material ("Material") contained herein is
// owned by Intel Corporation or its suppliers or licensors, and title
// to such Material remains with Intel Corporation or its suppliers or
// licensors. The Material contains proprietary information of Intel
// or its suppliers and licensors. The Material is protected by worldwide
// copyright laws and treaty provisions. No part of the Material may be used,
// copied, reproduced, modified, published, uploaded, posted, transmitted,
// distributed or disclosed in any way without Intel's prior express written
// permission. No license under any patent, copyright or other intellectual
// property rights in the Material is granted to or conferred upon you,
// either expressly, by implication, inducement, estoppel or otherwise.
// Any license under such intellectual property rights must be express and
// approved by Intel in writing.
//
// Unless otherwise agreed by Intel in writing,
// you may not remove or alter this notice or any other notice embedded in
// Materials by Intel or Intel's suppliers or licensors in any way.
*/
#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
}
}
}
*/