Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Ralf_K_
Beginner
66 Views

mfxFrameAllocator binding to C++ member functions

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
66 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
66 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
66 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
66 Views

Reply