Media (Intel® Video Processing Library, Intel Media SDK)
Access community support with transcoding, decoding, and encoding in applications using media tools like Intel® oneAPI Video Processing Library and Intel® Media SDK
Announcements
The Intel Media SDK project is no longer active. For continued support and access to new features, Intel Media SDK users are encouraged to read the transition guide on upgrading from Intel® Media SDK to Intel® Video Processing Library (VPL), and to move to VPL as soon as possible.
For more information, see the VPL website.

mfxFrameAllocator binding to C++ member functions

Ralf_K_
Beginner
577 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
577 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

0 Kudos
Ralf_K_
Beginner
577 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

0 Kudos
Mark_L_Intel1
Moderator
577 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

 

0 Kudos
Ralf_K_
Beginner
577 Views
0 Kudos
Reply