#include "VpcUtils.h" #include "depend_headers.h" #define ALIGN_UP(val, align) (((val) % (align) == 0) ? (val) : (((val) / (align) + 1) * (align))) #define CHECK_AND_RETURN(ret, message) \ if(ret != 0) {LOG_ERROR("{}", message); return ret;} #define CHECK_NOT_RETURN(ret, message) \ if(ret != 0) {LOG_ERROR("{}", message);} #define CHECK_AND_RETURN_NOVALUE(ret, message) \ if(ret != 0) {LOG_ERROR("{}", message); return;} #define CHECK_AND_BREAK(ret, message) \ if(ret != 0) {LOG_ERROR("{}", message); break;} static void adjustCoordinate(uint32_t& left, uint32_t& right, uint32_t& top, uint32_t& bottom, const uint32_t& width, const uint32_t& height) { uint32_t cropWidth = right - left; uint32_t cropHeight = bottom - top; if(cropWidth < 16) { cropWidth += 16; //小于16的似乎抠不了图 right += 16; } if (left < 0) { left = 0; right = cropWidth; } if (right >= width){ right = width -1; left = right - cropWidth; } if (top < 0) { top = 0; bottom = cropHeight; } if (bottom >= height){ bottom = height -1; top = bottom - cropHeight; } } VpcUtils::VpcUtils(){ } VpcUtils::~VpcUtils(){ if(nullptr != stream_){ aclrtDestroyStream(stream_); } if(context_){ aclrtDestroyContext(context_); } if (dvppChannelDesc_) { (void)acldvppDestroyChannel(dvppChannelDesc_); (void)acldvppDestroyChannelDesc(dvppChannelDesc_); dvppChannelDesc_ = nullptr; } } int VpcUtils::init(int devId){ m_devId = devId; aclrtSetDevice(m_devId); aclrtCreateContext(&context_, m_devId); CHECK_AND_RETURN(aclrtSetCurrentContext(context_), "aclrtSetCurrentContext failed"); CHECK_AND_RETURN(aclrtCreateStream(&stream_), "aclrtCreateStream failed! "); dvppChannelDesc_ = acldvppCreateChannelDesc(); int ret = ACL_ERROR_NONE; do { ret = acldvppCreateChannel(dvppChannelDesc_); CHECK_AND_BREAK(ret, "acldvppCreateChannel failed !"); ret = acldvppSetChannelDescMode(dvppChannelDesc_, DVPP_CHNMODE_VPC); CHECK_AND_BREAK(ret, "acldvppSetChannelDescMode failed !"); } while (0); return ret; } DvppDataMemory* VpcUtils::convert2bgr(acldvppPicDesc *inputDesc_, int out_width, int out_height, bool key_frame){ aclrtSetDevice(m_devId); aclrtSetCurrentContext(context_); int out_buf_width = ALIGN_UP(out_width, 16) * 3; int out_buf_height = ALIGN_UP(out_height, 2); int out_buf_size = out_buf_width * out_buf_height; DvppDataMemory* rgbMem = new DvppDataMemory(3, out_buf_width, out_buf_width, out_buf_height, out_buf_height, out_buf_size, "", to_string(m_devId), key_frame, 0); void *outBufferDev_ = (void*)rgbMem->getMem(); acldvppPicDesc *outputDesc_= acldvppCreatePicDesc(); acldvppSetPicDescData(outputDesc_, outBufferDev_); acldvppSetPicDescFormat(outputDesc_, PIXEL_FORMAT_BGR_888); acldvppSetPicDescWidth(outputDesc_, out_width); acldvppSetPicDescHeight(outputDesc_, out_height); acldvppSetPicDescWidthStride(outputDesc_, out_buf_width); acldvppSetPicDescHeightStride(outputDesc_, out_buf_height); acldvppSetPicDescSize(outputDesc_, out_buf_size); aclError ret = ACL_ERROR_NONE; do{ // 9. 执行异步色域转换,再调用aclrtSynchronizeStream接口阻塞程序运行,直到指定Stream中的所有任务都完成 ret = acldvppVpcConvertColorAsync(dvppChannelDesc_, inputDesc_, outputDesc_, stream_); if(ret != ACL_ERROR_NONE){ LOG_ERROR("acldvppVpcConvertColorAsync failed - out_width:{} out_height:{} out_buf_width:{} out_buf_height:{} out_buf_size:{}", out_width, out_height, out_buf_width, out_buf_height, out_buf_size); break; } ret = aclrtSynchronizeStream(stream_); if(ret != ACL_ERROR_NONE){ LOG_ERROR("aclrtSynchronizeStream failed - out_width:{} out_height:{} out_buf_width:{} out_buf_height:{} out_buf_size:{}", out_width, out_height, out_buf_width, out_buf_height, out_buf_size); break; } }while(0); acldvppDestroyPicDesc(outputDesc_); if(ret != ACL_ERROR_NONE){ delete rgbMem; rgbMem = nullptr; } return rgbMem; } DvppDataMemory* VpcUtils::convert2bgr(DvppDataMemory* inMem){ aclrtSetDevice(m_devId); aclrtSetCurrentContext(context_); int out_width = inMem->getWidth(); int out_height = inMem->getHeight(); acldvppPicDesc *inputDesc_= acldvppCreatePicDesc(); acldvppSetPicDescData(inputDesc_, inMem->getMem()); acldvppSetPicDescFormat(inputDesc_, PIXEL_FORMAT_YUV_SEMIPLANAR_420); acldvppSetPicDescWidth(inputDesc_, out_width); acldvppSetPicDescHeight(inputDesc_, out_height); acldvppSetPicDescWidthStride(inputDesc_, inMem->getWidthStride()); acldvppSetPicDescHeightStride(inputDesc_, inMem->getHeightStride()); acldvppSetPicDescSize(inputDesc_, inMem->getSize()); int out_buf_width = ALIGN_UP(out_width, 16) * 3; int out_buf_height = ALIGN_UP(out_height, 2); int out_buf_size = out_buf_width * out_buf_height; DvppDataMemory* rgbMem = new DvppDataMemory(3, out_buf_width, out_buf_width, out_buf_height, out_buf_height, out_buf_size, inMem->getId(), inMem->getDeviceId(), false, inMem->getFrameNb()); void *outBufferDev_ = (void*)rgbMem->getMem(); acldvppPicDesc *outputDesc_= acldvppCreatePicDesc(); acldvppSetPicDescData(outputDesc_, outBufferDev_); acldvppSetPicDescFormat(outputDesc_, PIXEL_FORMAT_BGR_888); acldvppSetPicDescWidth(outputDesc_, out_width); acldvppSetPicDescHeight(outputDesc_, out_height); acldvppSetPicDescWidthStride(outputDesc_, out_buf_width); acldvppSetPicDescHeightStride(outputDesc_, out_buf_height); acldvppSetPicDescSize(outputDesc_, out_buf_size); aclError ret = ACL_ERROR_NONE; do{ // 9. 执行异步色域转换,再调用aclrtSynchronizeStream接口阻塞程序运行,直到指定Stream中的所有任务都完成 ret = acldvppVpcConvertColorAsync(dvppChannelDesc_, inputDesc_, outputDesc_, stream_); if(ret != ACL_ERROR_NONE){ LOG_ERROR("acldvppVpcConvertColorAsync failed - out_width:{} out_height:{} out_buf_width:{} out_buf_height:{} out_buf_size:{}", out_width, out_height, out_buf_width, out_buf_height, out_buf_size); break; } ret = aclrtSynchronizeStream(stream_); if(ret != ACL_ERROR_NONE){ LOG_ERROR("aclrtSynchronizeStream failed - out_width:{} out_height:{} out_buf_width:{} out_buf_height:{} out_buf_size:{}", out_width, out_height, out_buf_width, out_buf_height, out_buf_size); break; } }while(0); acldvppDestroyPicDesc(outputDesc_); acldvppDestroyPicDesc(inputDesc_); if(ret != ACL_ERROR_NONE){ delete rgbMem; rgbMem = nullptr; } return rgbMem; } DvppDataMemory* VpcUtils::resize(acldvppPicDesc *inputDesc_, int out_width, int out_height){ int out_buf_width = ALIGN_UP(out_width, 16); int out_buf_height = ALIGN_UP(out_height, 2); int out_buf_size = out_buf_width * out_buf_height * 3; aclrtSetDevice(m_devId); aclrtSetCurrentContext(context_); DvppDataMemory* rgbMem = new DvppDataMemory(1, out_width, out_buf_width, out_height, out_buf_height, out_buf_size, "", "", false, 0); void *outBufferDev_ = (void*)rgbMem->getMem(); acldvppPicDesc *outputDesc_= acldvppCreatePicDesc(); acldvppSetPicDescData(outputDesc_, outBufferDev_); acldvppSetPicDescFormat(outputDesc_, acldvppGetPicDescFormat(inputDesc_)); acldvppSetPicDescWidth(outputDesc_, out_width); acldvppSetPicDescHeight(outputDesc_, out_height); acldvppSetPicDescWidthStride(outputDesc_, out_buf_width); acldvppSetPicDescHeightStride(outputDesc_, out_buf_height); acldvppSetPicDescSize(outputDesc_, out_buf_size); acldvppResizeConfig *resizeConfig_ = acldvppCreateResizeConfig(); aclError ret = ACL_ERROR_NONE; do{ // 9. 执行异步色域转换,再调用aclrtSynchronizeStream接口阻塞程序运行,直到指定Stream中的所有任务都完成 ret = acldvppVpcResizeAsync(dvppChannelDesc_, inputDesc_, outputDesc_, resizeConfig_, stream_); if(ret != ACL_ERROR_NONE){ LOG_ERROR("acldvppVpcResizeAsync failed - out_width:{} out_height:{} out_buf_width:{} out_buf_height:{} out_buf_size:{}", out_width, out_height, out_buf_width, out_buf_height, out_buf_size); break; } ret = aclrtSynchronizeStream(stream_); if(ret != ACL_ERROR_NONE){ LOG_ERROR("aclrtSynchronizeStream failed - out_width:{} out_height:{} out_buf_width:{} out_buf_height:{} out_buf_size:{}", out_width, out_height, out_buf_width, out_buf_height, out_buf_size); break; } }while(0); acldvppDestroyResizeConfig(resizeConfig_); acldvppDestroyPicDesc(outputDesc_); if(ret != ACL_ERROR_NONE){ delete rgbMem; rgbMem = nullptr; } return rgbMem; } DvppDataMemory* VpcUtils::resize(DvppDataMemory* inMem, int out_width, int out_height) { int out_buf_width = ALIGN_UP(out_width, 16) * 3; int out_buf_height = ALIGN_UP(out_height, 2); int out_buf_size = out_buf_width * out_buf_height; aclrtSetDevice(m_devId); aclrtSetCurrentContext(context_); acldvppPicDesc *inputDesc_= acldvppCreatePicDesc(); acldvppSetPicDescData(inputDesc_, inMem->getMem()); acldvppSetPicDescFormat(inputDesc_, PIXEL_FORMAT_BGR_888); acldvppSetPicDescWidth(inputDesc_, inMem->getWidth()); acldvppSetPicDescHeight(inputDesc_, inMem->getHeight()); acldvppSetPicDescWidthStride(inputDesc_, inMem->getWidthStride()); acldvppSetPicDescHeightStride(inputDesc_, inMem->getHeightStride()); acldvppSetPicDescSize(inputDesc_, inMem->getSize()); DvppDataMemory* rgbMem = new DvppDataMemory(3, out_width, out_buf_width, out_height, out_buf_height, out_buf_size, inMem->getId(), inMem->getDeviceId(), false, inMem->getFrameNb()); void *outBufferDev_ = (void*)rgbMem->getMem(); acldvppPicDesc *outputDesc_= acldvppCreatePicDesc(); acldvppSetPicDescData(outputDesc_, outBufferDev_); acldvppSetPicDescFormat(outputDesc_, PIXEL_FORMAT_BGR_888); acldvppSetPicDescWidth(outputDesc_, out_width); acldvppSetPicDescHeight(outputDesc_, out_height); acldvppSetPicDescWidthStride(outputDesc_, out_buf_width); acldvppSetPicDescHeightStride(outputDesc_, out_buf_height); acldvppSetPicDescSize(outputDesc_, out_buf_size); aclError ret = ACL_ERROR_NONE; acldvppResizeConfig *resizeConfig_ = acldvppCreateResizeConfig(); do{ // 9. 执行异步色域转换,再调用aclrtSynchronizeStream接口阻塞程序运行,直到指定Stream中的所有任务都完成 ret = acldvppVpcResizeAsync(dvppChannelDesc_, inputDesc_, outputDesc_, resizeConfig_, stream_); if(ret != ACL_ERROR_NONE){ LOG_ERROR("acldvppVpcResizeAsync failed - out_width:{} out_height:{} out_buf_width:{} out_buf_height:{} out_buf_size:{}", out_width, out_height, out_buf_width, out_buf_height, out_buf_size); break; } ret = aclrtSynchronizeStream(stream_); if(ret != ACL_ERROR_NONE){ LOG_ERROR("aclrtSynchronizeStream failed - out_width:{} out_height:{} out_buf_width:{} out_buf_height:{} out_buf_size:{}", out_width, out_height, out_buf_width, out_buf_height, out_buf_size); break; } }while(0); acldvppDestroyResizeConfig(resizeConfig_); acldvppDestroyPicDesc(outputDesc_); acldvppDestroyPicDesc(inputDesc_); if(ret != ACL_ERROR_NONE){ delete rgbMem; rgbMem = nullptr; } return rgbMem; } DvppDataMemory* VpcUtils::crop(DvppDataMemory* devMem, AreaInfo obj) { check_area(obj, devMem->getWidth(), devMem->getHeight()); // uint32_t cropSizeWidth = (obj.right - obj.left) / 16 * 16; // uint32_t cropSizeHeight = (obj.bottom - obj.top) / 2 * 2; uint32_t cropSizeWidth = ALIGN_UP(obj.right - obj.left, 16); uint32_t cropSizeHeight = ALIGN_UP(obj.bottom - obj.top, 2); uint32_t oddNum = 1; uint32_t cropLeftOffset = (obj.left + 1) / 2 * 2; // must even uint32_t cropRightOffset = cropLeftOffset + cropSizeWidth - oddNum; // must odd uint32_t cropTopOffset = (obj.top + 1) / 2 * 2; // must even uint32_t cropBottomOffset = cropTopOffset + cropSizeHeight - oddNum; // must odd adjustCoordinate(cropLeftOffset, cropRightOffset, cropTopOffset, cropBottomOffset, devMem->getWidth(), devMem->getHeight()); cropSizeWidth = cropRightOffset - cropLeftOffset + oddNum; // 宽高要比实际的高才行,否则会抠图失败 cropSizeHeight = cropBottomOffset - cropTopOffset + oddNum; // LOG_DEBUG("{} ,{} ,{} ,{} ", cropLeftOffset, cropRightOffset, cropTopOffset, cropBottomOffset); if(cropRightOffset <= cropLeftOffset || cropBottomOffset <= cropTopOffset){ LOG_ERROR("{} <= {} || {} <= {} ", cropRightOffset, cropLeftOffset, cropBottomOffset, cropTopOffset); return nullptr; } aclError ret; aclrtSetDevice(m_devId); ret = aclrtSetCurrentContext(context_); if (ret != ACL_SUCCESS) { LOG_ERROR("aclrtSetCurrentContext failed"); return nullptr; } // LOG_INFO("crop src {} ({}, {}, {}, {})", obj.object_id, obj.left, obj.right, obj.top, obj.bottom); // LOG_INFO("crop {} ({}, {}, {}, {})", obj.object_id, cropLeftOffset, cropRightOffset, cropTopOffset, cropBottomOffset); acldvppRoiConfig *cropArea_ = acldvppCreateRoiConfig(cropLeftOffset, cropRightOffset, cropTopOffset, cropBottomOffset); acldvppPicDesc *vpcInputDesc_ = acldvppCreatePicDesc(); acldvppSetPicDescData(vpcInputDesc_, devMem->getMem()); acldvppSetPicDescFormat(vpcInputDesc_, PIXEL_FORMAT_BGR_888); acldvppSetPicDescWidth(vpcInputDesc_, devMem->getWidth()); acldvppSetPicDescHeight(vpcInputDesc_, devMem->getHeight()); acldvppSetPicDescWidthStride(vpcInputDesc_, devMem->getWidthStride()); acldvppSetPicDescHeightStride(vpcInputDesc_, devMem->getHeightStride()); acldvppSetPicDescSize(vpcInputDesc_, devMem->getSize()); /* processdecode */ uint32_t vpcOutBufferSize_ = cropSizeWidth * cropSizeHeight * 3; DvppDataMemory* rgbMem = new DvppDataMemory(3, cropSizeWidth, cropSizeWidth, cropSizeHeight, cropSizeHeight, vpcOutBufferSize_, devMem->getId(), devMem->getDeviceId(), false, devMem->getFrameNb()); void *outBufferDev_ = (void*)rgbMem->getMem(); acldvppPicDesc *vpcOutputDesc_ = acldvppCreatePicDesc(); acldvppSetPicDescData(vpcOutputDesc_, outBufferDev_); acldvppSetPicDescFormat(vpcOutputDesc_, PIXEL_FORMAT_BGR_888); acldvppSetPicDescWidth(vpcOutputDesc_, cropSizeWidth); acldvppSetPicDescHeight(vpcOutputDesc_, cropSizeHeight); acldvppSetPicDescWidthStride(vpcOutputDesc_, cropSizeWidth*3); acldvppSetPicDescHeightStride(vpcOutputDesc_, cropSizeHeight); acldvppSetPicDescSize(vpcOutputDesc_, vpcOutBufferSize_); bool bRet = false; do { ret = acldvppVpcCropAsync(dvppChannelDesc_, vpcInputDesc_, vpcOutputDesc_, cropArea_, stream_); if (ret != ACL_SUCCESS) { LOG_ERROR("acldvppVpcCropAsync failed, task_id : {}", devMem->getId()); break; } ret = aclrtSynchronizeStream(stream_); if (ret != ACL_SUCCESS) { LOG_ERROR("aclrtSynchronizeStream failed, task_id : {}", devMem->getId()); break; } } while (0); acldvppDestroyPicDesc(vpcInputDesc_); (void)acldvppDestroyPicDesc(vpcOutputDesc_); (void)acldvppDestroyRoiConfig(cropArea_); if(ret != ACL_ERROR_NONE){ delete rgbMem; rgbMem = nullptr; } return rgbMem; } void VpcUtils::check_area(AreaInfo& area, int width, int height) { if (area.left < 0) { area.left = 0; } if (area.top < 0) { area.top = 0; } if (area.right > width) { area.right = width; } if (area.bottom > height) { area.bottom = height; } } vector VpcUtils::crop_batch(DvppDataMemory* devMem, const vector objs) { vector vec_img_info; const uint32_t outputBatchSize_ = objs.size(); if(outputBatchSize_ <= 0){ return vec_img_info; } aclError ret; aclrtSetDevice(m_devId); ret = aclrtSetCurrentContext(context_); // 输入 acldvppBatchPicDesc *vpcInputBatchDesc_ = acldvppCreateBatchPicDesc(1); if (vpcInputBatchDesc_ == nullptr) { LOG_ERROR("acldvppCreatePicDesc outBatchPicDesc failed"); return vec_img_info; } acldvppPicDesc *vpcInputDesc_ = acldvppGetPicDesc(vpcInputBatchDesc_, 0); acldvppSetPicDescData(vpcInputDesc_, devMem->getMem()); acldvppSetPicDescFormat(vpcInputDesc_, PIXEL_FORMAT_BGR_888); acldvppSetPicDescWidth(vpcInputDesc_, devMem->getWidth()); acldvppSetPicDescHeight(vpcInputDesc_, devMem->getHeight()); acldvppSetPicDescWidthStride(vpcInputDesc_, devMem->getWidthStride()); acldvppSetPicDescHeightStride(vpcInputDesc_, devMem->getHeightStride()); acldvppSetPicDescSize(vpcInputDesc_, devMem->getSize()); // 输出 acldvppBatchPicDesc *outputBatchPicDesc_ = acldvppCreateBatchPicDesc(outputBatchSize_); if (outputBatchPicDesc_ == nullptr) { LOG_ERROR("acldvppCreatePicDesc outBatchPicDesc failed"); (void)acldvppDestroyBatchPicDesc(vpcInputBatchDesc_); return vec_img_info; } vector vecOutPtr_; acldvppPicDesc *vpcOutputDesc = nullptr; acldvppRoiConfig *cropAreas[outputBatchSize_]; for (uint32_t i = 0; i < outputBatchSize_; i++) { AreaInfo obj = objs[i]; check_area(obj, devMem->getWidth(), devMem->getHeight()); uint32_t cropSizeWidth = (obj.right - obj.left + 15) / 16 * 16; //debug by zsh uint32_t cropSizeHeight = (obj.bottom - obj.top + 1) / 2 * 2; uint32_t oddNum = 1; uint32_t cropLeftOffset = (obj.left + 1) / 2 * 2; // must even uint32_t cropRightOffset = cropLeftOffset + cropSizeWidth - oddNum; // must odd uint32_t cropTopOffset = (obj.top + 1) / 2 * 2; // must even uint32_t cropBottomOffset = cropTopOffset + cropSizeHeight - oddNum; // must odd adjustCoordinate(cropLeftOffset, cropRightOffset, cropTopOffset, cropBottomOffset, devMem->getWidth(), devMem->getHeight()); cropSizeWidth = cropRightOffset - cropLeftOffset + oddNum; cropSizeHeight = cropBottomOffset - cropTopOffset + oddNum; // LOG_DEBUG("{} ,{} ,{} ,{} ", cropLeftOffset, cropRightOffset, cropTopOffset, cropBottomOffset); if(cropRightOffset <= cropLeftOffset || cropBottomOffset <= cropTopOffset){ LOG_ERROR("{} <= {} || {} <= {} ", cropRightOffset, cropLeftOffset, cropBottomOffset, cropTopOffset); // 释放之前成功的部分 再退出 for(int j = 0; j < vecOutPtr_.size(); j++){ if (vecOutPtr_[j] != nullptr){ acldvppFree(vecOutPtr_[j]); } if (cropAreas[j] != nullptr) { (void)acldvppDestroyRoiConfig(cropAreas[j]); cropAreas[j] = nullptr; } } (void)acldvppDestroyBatchPicDesc(vpcInputBatchDesc_); return vec_img_info; } cropAreas[i] = acldvppCreateRoiConfig(cropLeftOffset, cropRightOffset, cropTopOffset, cropBottomOffset); uint32_t vpcOutBufferSize_ = cropSizeWidth * cropSizeHeight * 3; void *vpcBatchOutputBufferDev = nullptr; auto ret = acldvppMalloc(&vpcBatchOutputBufferDev, vpcOutBufferSize_); if (ret != ACL_SUCCESS) { LOG_ERROR("acldvppMalloc failed, size = %u, errorCode = %d.", vpcOutBufferSize_, static_cast(ret)); // 释放之前成功的部分 再退出 for(int i = 0; i < vecOutPtr_.size(); i++){ if (vecOutPtr_[i] != nullptr){ acldvppFree(vecOutPtr_[i]); } if (cropAreas[i] != nullptr) { (void)acldvppDestroyRoiConfig(cropAreas[i]); cropAreas[i] = nullptr; } } (void)acldvppDestroyBatchPicDesc(vpcInputBatchDesc_); return vec_img_info; } vecOutPtr_.push_back(vpcBatchOutputBufferDev); vpcOutputDesc = acldvppGetPicDesc(outputBatchPicDesc_, i); (void)acldvppSetPicDescData(vpcOutputDesc, vpcBatchOutputBufferDev); (void)acldvppSetPicDescFormat(vpcOutputDesc, PIXEL_FORMAT_BGR_888); (void)acldvppSetPicDescWidth(vpcOutputDesc, cropSizeWidth); (void)acldvppSetPicDescHeight(vpcOutputDesc, cropSizeHeight); (void)acldvppSetPicDescWidthStride(vpcOutputDesc, cropSizeWidth*3); (void)acldvppSetPicDescHeightStride(vpcOutputDesc, cropSizeHeight); (void)acldvppSetPicDescSize(vpcOutputDesc, vpcOutBufferSize_); } bool bRet = false; do { uint32_t roiNums[] = { outputBatchSize_ }; ret = acldvppVpcBatchCropAsync(dvppChannelDesc_, vpcInputBatchDesc_, roiNums, 1, outputBatchPicDesc_, cropAreas, stream_); if (ret != ACL_SUCCESS) { LOG_ERROR("acldvppVpcBatchCropAsync failed, task_id : {}", devMem->getId()); break; } ret = aclrtSynchronizeStream(stream_); if (ret != ACL_SUCCESS) { LOG_ERROR("aclrtSynchronizeStream failed, task_id : {}", devMem->getId()); break; } for (uint32_t i = 0; i < outputBatchSize_; i++) { vpcOutputDesc = acldvppGetPicDesc(outputBatchPicDesc_, i); void *outputDataDev = acldvppGetPicDescData(vpcOutputDesc); uint32_t outputSize = acldvppGetPicDescSize(vpcOutputDesc); uint32_t width = acldvppGetPicDescWidth(vpcOutputDesc); uint32_t width_stride = acldvppGetPicDescWidthStride(vpcOutputDesc); uint32_t height = acldvppGetPicDescHeight(vpcOutputDesc); uint32_t height_stride = acldvppGetPicDescHeightStride(vpcOutputDesc); acldvppPixelFormat fmt = acldvppGetPicDescFormat(vpcOutputDesc); DvppDataMemory* rgbMem = new DvppDataMemory(width, width_stride, height, height_stride, outputSize, devMem->getId(), devMem->getDeviceId(), false, devMem->getFrameNb(), (unsigned char *)outputDataDev); vec_img_info.push_back(rgbMem); } bRet = true; } while (0); if (vpcInputBatchDesc_ != nullptr) { (void)acldvppDestroyBatchPicDesc(vpcInputBatchDesc_); vpcInputBatchDesc_ = nullptr; } if (!bRet){ for(int i = 0; i < vecOutPtr_.size(); i++){ if (vecOutPtr_[i] != nullptr){ acldvppFree(vecOutPtr_[i]); } } } if (outputBatchPicDesc_ != nullptr) { (void)acldvppDestroyBatchPicDesc(outputBatchPicDesc_); outputBatchPicDesc_ = nullptr; } for (uint32_t i = 0; i < outputBatchSize_; i++) { if (cropAreas[i] != nullptr) { (void)acldvppDestroyRoiConfig(cropAreas[i]); cropAreas[i] = nullptr; } } return vec_img_info; }