#include #include "depend_headers.h" #include "dvpp_headers.h" using namespace std; // static int snap_free = 0; class DvppDataMemory : public DeviceMemory { public: DvppDataMemory(int _channel, int _width, int _width_stride, int _height, int _height_stride, int _size, string _id, string _dev_id, bool _key_frame, unsigned long long frame_nb) :DeviceMemory(_channel, _width, _width_stride, _height, _height_stride, _id, _dev_id, _key_frame, frame_nb, false){ data_size = _size; data_type = 1; int ret = acldvppMalloc((void **)&pHwRgb, data_size); if(ret != ACL_ERROR_NONE){ LOG_ERROR("[{}]- acldvppMalloc failed", id); } } DvppDataMemory( int _width, int _width_stride, int _height, int _height_stride, int _size, string _id, string _dev_id, bool _key_frame, unsigned long long frame_nb, unsigned char * pHwData) :DeviceMemory(-1, _width, _width_stride, _height, _height_stride, _id, _dev_id, _key_frame, frame_nb, false){ data_size = _size; data_type = 1; pHwRgb = pHwData; } DvppDataMemory(DvppDataMemory* pSrc):DeviceMemory(-1, pSrc->getWidth(), pSrc->getWidthStride(), pSrc->getHeight(), pSrc->getHeightStride(), pSrc->getId(), pSrc->getDeviceId(), pSrc->isKeyFrame(), pSrc->getFrameNb(), false){ if(pSrc == nullptr) { LOG_ERROR("[{}]- pSrc is nullptr", pSrc->getId()); return; } data_size = pSrc->getSize(); int ret = acldvppMalloc((void **)&pHwRgb, data_size); if(ret != ACL_ERROR_NONE){ LOG_ERROR("[{}]- acldvppMalloc failed", pSrc->getId()); return; } ret = aclrtMemcpy(pHwRgb, data_size, pSrc->getMem(), pSrc->getSize(), ACL_MEMCPY_DEVICE_TO_DEVICE); if(ret != ACL_ERROR_NONE){ acldvppFree(pHwRgb); LOG_ERROR("[{}]- aclrtMemcpy failed", pSrc->getId()); return; } data_type = 2; timestamp = UtilTools::get_cur_time_ms(); } ~DvppDataMemory(){ // if (data_type == 2) // { // snap_free++; // LOG_INFO("[{}]- snap_free: {}", getId(), snap_free); // } if (pHwRgb) { int ret = acldvppFree(pHwRgb); if(ret != ACL_ERROR_NONE){ LOG_ERROR("[{}]- acldvppFree failed", id); } pHwRgb = nullptr; } } public: int data_type; // 0: rgb , 1: NV12 };