开发者

Custom allocator doesn't work on Windows 7

开发者 https://www.devze.com 2023-03-19 03:13 出处:网络
I 开发者_高级运维writing a program using a custom allocator that allow to display my directshow video capture to a directx texture.

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?


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);


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号