Malloc

Allocates memory aligned to 32-byte boundary.

Syntax

Ipp<datatype>* ippiMalloc_<mod>(int widthPixels, int heightPixels, int* pStepBytes);

Supported values for mod:

8u_C1 16u_C1 16s_C1 32s_C1 32f_C1 32sc_C1 32fc_C1
8u_C2 16u_C2 16s_C2 32s_C2 32f_C2 32sc_C2 32fc_C2
8u_C3 16u_C3 16s_C3 32s_C3 32f_C3 32sc_C3 32fc_C3
8u_C4 16u_C4 16s_C4 32s_C4 32f_C4 32sc_C4 32fc_C4
8u_AC4 16u_AC4 16s_AC4 32s_AC4 32f_AC4 32sc_AC4 32fc_AC4

Parameters

widthPixels

Width of an image in pixels

heightPixels

Height of an image in pixels

pStepBytes

Pointer to the distance in bytes between starts of consecutive lines in the image

Description

The function ippiMalloc is declared in the ippi.h file. This function allocates a memory block aligned to a 32-byte boundary for elements of different data types. Every line of the image is aligned in accordance with the pStepBytes parameter, which is calculated by the ippiMalloc function and returned for further use.

The function ippiMalloc allocates one continuous memory block, whereas functions that operate on planar images require an array of separate pointers (IppType* plane[3]) to each plane as input. The ippiMalloc function should be called three times in this case. The code Example Setting Values to Pointers to Image Planes demonstrates how to construct such an array and set correct values to the pointers to use the allocated memory block with the Intel IPP functions operating on planar images. Note that pStepBytes should be specified for each plane. The example is given for 8u data type.

Setting Values to Pointers to Image Planes

int stepBytes[3];
Ipp8u* plane[3];
   plane[0] = ippiMalloc_8u_C1(widthPixels, heightPixels,
                               &(stepBytes [0]));
   plane[1] = ippiMalloc_8u_C1(widthPixels/2, heightPixels/2,
                               &(stepBytes [1]));
   plane[2] = ippiMalloc_8u_C1(widthPixels/2, heightPixels/2,
                               &(stepBytes [2]));

Return Values

The return value of ippiMalloc function is a pointer to an aligned memory block.

If no memory is available in the system, the NULL value is returned.

To free the allocated memory block, use the ippiFree function.


Submit feedback on this help topic

Copyright © 2000 - 2011, Intel Corporation. All rights reserved.