AVStream Driver Allocator

Hi All,

We are working on an AV stream driver and would like to use our own
allocator to provide input/output data buffers.
We would like to avoid the memcopy to system memory by making the frames
available on the allocator with the memory mapped to user space.
I see that MSDN says that it is possible to provide your own allocator.
I also know the documentation available online says that the direct show
graph builder might or might NOT accept my allocator. But I still want
to give it a try.

Does anyone have any related information in this area?

Thanks & Regards
Abhishek Joshi

Abhishek Joshi wrote:

Hi All,

We are working on an AV stream driver and would like to use our own
allocator to provide input/output data buffers.
We would like to avoid the memcopy to system memory by making the
frames available on the allocator with the memory mapped to user space.
I see that MSDN says that it is possible to provide your own
allocator. I also know the documentation available online says that
the direct show graph builder might or might NOT accept my allocator.
But I still want to give it a try.

Does anyone have any related information in this area?

Kesava Guptha just asked this question. Are you working on the same
project?

You can’t force another component to accede to your wishes. You can
offer, but there’s no guarantee the graph will accept your offer.

However, the big problem is that you are micro-optimizing. The memcpy
overhead is insignificant. First, get it to work, and THEN see if it is
too slow. If you have a PCI device that does DMA, the avshws sample
shows how to do DMA using the user’s buffers directly, so you don’t need
a copy. If you have a USB device, then just do the memcpy.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Thanks for the response. Currently, we have ruled out DMA for some
testing on our device.
So, we are left with two options.

  1. Use PC DMA
  2. Use allocator method.

PC DMA can’t be used as it is meant for ISA/EISA devices. Thus, this is
the only option we are left with.

We did some work on getting it to work. Is there any FLAG or combination
of FLAGS we need to inform the graph builder in order to enable our own
allocator?

I think following are the available flag values in KSALLOCATOR_FRAMING
structure.

Requirement Flags

  1. KSALLOCATOR_REQUIREMENTF_INPLACE_MODIFIER
  2. KSALLOCATOR_REQUIREMENTF_SYSTEM_MEMORY
  3. KSALLOCATOR_REQUIREMENTF_FRAME_INTEGRITY
  4. KSALLOCATOR_REQUIREMENTF_MUST_ALLOCATE
  5. KSALLOCATOR_REQUIREMENTF_PREFERENCES_ONLY

Option Flags

  1. KSALLOCATOR_OPTIONF_COMPATIBLE
  2. KSALLOCATOR_OPTIONF_SYSTEM_MEMORY

We don’t see even our “AVStrMiniInitializeAllocator” function callback
getting called.

Thanks & Regards
Abhishek Joshi

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Tim Roberts
Sent: Tuesday, January 08, 2008 1:38 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] AVStream Driver Allocator

Abhishek Joshi wrote:

Hi All,

We are working on an AV stream driver and would like to use our own
allocator to provide input/output data buffers.
We would like to avoid the memcopy to system memory by making the
frames available on the allocator with the memory mapped to user
space.
I see that MSDN says that it is possible to provide your own
allocator. I also know the documentation available online says that
the direct show graph builder might or might NOT accept my allocator.
But I still want to give it a try.

Does anyone have any related information in this area?

Kesava Guptha just asked this question. Are you working on the same
project?

You can’t force another component to accede to your wishes. You can
offer, but there’s no guarantee the graph will accept your offer.

However, the big problem is that you are micro-optimizing. The memcpy
overhead is insignificant. First, get it to work, and THEN see if it is
too slow. If you have a PCI device that does DMA, the avshws sample
shows how to do DMA using the user’s buffers directly, so you don’t need
a copy. If you have a USB device, then just do the memcpy.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Abhishek Joshi wrote:

Thanks for the response. Currently, we have ruled out DMA for some
testing on our device.
So, we are left with two options.

  1. Use PC DMA
  2. Use allocator method.

PC DMA can’t be used as it is meant for ISA/EISA devices. Thus, this is
the only option we are left with.

I’m still confused as to why you think you need this. Where is the
memory going to come from? You can’t pass device memory into a pin that
will connect to user-mode.

Remember that at 640x480 YUY2 30fps, the additional copy is less than 1%
of your CPU load.

We did some work on getting it to work. Is there any FLAG or combination
of FLAGS we need to inform the graph builder in order to enable our own
allocator?

Again, I would point out that the graph manager is never obligated to
use your allocator. It might, depending on the needs of the next
downstream filter, or it might not. The decision tree is not documented.

I think following are the available flag values in KSALLOCATOR_FRAMING
structure.

Requirement Flags

  1. KSALLOCATOR_REQUIREMENTF_INPLACE_MODIFIER
  2. KSALLOCATOR_REQUIREMENTF_SYSTEM_MEMORY
  3. KSALLOCATOR_REQUIREMENTF_FRAME_INTEGRITY
  4. KSALLOCATOR_REQUIREMENTF_MUST_ALLOCATE
  5. KSALLOCATOR_REQUIREMENTF_PREFERENCES_ONLY

I believe you want MUST_ALLOCATE only.

Option Flags

  1. KSALLOCATOR_OPTIONF_COMPATIBLE
  2. KSALLOCATOR_OPTIONF_SYSTEM_MEMORY

I believe you want 0 here.

We don’t see even our “AVStrMiniInitializeAllocator” function callback
getting called.

And that may be your final answer.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.