For the context, I have a  i5-12500E processor and I am using the following media stack:
- oneVPL GPU Runtime: https://github.com/oneapi-src/oneVPL-intel-gpu/releases/tag/intel-onevpl-23.1.5
- oneVPL Dispatcher and Samples: https://github.com/oneapi-src/oneVPL/releases/tag/v2023.1.3
- Driver: https://github.com/intel/media-driver/releases/tag/intel-media-23.1.6
- Gmmlib: https://github.com/intel/gmmlib/releases/tag/intel-gmmlib-22.3.5
- libva: https://github.com/intel/libva/releases/tag/2.18.0
- libva-utils: https://github.com/intel/libva-utils/releases/tag/2.18.1
I have a question about the function "MFXVideoCORE_SetFrameAllocator". I do not see in which cases it could be used:
MFXVideoENCODE_QueryIOSurf(session, &init_param, &request);
allocate_pool_of_frame_surfaces(request.NumFrameSuggested);
MFXVideoENCODE_Init(session, &init_param);
sts=MFX_ERR_MORE_DATA;
for (;;) {
   if (sts==MFX_ERR_MORE_DATA && !end_of_stream()) {
      find_unlocked_surface_from_the_pool(&surface);
      fill_content_for_encoding(surface);
   }
   surface2=end_of_stream()?NULL:surface;
   sts=MFXVideoENCODE_EncodeFrameAsync(session,NULL,surface2,bits,&syncp);
   if (end_of_stream() && sts==MFX_ERR_MORE_DATA) break;
   // Skipped other error handling
   if (sts==MFX_ERR_NONE) {
      MFXVideoCORE_SyncOperation(session, syncp, INFINITE);
      do_something_with_encoded_bits(bits);
   }
}
MFXVideoENCODE_Close(session);
free_pool_of_frame_surfaces();
MFXVideoCORE_SetFrameAllocator(session, &allocator)
MFXVideoENCODE_Init(session, &init_param);
sts=MFX_ERR_MORE_DATA;
for (;;) {
   if (sts==MFX_ERR_MORE_DATA && !end_of_stream()) {
      MFXMemory_GetSurfaceForEncode(session,&surface);
      fill_content_for_encoding(surface);
   }
   surface2=end_of_stream()?NULL:surface;
   sts=MFXVideoENCODE_EncodeFrameAsync(session,NULL,surface2,bits,&syncp);
   if (surface2) surface->FrameInterface->Release(surface2);
   if (end_of_stream() && sts==MFX_ERR_MORE_DATA) break;
   // Skipped other error handling
   if (sts==MFX_ERR_NONE) {
      MFXVideoCORE_SyncOperation(session, syncp, INFINITE);
      do_something_with_encoded_bits(bits);
   }
}
MFXVideoENCODE_Close(session);
Thank you,
Bernard thilmant
Hi,
We assume that your issue is resolved. If you need any additional information, please post a new question as this thread will no longer be monitored by Intel.
Regards,
Rajashekar
連結已複製
Hi, Thanks for posting in Intel communities.
Appreciate your detail of information by providing the version of various packages, But If you can also share,
- OS information
- oneVPL version.
It will help us better to debug this.
Regards,
Rajashekar
Hi,
Good day to you.
You can use MFXVideoCORE_SetFrameAllocator for external allocation. but MFXMemory_GetSurfaceForEncode can be called for Internal allocation mode only.
Another page useful for this information.
https://spec.oneapi.io/versions/latest/elements/oneVPL/source/programming_guide/VPL_prg_mem.html
If this resolves your query, make sure to accept this as a solution. This would help others with similar issue.
Regards,
Rajashekar
Hello,
Unfortunately it remains not clear for me.
I understand MFXMemory_GetSurfaceForEncode can be called for Internal allocation mode only.
But I don't understand how it should be used in the external allocation mode:
If we take a look at the external allocation example from the following page, 
https://spec.oneapi.io/versions/latest/elements/oneVPL/source/programming_guide/VPL_prg_encoding.html
Is that OK they do not call "MFXVideoCORE_SetFrameAllocator" ?
My guess is: as there are using a custom surface pool they do not have to inject an allocator. The custom surface pool is using it directly.
Would you have an example (even in pseudo-code) where we use "MFXVideoCORE_SetFrameAllocator" ?
Hi @BernardThilmant , Good day to you.
We've contacted with the dev team, we'll get back to you soon with an update.
Regards,
Rajashekar
Hi,
Currently, you can use below as references on how to use setFrameAllocator for external allocation.
Here's a cpp file showing how to prepare mfxFrameAllocator for SetFrameAllocator on line 67: https://github.com/Intel-Media-SDK/MediaSDK/blob/master/tutorials/common/common_utils_windows.cpp
Continue, here's is the file having definition of external callback functions which are assigned to mfxFrameAllocation in the previous link: https://github.com/Intel-Media-SDK/MediaSDK/blob/master/tutorials/common/common_directx11.cpp
If this is the information what your looking for, make sure to accept this as a solution. This would help others with similar issue.
Regards,
Rajashekar
Hi @BernardThilmant ,
We have not heard back from you, did you get the chance to review them?
If this is the information what your looking for, make sure to accept this as a solution. This would help others with similar issue and do let us know if we can stop monitoring this thread.
Regards,
Rajashekar
