Media (Intel® oneAPI Video Processing Library, Intel Media SDK)
Access community support with transcoding, decoding, and encoding in applications using media tools from Intel. This includes Intel® oneAPI Video Processing Library and Intel® Media SDK.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!
For the latest information on Intel’s response to the Log4j/Log4Shell vulnerability, please see Intel-SA-00646

mfxFrameAllocator binding to C++ member functions

Ralf_K_
Beginner
152 Views

i want to implement my own FrameAllocator class like this:

class MyAllocator
{
public:
  mfxStatus alloc(mfxFrameAllocRequest *request, mfxFrameAllocResponse *response);
  mfxStatus  lock(mfxMemId mid, mfxFrameData *ptr);
  mfxStatus  unlock(mfxMemId mid, mfxFrameData *ptr);
  mfxStatus  getHDL(mfxMemId mid, mfxHDL *handle);
  mfxStatus  Free(mfxFrameAllocResponse *response);

  void setAllocator(mfxFrameAllocator* allocator);
}

How can i do the binding to my member functions in setAllocator, where pthis should be this from MyAllocator?

FYI:

typedef struct {

    mfxU32      reserved[4];
    mfxHDL      pthis;

    mfxStatus  (MFX_CDECL  *Alloc)    (mfxHDL pthis, mfxFrameAllocRequest *request, mfxFrameAllocResponse *response);
    mfxStatus  (MFX_CDECL  *Lock)     (mfxHDL pthis, mfxMemId mid, mfxFrameData *ptr);
    mfxStatus  (MFX_CDECL  *Unlock)   (mfxHDL pthis, mfxMemId mid, mfxFrameData *ptr);
    mfxStatus  (MFX_CDECL  *GetHDL)   (mfxHDL pthis, mfxMemId mid, mfxHDL *handle);
    mfxStatus  (MFX_CDECL  *Free)     (mfxHDL pthis, mfxFrameAllocResponse *response);
} mfxFrameAllocator;

 

Ralf

 

0 Kudos
4 Replies
Mark_L_Intel1
Moderator
152 Views

Hi Ralf,

Are you asking the following question:

How can i do the binding to my member functions in mfxFrameAllocator, where pthis should be this from MyAllocator?

If my guess is correct, you might try to inherit mfxHDL:

class MyAllocator : public mfxHDL {......}

Mark

Ralf_K_
Beginner
152 Views

Hi Mark,

thanks, good idea.

But how do i set the fields from mfxFrameAllocator?

mfxFrameAllocator mfxAllocator{};
MyAllocator myAllocator{};

mfxAllocator.alloc = myAllocator.alloc; //!!! How to do the binding?

 

Ralf

Mark_L_Intel1
Moderator
152 Views

Hi Ralf,

You are close, the code should be:

MyAllocator *myAllocator = new MyAllocator();
mfxFrameAllocator *mfxAllocator;

mfxAllocator = (*mfxFrameAllocator)malloc(sizeof(mfxFrameAllocator));

mfxAllocator->Alloc = myAllocator->alloc;

Let me know if this doesn't work.

Mark

 

Ralf_K_
Beginner
152 Views
Reply