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.

mfxEncodeCtrl payload lifetime

Will_K_
Beginner
767 Views

Hi,

I'm having some issues inserting SEI payloads while encoding.  Specifically, I'm confused regarding the lifetime of the mfxEncodeCtrl structure and associated payload.  If I allocate the mfxEncodeCtrl and mfxPayload data on the heap and never free either, everything works fine.  If I free just the mfxPayload->Data, it also seems to work.  But if I also free the mfxEncodeCtrl structure or the Payload pointers, then I get a segfault in the codec library.

I thought I saw something in the documentation that said the payload data needs to remain valid for the duration of the async job, which is why I'm waiting until after the SyncOperation completes to free it.  Is that also the case with the rest of the mfxEncodeCtrl struct?

So, I'd like to clarify the following:

- Does the encoder copy the mfxPayload data to some internal storage during EncodeFrameAsync?

- Is it ok to use a new mfxEncodeCtrl structure on each call to EncodeFrameAsync, or should I be reusing the same one and just changing the payload each time?  If this is ok, what is the expected lifetime of the mfxEncodeCtrl object?

I should also mention that I'm pipelining the encoding with an AsyncDepth of 4.

Thanks,

will

0 Kudos
3 Replies
Jeffrey_M_Intel1
Employee
767 Views

There are many ways to implement, but something like an array of encode control structures corresponding to the number of surfaces could help.  The surface and encode control used for each frame given to the encoder can share the same index, which makes it easy to know when they can be reused.  Internally there are no copies and both travel through the encode process together.    

0 Kudos
Will_K_
Beginner
767 Views

Ok, does that mean that the surface->Data.Locked field can also be used to tell when the encoder control structure is free?

0 Kudos
Jeffrey_M_Intel1
Employee
767 Views

If you're using the same index for both the surface and encode control structure, yes.

0 Kudos
Reply