mirror of
https://github.com/opencv/opencv_contrib.git
synced 2025-10-14 18:58:22 +08:00
Merge pull request #3969 from CodeLinaro:apreetam_7thPost
Modified QcAllocator to store File Descriptor
This commit is contained in:
@@ -36,12 +36,15 @@ private:
|
||||
/**
|
||||
* @brief Qualcomm's custom allocator.
|
||||
* This allocator uses Qualcomm's memory management functions.
|
||||
*
|
||||
* Note: The userdata field of cv::UMatData is used to store the file descriptor (fd) of the allocated memory.
|
||||
*
|
||||
*/
|
||||
class QcAllocator : public cv::MatAllocator {
|
||||
public:
|
||||
QcAllocator();
|
||||
~QcAllocator();
|
||||
|
||||
|
||||
cv::UMatData* allocate(int dims, const int* sizes, int type, void* data0, size_t* step, cv::AccessFlag flags, cv::UMatUsageFlags usageFlags) const CV_OVERRIDE;
|
||||
bool allocate(cv::UMatData* u, cv::AccessFlag accessFlags, cv::UMatUsageFlags usageFlags) const CV_OVERRIDE;
|
||||
void deallocate(cv::UMatData* u) const CV_OVERRIDE;
|
||||
|
@@ -55,13 +55,19 @@ cv::UMatData* QcAllocator::allocate(int dims, const int* sizes, int type,
|
||||
}
|
||||
total *= sizes[i];
|
||||
}
|
||||
uchar* data = data0 ? (uchar*)data0 : (uchar*)fcvHwMemAlloc(total, 16);
|
||||
|
||||
int fd = -1;
|
||||
uchar* data = data0 ? (uchar*)data0 : (uchar*)fcvHwMemAlloc(total, 16, &fd);
|
||||
cv::UMatData* u = new cv::UMatData(this);
|
||||
u->data = u->origdata = data;
|
||||
u->size = total;
|
||||
if(data0)
|
||||
u->flags |= cv::UMatData::USER_ALLOCATED;
|
||||
|
||||
// Store FD in userdata (cast to void*)
|
||||
if (fd >= 0)
|
||||
u->userdata = reinterpret_cast<void*>(static_cast<intptr_t>(fd));
|
||||
|
||||
// Add to active allocations
|
||||
cv::fastcv::QcResourceManager::getInstance().addAllocation(data);
|
||||
|
||||
|
Reference in New Issue
Block a user