Link Copied
1 2
3 4
5 6
7 8
If use ippiMalloc_xtoallocate memory for the image,
ippiMalloc
Allocates memory aligned to 32-byte boundary for good performance.
then the stepBytesis always a multiple of 32.
SotheconvertWidthStep1/2 is 32. It is not image width 2, not image*sizeof(Ipp16s)=4 or
image*sizeof(Ipp32f)=8 .
the space between 4-32 will be padded with 0.
If print a imagewhich is allocated by ippiMalloc, a pefered solution should be
for (m = 0 ; m < height; m++)
{
for (n = 0 ; n
printf("%d ", pGray[n+m*(stepGray)/sizeof(Ipp16s)]);
}
printf("\n\n");
}
Forthe value of GrayImg->widthStep,you maymake sure if it is 4-bytes aligned or it is 32-bytes aligned. But printf the image 8u,
for (n = 0 ; n < GrayImg->widthStep ; n++) 'dbetter to change intofor (n = 0 ; n
Icreat asmallexample code for yourreference.
#include
#include "ipp.h"
int main()
{
// Print the version of ipp being used
const IppLibraryVersion* lib = ippiGetLibVersion();
printf("%s %s %d.%d.%d.%d\n", lib->Name, lib->Version,lib->major, lib->minor, lib->majorBuild, lib->build);
/*src 1 2 3 4 5 6 7 8 9
I was waiting for this result:
dsl 1 4 9 16 25 36 49 64 81
Here is the kind of dst I've acutally received:
1 0 4 0 9 0 16 0 25
More specificaly, here is my code:
*/
int width=2;
int height=4;
IppiSize Roi = {width, height};
int convertWidthStep1, convertWidthStep2;
Ipp16s* pEdgeVert = ippiMalloc_16s_C1(width, height, &convertWidthStep1);
Ipp32f* pEdgeBorder = ippiMalloc_32f_C1(width, height, &convertWidthStep2);
int m,n;
Ipp16s temp=1;
printf("the src image\n");
for (m = 0 ; m < height; m++)
{
for (n = 0 ; n < width ; n++)
{
pEdgeVert[n+m*convertWidthStep1/sizeof(Ipp16s)]=temp;
temp++;
printf("%d ", pEdgeVert[n+m*convertWidthStep1/sizeof(Ipp16u)]);
}
printf("\n");
}
printf("\n");
printf("convertWidthStep1 is %d,\t convertWidthStep2 is %d\n ", convertWidthStep1,convertWidthStep2);
printf("image width is %d,\t image width*sizeof(Ipp32f)is %d \n", width,width*sizeof(Ipp32f) );
// ... processing of pEdgeVert to get some values in
ippiSet_32f_C1R(0, pEdgeBorder, convertWidthStep2, Roi);
IppStatus status=ippiAddSquare_16u32f_C1IR((Ipp16u*) pEdgeVert,convertWidthStep1, pEdgeBorder, convertWidthStep2,Roi);
printf("\n%d : %s\n\n", status, ippGetStatusString(status));
printf("the result image\n");
for (m = 0 ; m < height; m++)
{
for (n = 0 ; n < width ; n++)
{
printf("%f ", pEdgeBorder[n+m*convertWidthStep1/sizeof(Ipp32f)]);
}
printf("\n");
}
printf("\n");
return 0;
}
The result,
ippiv8-6.1.dll 6.1 build 137.53 6.1.137.842
the src image
1 2
3 4
5 6
7 8
convertWidthStep1 is 32, convertWidthStep2 is 32
image width is 2, image width*sizeof(Ipp32f)is 8
0 : ippStsNoErr: No error, it's OK
the result image
1.000000 4.000000
9.000000 16.000000
25.000000 36.000000
49.000000 64.000000
Press any key to continue . . .
Regards,
Ying
For more complete information about compiler optimizations, see our Optimization Notice.