<div dir="ltr"><div><div>Hi Michael,<br><br></div>I had a quick look over your patches. As Henri pointed figuring out the interaction between dxva2 / d3d is important. I would like to add to also study the interface between the GPU driver (maybe that's through an awful ExtEscape). The current code uses the VAAPI X11 APIs fro dxva2.dll. This code should be moved in some way or another to the display driver, winex11.<br>
<br>Interaction between the display driver and dxva2 could be inspired by the Windows way (if documented well), but it may be too complex and you need your own mechanism. Depending on how dxva2 and d3d can interact, you may want to use OpenGL and probably need your own WGL extension (e.g. something similar to the VDPAU opengl interop extension).<br>
<br></div><div>Whichever video decoding library is better is hard to say. Over the years vdpau felt like the better library to me (it felt like it took years to get libva in some usable shape and I'm not sure how stable it is now.) You mention that vdpau on Intel uses opengl. From my understanding it does use the hw decoder and then uses some form of gl/glx buffer sharing, which is not bad. They also defined a reasonable GL extension, would could be ported to Wine. Some more testing may be needed. If worst came to worst, maybe allow multiple APIs to be used, though less than ideal, but we have multiple backends for other features (xrandr / xvidmode).<br>
<br>On a sidenote, OpenCL also allows sharing of buffers with the video decoders using directx. It may give some clues on how it works in windows and may give clues on how to do it for wiine. Long-term we may also want to support this opencl extension, assuming it is widely used (I doubt that right now).<br>
<br></div><div>I would urge to focus on the driver and d3d interaction.<br></div><div><br></div><div>Thanks,<br>Roderick<br></div><br><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Apr 1, 2014 at 6:50 AM, Michael M�ller <span dir="ltr"><<a href="mailto:michael@fds-team.de" target="_blank">michael@fds-team.de</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Henri,<div class=""><br>
<br>
> Which APIs did you consider for this? What were the various issues?<br>
> What made you choose VAAPI in the end? Do you have tests for how the<br>
> dxva / d3d9 interface is supposed to work?<br>
<br></div>
I mostly considered VAAPI and VDPAU for this as they both offer support for multiple vendors.<br>
<br>
VDPAU has native support for nvidia, amd (only open source driver) and S3 but not for intel. There is a OpenGL backend for VDPAU which can be used on Intel graphic cards but I expect the video decode engine of Intel to reach a better performance than an implementation which is completely based on OpenGL.<br>

<br>
VAAPI has native support for intel, crystal HD decoder, S3 and can also use VDPAU and the amds proprietary XvBA �interface. It simply supports everything VDPAU does plus Intel and the proprietary AMD driver. I think that a library which offers support for the most graphic cards is the best possible option for Wine as we do not want to implement these decoders multiple times.<br>

<br>
The only issues I encountered so far with VAAPI is that not all backend support all commands and you sometimes get an unimplemented error. This is not a big problem in the most cases as you can use other commands to achieve the same, the only real issue I found so far is that the vdpau wrapper does not allow setting or querying for the native image format of a codec. I can force a yuv 420 format, but i can not set or query whether it is stored as NV12 or YV12. When mapping the image it is possible to define a image format but I don't know whether a conversation is done or if is the raw decoded data. It may be necessary that we actually take a look at vdpau library and hard code some values if the vdpau backend is used to avoid conversations between formats.<br>

<br>
There are currently no tests so far. The reason for this is that mingw does not support the dxva header files and you can not use the hardware decoder in a VM. So I basically wrote some test code in MSVC and tested it on an old laptop which is running Windows 7 with a nvidia 9800 GTS.<br>

<br>
VLC wrote some header files for mingw which they use to cross compile VLC, but it does not offer everything we need ( <a href="http://www.videolan.org/developers/vlc/modules/codec/avcodec/dxva2.c" target="_blank">http://www.videolan.org/<u></u>developers/vlc/modules/codec/<u></u>avcodec/dxva2.c</a> ). Maybe whe can use the wine header file or ship a more complete version to allow cross compiling.<br>

<br>
If you want to know how dxva2 is used by applications I would suggest you to take a look at these 3 files used by VLC �to decode mpeg2 using dxva2:<br>
<br>
<a href="http://www.videolan.org/developers/vlc/modules/codec/avcodec/dxva2.c" target="_blank">http://www.videolan.org/<u></u>developers/vlc/modules/codec/<u></u>avcodec/dxva2.c</a><br>
<a href="http://www.ffmpeg.org/doxygen/1.0/dxva2__mpeg2_8c-source.html" target="_blank">http://www.ffmpeg.org/doxygen/<u></u>1.0/dxva2__mpeg2_8c-source.<u></u>html</a><br>
<a href="http://www.ffmpeg.org/doxygen/1.0/dxva2_8c-source.html" target="_blank">http://www.ffmpeg.org/doxygen/<u></u>1.0/dxva2_8c-source.html</a><br>
<br>
VLC initializes DXVA2, creates the surfaces and passes them to avcodec for decoding and storing the result images. Since you need a complete mpeg2 bitstream decoder to gather the information for decoding it is not very easy to create a small example code.<br>

<br>
@Stefan D�singer: I will try to do some tests this evening when I am at home.<span class="HOEnZb"><font color="#888888"><br>
<br>
Michael<br>
<br>
<br>
</font></span></blockquote></div><br></div>