Multi VPPs share the same input surface

Multi VPPs share the same input surface

Hello

My work is to split the decoded frame in D3D surface into N*N sub pictures in directshow pipeline. So I create N*N VPP sessions to share the same output of decoder session. To avoid data racing, each session just has a copy of inputs handle, i.e. mfxFrameSurface, but content of frame is NOT copied.

I have tried three ways to do this work. The pseudo codes are given below:

Method 1: The simple and naive way is to run each step one by one

for each(i = 0 to all) {

RunVPPAsync(sessions[i], inputSurf, outputSurf[i])

SyncOperation(sessions[i], syncp[i])

DoSomthing(outputSurf[i])

}

It runs well and gets the result successfully.

Method 2: I want to let MSDK runtime to schedule the sessions by itself, so I commit all the sessions before all sync operations

for each(i = 0 to all) {

RunVPPAsync(sessions[i], inputSurf, outputSurf[i])

}

for each(i = 0 to all) {

SyncOperation(sessions[i], syncp[i])

}

for each(i = 0 to all) {

DoSomthing(outputSurf[i])

}

It crashed at SyncOperation and MFX_ERR_DEVICE_FAILED is reported

Method 3: A better way is to run three steps in pipelining as following codes shown

RunVPPAsync(sessions[0], inputSurf, outputSurf[0])

SyncOperation(sessions[0], syncp[0])

for each(i = 1 to all) {

RunVPPAsync(sessions[i], inputSurf, outputSurf[i])

DoSomthing(outputSurf[i-1])

SyncOperation(sessions[i], syncp[i])

}

DoSomthing(outputSurf[i])

But it also crashed at SyncOperation and MFX_ERR_DEVICE_FAILED is reported too. Anyone can help me how to fix bugs of method 2 & 3. Or there is any other efficient ways?

Thanks a lot!

6 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Hi,

To be able to answer your question I'd like to better understand your use case. If you don't mind, could you please share a bit more of what you are trying to achieve with the sub pictures surfaces, such as what is "DoSomething()"?

Is the intent to apply different VPP operations (such as scale, brightness etc...) on all subpictures, or are you just using VPP to crop the specific sub picture. If you are only cropping I do not think you have to bother using VPP since creating independent Media SDK VPP sessions would result in lots of threading and resource overhead. If only cropping, then you may want to explore direct use of DirectX calls such as StretchRect.

Without implementing a somewhat equivalent setup as yours it is hard for me to say what the reason for theMFX_ERR_DEVICE_FAILED may be.

Regards,Petter

Hello Petter

Thanks for your reply.

VPP operations I need are

1: Crop specific sub pictures of 720P picture

2: Scale sub pictures to 720P.

The DoSomething() will read the scaled picture and send it to our display device.

Is there any example of multiple sessions share the same input surface? Do you think whether my pseudo code is reasonable? The most suspicious part is that only the handle of surface, i.e. mfxFrameSurface, is saved, for each session. Do I need to save a copy of picture for each session? It may be an expensive way

Furthermore I have tried to run each session in different thread when input surface is ready. But the same err is reported in each thread.

Ok,considering the purpose is just cropping and scaling then you may be better off just using pure DirectX StretchRect call which can handle both scaling and cropping in one call. The resulting D3D surface can then be rendered using your preferred method. By doing it this way you will save the effort of setting up and dealing with the overhead of several separate VPP sessions.

Unfortunately we have no sample showcasing sessions reusing same input surface. However, if you need some guidance on how to use StretchRect please refer to the Media SDK 3.0 "sample_decode" sample.

Regards,Petter

Thanks a lot. I will try it!

Leave a Comment

Please sign in to add a comment. Not a member? Join today