# Memory¶

Functions for internal memory allocation and management.

## API¶

### MFXMemory_GetSurfaceForVPP¶

mfxStatus MFXMemory_GetSurfaceForVPP(mfxSession session, mfxFrameSurface1 **surface)

Returns surface which can be used as input for VPP.

VPP should be initialized before this call. Surface should be released with mfxFrameSurface1::FrameInterface.Release(…) after usage. Th value of mfxFrameSurface1::Data.Locked for the returned surface is 0.

Return

MFX_ERR_NONE The function completed successfully.

MFX_ERR_NULL_PTR If surface is NULL.

MFX_ERR_INVALID_HANDLE If session was not initialized.

MFX_ERR_NOT_INITIALIZED If VPP was not initialized (allocator needs to know surface size from somewhere).

MFX_ERR_MEMORY_ALLOC In case of any other internal allocation error.

Parameters
• [in] session: Session handle.

• [out] surface: Pointer is set to valid mfxFrameSurface1 object.

### MFXMemory_GetSurfaceForEncode¶

mfxStatus MFXMemory_GetSurfaceForEncode(mfxSession session, mfxFrameSurface1 **surface)

Returns a surface which can be used as input for the encoder.

Encoder should be initialized before this call. Surface should be released with mfxFrameSurface1::FrameInterface.Release(…) after usage. The value of mfxFrameSurface1::Data.Locked for the returned surface is 0.

Return

MFX_ERR_NONE The function completed successfully.

MFX_ERR_NULL_PTR If surface is NULL.

MFX_ERR_INVALID_HANDLE If session was not initialized.

MFX_ERR_NOT_INITIALIZED If the encoder was not initialized (allocator needs to know surface size from somewhere).

MFX_ERR_MEMORY_ALLOC In case of any other internal allocation error.

Parameters
• [in] session: Session handle.

• [out] surface: Pointer is set to valid mfxFrameSurface1 object.

### MFXMemory_GetSurfaceForDecode¶

mfxStatus MFXMemory_GetSurfaceForDecode(mfxSession session, mfxFrameSurface1 **surface)

Returns a surface which can be used as input for the decoder.

Decoder should be initialized before this call. Surface should be released with mfxFrameSurface1::FrameInterface.Release(…) after usage. The value of mfxFrameSurface1::Data.Locked for the returned surface is 0.’

Note

This function was added to simplify transition from legacy surface management to the proposed internal allocation approach. Previously, the user allocated surfaces for the working pool and fed them to the decoder using DecodeFrameAsync calls. With MFXMemory_GetSurfaceForDecode it is possible to change the existing pipeline by just changing the source of work surfaces. Newly developed applications should prefer direct usage of DecodeFrameAsync with internal allocation.

Return

MFX_ERR_NONE The function completed successfully.

MFX_ERR_NULL_PTR If surface is NULL.

MFX_ERR_INVALID_HANDLE If session was not initialized.

MFX_ERR_NOT_INITIALIZED If the decoder was not initialized (allocator needs to know surface size from somewhere).

MFX_ERR_MEMORY_ALLOC Other internal allocation error.

Parameters
• [in] session: Session handle.

• [out] surface: Pointer is set to valid mfxFrameSurface1 object.