VCLib Documentation  6.12.2

Memory Management

Memory Management

Modules

 Fast Buffer
 

Functions

I32 ImageAllocateEdge (image *src, image *dst, I32 edgeX, I32 edgeY)
 Allocates a New Image With Padding Content from Originating Image. More...
 
void ImageAssign_Bayer (image *img)
 Assigns a correct aligned IMAGE_BAYER Image with maximum dimension. More...
 
I32 ImageROI (image *roi, I8 copyIff1, image *src, I32 x0, I32 y0, I32 dx, I32 dy)
 Gets a Sub-Region of an Image. More...
 
I32 ImageOffset (I32 *x0, I32 *y0, image *roi, I32 chRoi, image *src, I32 chSrc)
 Gets the Offset for a Sub-Region of an Image. More...
 
#define rlcmalloc(x)   (U16 *)sysmalloc((x+1)/2, MDATA)
 Allocation Helper for RLC Data. More...
 
#define rlcfree(x)   sysfree((void *)x)
 Frees Memory from RLC Data. More...
 
U8ImageAllocate (image *img, U32 type, U32 dx, U32 dy)
 Allocates Memory for an Image. More...
 
void ImageFree (image *img)
 Release Memory for an Image Variable. More...
 

Detailed Description

Functions in this group provide methods for memory management.

Macro Definition Documentation

◆ rlcmalloc

#define rlcmalloc (   x)    (U16 *)sysmalloc((x+1)/2, MDATA)

The macro returns a pointer to a heap memory area for size RLC Items (U16).

◆ rlcfree

#define rlcfree (   x)    sysfree((void *)x)

The macro simply calls sysfree().

Function Documentation

◆ ImageAllocate()

U8 * ImageAllocate ( image img,
U32  type,
U32  dx,
U32  dy 
)

This function allocates memory for an image and sets the image variable struct components to the appropriate values. type is the image type, dx and dy are the horizontal and vertical dimensions of the image. The function allocates memory for a tight storage, i.e. img->pitch is set to dx.

type Definition Image Type Memory Requirement st ccmp1 ccmp2
0 IMAGE_GREY Grey-Scale Image (U8) 1 * dy * pitch grey
1 IMAGE_BAYER Bayer Pattern 1 * dy * pitch bayer
2 IMAGE_RGB Color Image RGB 3 * dy * pitch red green blue
3 IMAGE_CBCR444 Color Image YCbCr 4:4:4 3 * dy * pitch y u v
4 IMAGE_CBCR411 Color Image YCbCr 4:1:1 3/2 * dy * pitch y u v
5 IMAGE_YUVNORM Normalized YcbCr 4:4:4 3 * dy * pitch y u* v*
6 IMAGE_IHS Color Image IHS (HSI) 3 * dy * pitch i h s
7 IMAGE_RGBO Reserved
8 IMAGE_VECTOR Vector Image 2 * dy * pitch mag dir
9 IMAGE_GREY16 Grey-Scale Image (U16) 2 * dy * pitch grey
10 IMAGE_GREY32 Grey-Scale Image (U32) 4 * dy * pitch grey
11 IMAGE_CMPLX16 Complex Valued Image 4 * dy * pitch cmplx
13 IMAGE_CBCR422 Color Image YCbCr 4:2:2 2 * dy * pitch y u v
14 IMAGE_YCBYCR Reserved

The function returns the start address of the memory block allocated. If out of memory, the NULL pointer is returned.

Parameters
imgDestination Image Pointer.
typeTypes of Image Data.
dxHorizontal Pixel Count.
dyVertical Pixel Count.
Memory Consumption
See Tabular.
See also
ImageFree().
Return values
NULLon Allocation Failure.
AddressPointer of the New Allocated Memory (equals img->st).
NULLon Allocation Failure.
AddressPointer of the New Allocated Memory (equals img->st).

◆ ImageAllocateEdge()

I32 ImageAllocateEdge ( image src,
image dst,
I32  edgeX,
I32  edgeY 
)

Allocates a new image consisting of an additional padding region around the contents of the given image.

The padding region is being filled with the color of the next lying horizontal or vertical pixel.

ImageAllocateEdge.png
Parameters
srcSource Image Pointer, Type: IMAGE_GREY.
dstDestination Image Pointer, Type: IMAGE_GREY.
edgeXPixel Count added left and right.
edgeYPixel Count added top and bottom.
Returns
Standard Error Code.
Return values
ERR_MEMORYiff Memory could not be allocated.
ERR_NONEiff OK.

◆ ImageFree()

void ImageFree ( image img)

This function frees the memory for an image previously allocated with ImageAllocate().

Memory Consumption
None.
See also
ImageAllocate().

◆ ImageAssign_Bayer()

void ImageAssign_Bayer ( image img)

This function assigns an image of type IMAGE_BAYER with respect to the sensor Bayer pattern alignment. This is necessary, since depending on the sensor type, the first pixel may be non-red which is to be guaranteed for our functions to work properly. The image has the maximum possible size. Due to realignment the result image dx and/or dy values may be one pixel smaller than the total sensor size.

Parameters
imgThe Assignment Image.

◆ ImageROI()

I32 ImageROI ( image roi,
I8  copyIff1,
image src,
I32  x0,
I32  y0,
I32  dx,
I32  dy 
)

This functions gets a sub-region of a given image. Depending on the input image type, x0, y0, dx, dy may be divideable by 2. If copyIff1 is set to one, it is assumed, that roi is pre-allocated, and the copy routine will be called. Else it is assumed, that roi is only used to reference the src image memory directly, and the st, ccmp1, ccmp2 will point to the src image data.

Parameters
roiOutput Image.
copyIff1If 1: src Content is copied, else roi refers to src data.
srcInput Image.
x0,y0,dx,dyOutput ROI at the source image, may be needed to be divideable by 2.
Return values
ERR_PARAMif either of x0, y0, dx, dy is smaller than 0 or needed to be divideable by 2 by input image type.
ERR_BOUNDSif ROI exceeds source image.
ERR_TYPEon source image type error.
copy()if copy() fails.

◆ ImageOffset()

I32 ImageOffset ( I32 x0,
I32 y0,
image roi,
I32  chRoi,
image src,
I32  chSrc 
)

This functions gets the offset for a sub-region of a given image. As Formula:

 addrDiff = (roiAddrOfCh - srcAddrOfCh)/srcPxBytes;
 x0 = (addrDiff<0) ? ((addrDiff % srcPitch + srcPitch)%srcPitch) : (addrDiff%srcPitch);
 y0 = (addrDiff<0) ? ((addrDiff        + 1 - srcPitch)/srcPitch) : (addrDiff/srcPitch);
Parameters
x0,y0Output Offset of the image roi to the image src.
roi,srcInput Images.
chRoi,chSrcChannels of images which are used for calculation.
Return values
ERR_TYPEon source image type discrepance, or unsupported type.
ERR_PARAMon channel selector range failure.