Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Will_K_
Beginner
110 Views

mfxEncodeCtrl payload lifetime

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
110 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.    

Will_K_
Beginner
110 Views

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

Jeffrey_M_Intel1
Employee
110 Views

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

Reply