Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Video Capture driver allocating buffers using CSPROPERTY_BUFFER_DR

61 views
Skip to first unread message

Rednahc

unread,
Apr 2, 2010, 5:37:01 PM4/2/10
to
Basically, the PDD portion of my capture driver allocates a non-cached
contiguous frame buffer in physical memory for the capture hardware to fill
data in. The driver buffer memory model was set to
CSPROPERTY_BUFFER_CLIENT_LIMITED originally. At every interrupt, the driver
copies the frame buffer into the client supplied buffer using memcpy. This
memcpy hogs the CPU and I can barely get 15 fps if my encoder filter is also
running in the DirectShow graph. I would like to avoid the copy by using the
CSPROPERTY_BUFFER_DRIVER memory model and have the hardware frame buffer
pointer passed all the way to my encoder filter. The encoder is running
remotely on a separate processor and I just need to convert the pointer back
to a physical address and pass this address to the remote encoder without any
copying taking place.

To start off, I just changed the memory model to CSPROPERTY_BUFFER_DRIVER
and made the following changes:


1. I made the following change to the AllocateBuffer function in my PDD
layer to just return the hardware frame buffer.

PVOID CCameraPdd::AllocateBuffer( ULONG ulModeType )

{

// Real PDD may want to save off this allocated pointer

// in an array.

// ULONG ulFrameSize = CS__DIBSIZE
(m_pCurrentFormat[ulModeType].VideoInfoHeader.bmiHeader);

// return RemoteLocalAlloc( LPTR, ulFrameSize );

return (m_pCameraHw->GetFrameBuffer());

}

2. In y PDD_FillBuffer, I do nothing and just return the size of the image.

I know I will have to use 2 or more frame buffers eventually to avoid memory
corruption issues, but I just wanted to test the concept first.

I am facing the following issues:

When the client calls IOCTL_CS_BUFFERS with the command CS_ENQUEUE, it
eventually results in a call to CPinDevice::EnqueueDescriptor which tries to
marshal the buffer. This results in a call to CeOpenCallerBuffer on the
buffer which fails with E_ACCESSDENIED. I noticed that the PDD portion is
allocating the buffer using HalAllocateCommonBuffer() and then it assigns a
virtual address to it using VirtualAlloc(NULL,dwSize,
MEM_RESERVE,PAGE_NOACCESS). I changed the access protection to PAGE_READONLY
but CeOpenCallerBuffer still fails.

Also, during CS_ENQUEUE, there is no call to the PDD layer to notify the
driver that it has been granted ownership of the buffer. If I allocate 2 or
more buffers in my PDD driver, how do I know when to switch frame buffers?

Any help on the above is appreciated. Thanks!


0 new messages