All SDK implementations delegate memory management to the application. The application must allocate sufficient memory for input and output parameters and buffers, and de-allocate it when SDK functions complete their operations. During execution, the SDK functions use callback functions to the application to manage memory for video frames through external allocator interface mfxFrameAllocator.
mfxBufferAllocator interface is deprecated.
If an application needs to control the allocation of video frames, it can use callback functions through the mfxFrameAllocator interface. If an application does not specify an allocator, an internal allocator is used. However, if an application uses video memory surfaces for input and output, it must specify the hardware acceleration device and an external frame allocator using mfxFrameAllocator.
The external frame allocator can allocate different frame types:
· in system memory and
· in video memory, as “decoder render targets” or “processor render targets.” See the section Working with hardware acceleration for additional details.
The external frame allocator responds only to frame allocation requests for the requested memory type and returns MFX_ERR_UNSUPPORTED for all others. The allocation request uses flags, part of memory type field, to indicate which SDK class initiates the request, so the external frame allocator can respond accordingly. Example 11 illustrates a simple external frame allocator.
Example 11: Example Frame Allocator
For system memory, it is highly recommended to allocate memory for all planes of the same frame as a single buffer (using one single malloc call).