OK, here goes… first a rant, then a recommendation.
The CinderWMF does a decent job, but it’s limited in what it can do. For instance, it doesn’t allow you access to the decoded textures, because it maintains a small pool of textures that DirectX needs to have control over. Handing those textures to the user would negatively impact the hardware video decoding process.
I’m not sure the block handles the small implementation differences between NVIDIA, AMD and Intel GPU’s equally well. I remember being unable to run it on several machines with GPU’s from different vendors. This is probably due to the flags used to create the DirectX surfaces.
The way the block works, is to create a Windows Media Foundation player that runs in a hidden window. WMF is the only way to have access to hardware accelerated video on the Windows Platform* (which is a bloody shame really). The block uses a DirectX9 backend to create a pool of surfaces that are then shared with OpenGL through the WGL_NV_DX_interop extension. Each time a frame has been decoded, the main thread is notified and the surface/texture is then locked to prevent concurrency errors. This is quite an expensive operation that unfortunately reduces the performance of video in OpenGL compared to DirectX, but not by a lot. OpenGL can then render the texture, after which it is unlocked and DirectX can write a new video frame to it.
Because DirectX runs in a thread of its own, we need at least 3 surfaces to avoid stalls, and OpenGL can not hold on to a texture for too long. The block has no mechanism to create extra surfaces when needed, for example if you want to capture screenshots or thumbnails from the movie. The fact that it needs a scheduler running in a hidden window, which is tied to the refresh rate of the monitor, causes OpenGL to often wait for vertical sync twice, before rendering the video frame, causing sync issues. Rewriting the scheduler is not an easy task, though.
People on NVIDIA laptops with Optimus (like yours truly) are in bad luck, because the Intel integrated GPU supports a DirectX9 backend, but the NVIDIA discrete GPU requires a DirectX11 backend. The block does not provide that.
As you can tell, I have been looking into video on Windows for quite a bit. I turned grey because of it and my doctor has made me promise never to work on it again.
With that being said, I do believe the block is the best option for running video on Windows while the platform does not provide access to hardware accelerated video decoding from OpenGL and I would like to sincerely thank the fine people at Stimulant and Philippe Laulheret from Second Story for their pioneering work.
-Paul
*) technically, the older DirectShow
also allows access to hardware accelerated video, but it’s an older API that is no longer properly supported on modern systems (64-bit Windows 10, for example).