[AVStream] Enforce allocator requirements from kernel mode filter ?

In our kernel mode capture filter, we allocate 3 buffers of contiguous memory to hold the DMA scatter-gather lists of 3 frames that we will pass to the next filter. These buffers are allocated once during boot.
We want to “enforce” our allocator properties to the next filter: size, alignment AND number of frames.

The macro settings we use are:

DECLARE_SIMPLE_FRAMING_EX (
CapturePinAllocatorFraming,
STATICGUIDOF (KSMEMORY_TYPE_KERNEL_NONPAGED),
KSALLOCATOR_REQUIREMENTF_SYSTEM_MEMORY | KSALLOCATOR_REQUIREMENTF_MUST_ALLOCATE,
DEC_SG_DMA_PAGE_LIST_SECTORS, // Nr of frames = 3
// We need 64-byte alignment for the DMA
FILE_64_BYTE_ALIGNMENT,
VIDEO_MIN_WIDTH * VIDEO_MIN_HEIGHT * 2,
VIDEO_MAX_WIDTH * VIDEO_MAX_HEIGHT * 3
);

When we connect a user mode filter input pin to the output pin of our kernel mode capture filter and don’t take into account the allocator requirements, the number of buffers used is always 3.
When we demand a different number of frames from the user mode filter, howe can this be overruled by our kernel mode requirements ?

Thanks in advance for your help,

  • Bernard Willaert
    Healthcare Division
    Barco, Belgium

Some more info from the input pin point of view. The user mode filter connected to the capture output pin is a “dump” filter that writes frame data and other metadata to a text file.
When we set some allocator requirements in this filter, and we set the number of buffers differently than the settings in my previous post on the capture filter output, things go wrong ( frame tearing,…):

STDMETHODIMP CMNACaptureDebugInputPin::GetAllocatorRequirements(ALLOCATOR_PROPERTIES *pProps)
{
DbgLog((LOG_TRACE, 0, "[%s] ", FUNCTION));

BITMAPINFOHEADER *bmiHeader = getBitmapInfoHeader(&m_mt);
pProps->cbAlign = 64;
pProps->cBuffers = 4; //numBuffers;
pProps->cbPrefix = 0;
pProps->cbBuffer = bmiHeader->biWidth * abs(bmiHeader->biHeight) * (bmiHeader->biBitCount/8);
DbgLog((LOG_TRACE, 0, “[%s] bufferSize=[%d]”, FUNCTION, pProps->cbBuffer));

return S_OK;
}

In this case, the input pin wants 4 buffers instead of 3 from the output pin.
There is also a second callback in this user mode filter: NotifyAllocator, that confirms the 4 buffers will be used.

When we set the number of buffers in this user mode filter also to 3, or omit the GetAllocatorRequirements, things work fine.

At the capture output pin side, we only get the S/G lists for 3 buffers, not 4.