MbufCreate2d()函数

Synopsis

Create a two-dimensional data buffer.

Format

MIL_ID MbufCreate2d(SystemId, SizeX, SizeY, DataType, Attribute, ControlFlag, Pitch, DataPtr, BufIdPtr)

MIL_ID SystemId; System identifier
long SizeX; X dimension
long SizeY; Y dimension
long DataType; Pixel depth and range
long Attribute; Buffer attributes
long ControlFlag; Creation control flag
long Pitch; Value of pitch if necessary
void *DataPtr; Array of data buffer pointers
MIL_ID *BufIdPtr; Storage location for buffer identifier

Description

This function creates a two-dimensional data buffer that maps to a user-specified data array and associates it with a specific MIL system. This function should be used with great care. It is generally better to leave buffer allocation, data loading and memory control to MIL (MbufAlloc2d, MbufGet2d, MbufPut2d), since MIL might require special memory attributes (such as non-paged memory) or alignment in order to associate the buffer with a particular target system. MbufInquire can be used to get the pointer to a MIL allocated buffer.

The appropriate memory must be allocated by the user before calling MbufCreate2d and freed when no longer required, after calling MbufFree.

The SystemId parameter specifies the MIL system with which the buffer will be associated. This parameter must be set to a valid system identifier, M_DEFAULT_HOST or M_DEFAULT. To use the default Host system of the current MIL application, specify M_DEFAULT_HOST. If you specify M_DEFAULT, MIL will select the most appropriate system with which to associate the buffer (it can be the Host system or any already allocated system).

The SizeX and SizeY parameters specify the buffer width and height, respectively, in the units appropriate for the selected buffer attribute. For example, if the buffer has an image buffer attribute, width and height are specified in pixels.

The DataType parameter specifies a combination of two values: the depth and range of the data. Express the depth in bits and give the data range as one of the following:

Data Type Description Depth (in bits)
M_SIGNED Signed data 8, 16, or 32
M_UNSIGNED Unsigned data (default) 1, 8, 16, or 32
M_FLOAT Floating point data 32

For example, when allocating a 8-bit unsigned buffer, you would set the DataType parameter to (8 + M_UNSIGNED).

The Attribute parameter defines the buffer usage. The system uses this information to determine where to allocate the buffer in physical memory. This parameter should be set to M_LUT or to M_IMAGE + specifier. The specifier can be one or more of the following:

Usage specifiers:

M_DISP An image buffer that can be displayed.
M_GRAB An image buffer in which to grab data from input devices.
M_PROC An image buffer that can be processed.

For example, to allocate an image buffer that can be processed and displayed, you should set the Attribute parameter to M_IMAGE + M_PROC + M_DISP.

Board-dependent location specifiers:

M_ON_BOARD Force the buffer in the system memory.
M_OFF_BOARD Force the buffer in the Host memory.
M_OVR Force the buffer in the overlay display surface.
M_NON_PAGED Force the buffer in non-pageable memory.
M_SINGLE Force a unique copy of the buffer.

Board-dependent internal storage format specifiers:

M_HOST_ADDRESS+M_PITCH+BYTE DataPtr is the Host CPU address. The pitch is in bytes.
M_PHYSICAL_ADDRESS+M_PITCH DataPtr is the physical address of the data buffer in memory. The pitch is in pixels.
M_PHYSICAL_ADDRESS+M_PITCH_BYTE DataPtr is the physical address of the data buffer. The pitch is in bytes.

The Pitch parameter specifies the pitch in pixels or bytes (as determined by ControlFlag) or M_DEFAULT. The pitch is the length of the buffer’s memory (not data) line.

The DataPtr parameter is a pointer to the data array to which to map the created MIL buffer.

The BufIdPtr parameter specifies the address of the variable in which the buffer identifier is to be written. Since the MbufCreate2d function also returns the buffer identifier, you can set this parameter to M_NULL. If allocation fails, M_NULL is written as the identifier.

Returned value

The returned value is the buffer identifier. If allocation fails, an identifier of 0 is returned.

Status

Current limitation:

  • For M_KERNEL data buffers, the data type must be 8-bit signed or unsigned.
  • For M_STRUCT_ELEMENT data buffers, the data type must be 32-bit signed or unsigned. If signed, the range is -32768 to +32767. If unsigned, the range is 0 to +65535.

See also

MbufAlloc2d, MbufGet2d, MbufPut2d, MbufFree