Question

DirectShow filters allow to allocate multiple buffers in DecideBufferSize.

I have a transform filter that encodes raw frames with x264, generating 1+ NALs to pass upstream to next filter. I thought that allocating a pool of buffers for NALs can be a solution, but I can't figure out how to access all the buffers I've allocated before.

Maybe, there is a better way to solve the problem - allocate one big buffer and pass all the NALs inside?

Was it helpful?

Solution

On pin connection, pins agree on the memory allocator to use, and the method is question is involved in negotiation of parameters of such allocator. DecideBufferSize does NOT do allocation.

Next thing you possibly take incorrectly is using buffers. Eventually, you pass data using those buffers taking one by one and passing downstream. No matter how many buffers the allocator has, you can use even one buffer to pass all your NALUs because you stream buffers one by one anyway. If you have another NAL to deliver then you request new buffer (by the way, the method to request a new buffer is IMemAllocator::GetBuffer) to fill and you have it once there is a free one. So, amount of buffers is irrelevant and is not the answer to your problem.

You typically want more buffers if you are interested in buffering for some synchronous activity, or you need a few at a time, in which case DecideBufferSize is a good place to state your minimal requirements.

Stuffing multiple NALUs into single large buffer is unlikely to be a solution: you are basically expected to fill one buffer per frame, no matter how many NALUs are there. A buffer with NALUs without a frame is perhaps acceptable, but multiple frame NALUs in a single buffer are not/unlikely. Although, it is more a decoder/multiplexer compatibility question.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top