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

发布于 2024-11-19 10:04:52 字数 162 浏览 2 评论 0原文

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

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

有谁有解决这个问题的线索吗?

I writing a program using a custom allocator that allow to display my directshow video capture to a directx texture.
Since I'm running my program on Windows 7 it display a white frame instead of my video.

If I configure my VMR9 filter to display on a control it works fine.

Does anyone have a clue to solve this problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

北陌 2024-11-26 10:04:52

我自己使用 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);

I found the solution myself using DirectX Control Panel to enable Debug mode. I realized that I wasn't doing the thing in the right order when setting the allocator. Here is a portion of my code:

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);
陪我终i 2024-11-26 10:04:52

vmr9 中带有自定义 Allocator Presenter 的 DirectShow 在 Windows 7 中可以正常工作。您的代码中可能存在某些问题。
在绘制为另一种颜色(例如红色)之前尝试清除框架。如果你看到红色,则意味着你没有正确绘制框架。如果你不这样做,就意味着你没有做正确的事情。

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

DirectShow with custom Allocator Presenter in vmr9, does work in Windows 7. You probably have something broken in your code.
Try clearing the frame before drawing to another color, red for example. If you see red, means that you don't draw the frame correctly. If you don't, means that you didn't do something correctly.

I would advice you to check your locking mechanism because your custom AP is accessed from 3-5 threads at the same time.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文