自定义分配器在Windows 7上不起作用

时间:2011-07-11 09:12:17

标签: c# video directx directshow

我使用自定义分配器编写程序,允许将directctshow视频捕获显示为directx纹理。 由于我在Windows 7上运行我的程序,它显示的是白框而不是我的视频。

如果我将VMR9过滤器配置为在控件上显示,则可以正常工作。

有没有人有解决这个问题的线索?

2 个答案:

答案 0 :(得分:1)

我自己使用 DirectX控制面板找到了解决方案,以启用调试模式。我意识到在设置分配器时我没有以正确的顺序做事。这是我的代码的一部分:

filterConfig.SetRenderingMode(VMR9Mode.Renderless);
// QueryInterface on the VMR-9 filter for the IVMRSurfaceAllocatorNotify9 interface.
IVMRSurfaceAllocatorNotify9 san = (IVMRSurfaceAllocatorNotify9)_vmr9;
// Call the IVMRSurfaceAllocatorNotify9::AdviseSurfaceAllocator method and pass in a pointer to your allocator-presenter's IVMRSurfaceAllocator9 method.
san.AdviseSurfaceAllocator(IntPtr.Zero, allocator);
// Call your allocator-presenter's IVMRSurfaceAllocator9::AdviseNotify method and pass in a pointer to the VMR-9 filter's IVMRSurfaceAllocatorNotify9 interface.
allocator.AdviseNotify(san);
// Change mixer prefs AFTER settings the allocator in order to support YUV mixing (best performance)
IVMRMixerControl9 mixerControl = (IVMRMixerControl9)_vmr9;
VMR9MixerPrefs prefs;
mixerControl.GetMixingPrefs(out prefs);
prefs &= ~VMR9MixerPrefs.RenderTargetMask;
prefs |= VMR9MixerPrefs.RenderTargetYUV;
mixerControl.SetMixingPrefs(prefs);

答案 1 :(得分:0)

使用vmr9中的自定义Allocator Presenter进行DirectShow,在Windows 7中可以正常工作。您的代码中可能有一些内容。 在绘制到另一种颜色之前尝试清除框架,例如红色。如果看到红色,表示您没有正确绘制框架。如果不这样做,则表示您没有正确执行某些操作。

我建议您检查锁定机制,因为您的自定义AP可以同时从3-5个线程访问。