Updated on 2022-03-13 GMT+08:00

Applying for DVPP Memory

The Matrix framework provides the memory allocation API HIAI_DVPP_DMalloc and memory freeing API HIAI_DVPP_DFree. HIAI_DVPP_DMalloc is used to allocate memory that meets DVPP alignment requirements. The two APIs must be used in pairs. To prevent memory leakage, you are advised to use the shared pointer to manage the allocated memory. The implementation code is as follows:

uint8_t* buffer = nullptr;
HIAI_StatusT ret = hiai::HIAIMemory::HIAI_DVPP_DMalloc(dataSize,  (void*&) buffer);
std::shared_ptr<uint8_t> dataBuffer =  std::shared_ptr<uint8_t>( buffer, \
[](std::uint8_t* data) hiai::HIAIMemory::HIAI_DVPP_DFree(data);});

In addition, these APIs are available only on the device side. The memory allocated by HIAI_DVPP_DMalloc can be used for high-speed data transmission from the device to host. In this mode, the memory is freed by the Matrix framework. For details, see the sample code DvppDecodeResize.