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
Ankündigungen
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.

Usage of MFXVideoCORE_SetFrameAllocator

BernardThilmant
Einsteiger
3.176Aufrufe
Hello,


For the context, I have a  i5-12500E processor and I am using the following media stack:

I am using oneVPL to encode raw video images in H264.

I have a question about the function "
MFXVideoCORE_SetFrameAllocator". I do not see in which cases it could be used:
 
If I refer to the oneVPL documentation (https://spec.oneapi.io/versions/latest/elements/oneVPL/source/programming_guide/VPL_prg_encoding.html), we have two way of managing the memory: External and Intenal.

 

When looking at the pseudo code of the encoding procedure with external memory, we see the usage of a custom memory pool. In this case, I guess it is the pool that will be responsible of the surface allocations and we do not need to call  "MFXVideoCORE_SetFrameAllocator".
 

 

 

 

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();

 

 

 

Therefore I thought the purpose of the function MFXVideoCORE_SetFrameAllocator was to set an external allocator on the session that would have been called transparently while following the encoding procedure with internal memory.

 

 

 

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);

 

 

 

However if I call MFXMemory_GetSurfaceForEncode afer having set an external allocator, I have an "MFX_ERR_NOT_INITIALIZED" error which tells me that the cache of the session encoder is not initialized.

 

My question is: in which case and how should we use the function MFXVideoCORE_SetFrameAllocator to set an allocator on the session ?
 

Thank you,

Bernard thilmant

 

Beschriftungen (1)
0 Kudos
1 Lösung
RajashekarK_Intel
Mitarbeiter
2.663Aufrufe

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


Lösung in ursprünglichem Beitrag anzeigen

9 Antworten
RajashekarK_Intel
Mitarbeiter
3.126Aufrufe

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,

  1. OS information
  2. oneVPL version.

It will help us better to debug this.


Regards,

Rajashekar


BernardThilmant
Einsteiger
3.097Aufrufe

Hi Rajashekar,

- The OS is Linux (Buildroot).

- oneVPL version 2023.1.3


Best regards,

Bernard Thilmant

RajashekarK_Intel
Mitarbeiter
3.062Aufrufe

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


BernardThilmant
Einsteiger
3.058Aufrufe

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" ?


RajashekarK_Intel
Mitarbeiter
2.908Aufrufe

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

 

RajashekarK_Intel
Mitarbeiter
2.831Aufrufe

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

 

BernardThilmant
Einsteiger
2.797Aufrufe

Hi,

Sorry for the late answer, I had an issue with my account and finally had to recreate it.

Thanks for your answers, I am going to take a look on your example.

RajashekarK_Intel
Mitarbeiter
2.725Aufrufe

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

 

 

RajashekarK_Intel
Mitarbeiter
2.664Aufrufe

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


Antworten