- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here is the answer to my question:
https://github.com/Intel-Media-SDK/samples/blob/master/samples/sample_common/src/base_allocator.cpp
Ralf

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page