Search code examples
c#c++directshowdirectshow.netms-media-foundation

VMR9 vs EVR : How to use ImageCompositor with EVR?


I've coded a PixelShader compiler/tester that works live on the Image or Video source that is playing using DirectShow.Net + VMR9.

And it was all good until I decided to give it a go as a real video player, and started adjusting every bit of it to work as it should (titles,etc).

Then I found out that video is very pixelated (badly interpolated) on Windows7 with ATI gpus. The solution was to go with EVR. And I did it. Aside with some glitches with background flickering and resize slowness that I'll try to solve with a custom presenter it all looked good.

BUT...

I lost the ability to apply pixel shading to the output video because there is no SetImageCompositor method on the EVR FilterConfig interface.

This is the EVR interface:

[SuppressUnmanagedCodeSecurity]
[Guid("83E91E85-82C1-4ea7-801D-85DC50B75086")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IEVRFilterConfig
{
    void GetNumberOfStreams(out int pdwMaxStreams);
    void SetNumberOfStreams(int dwMaxStreams);
}

This is the VMR9 interface:

[Guid("5a804648-4f66-4867-9c43-4f5c822cf1b8")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[SuppressUnmanagedCodeSecurity]
public interface IVMRFilterConfig9
{
    int GetNumberOfStreams(out int pdwMaxStreams);
    int GetRenderingMode(out VMR9Mode Mode);
    int GetRenderingPrefs(out VMR9RenderPrefs pdwRenderFlags);
    int SetImageCompositor(IVMRImageCompositor9 lpVMRImgCompositor);
    int SetNumberOfStreams(int dwMaxStreams);
    int SetRenderingMode(VMR9Mode Mode);
    int SetRenderingPrefs(VMR9RenderPrefs dwRenderFlags);
}

I have been using this approach with a custom image compositor to apply pixel shaders:

    IVMRFilterConfig9 filterConfig = (IVMRFilterConfig9)vmr9;
    // frameManager is my custom class implementing IVMRImageCompositor9
    hr = filterConfig.SetImageCompositor(frameManager);
    DsError.ThrowExceptionForHR(hr);

Now I cannot...

Using: VS2010, C#, DirectShow.NET, Mediafoundation.NET, Managed DX9.

What is the solution to this problem? Any guidelines on how to do it with EVR?

Thank you very much!


Solution

  • Since nobody had suggestions I dig up a little and think I have found out what could be the solution:

    http://msdn.microsoft.com/en-us/library/bb530107(v=vs.85).aspx

    This should be now done in the custom presenter...