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.

Multi VPPs share the same input surface

way_lzl
Beginner
798 Views

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, inputSurf, outputSurf)

SyncOperation(sessions, syncp)

DoSomthing(outputSurf)

}

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, inputSurf, outputSurf)

}

for each(i = 0 to all) {

SyncOperation(sessions, syncp)

}

for each(i = 0 to all) {

DoSomthing(outputSurf)

}

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, inputSurf, outputSurf)

DoSomthing(outputSurf[i-1])

SyncOperation(sessions, syncp)

}

DoSomthing(outputSurf)

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!

0 Kudos
5 Replies
IDZ_A_Intel
Employee
798 Views
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


0 Kudos
way_lzl
Beginner
798 Views

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

0 Kudos
way_lzl
Beginner
798 Views

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.

0 Kudos
IDZ_A_Intel
Employee
798 Views
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
0 Kudos
way_lzl
Beginner
798 Views
Thanks a lot. I will try it!
0 Kudos
Reply