I am trying to write a simple decoder. The decoder connects to the upstream pin without issue but on connection with the downstream VMR I am having trouble getting the allocator to be set correctly. On debugging, I found this series of calls taking place:

When the output pin's CBaseOutputPin:: DecideAllocator function is called, first the downstream renderer's allocator is tried. The downstream allocator is obtained successfully. The ALLOCATOR_PROPERTIES structure returned by GetAllocatorRequirements on the downstream allocator is all zeroes. (should it be ). Then the DecideBufferSize function of my transform filter is called.

The ALLOCATOR_PROPERTIES structure I try inside DecideBufferSize consists of:

cBuffers = 1;
cbBuffer = dwWidth * dwHeight * 1.5 ; // YV12
cbAlign = 1;
cbPrefix = 0;

Calling SetProperties on the downstream allocator with this structure gives me a return code of E_INVALIDARG. Any ideas why this call does not work I have no idea why this happens.

Back inside CBaseOutputPin:: DecideAllocator, next my own decoder's allocator is tried. Inside my transform filter's DecideBufferSize again, the SetProperties call with the same structure as above succeeds. Returning back to DecideAllocator, on notifying the VMR input pin of my filter's allocator fails. This does not seem surprising as I have read in this forum that the VMR connection requires VMR's own allocator.

Can someone give me any ideas how to get this to work


Re: DirectShow Development decoder connection with vmr failing

Geraint Davies

Check the sample size in the media type that you have agreed with the vmr. Probably an extended stride makes the buffer size larger than your calculations.


Re: DirectShow Development decoder connection with vmr failing


I had a wrong media type set on the output pin with the renderer. I changed a bunch of options on the output media type, but the one which seemed to make the difference was changing the values for aspect ratio to:

pVih->dwPictAspectRatioX = 4;

pVih->dwPictAspectRatioY = 3;

Earlier I had

pVih->dwPictAspectRatioX = 3;

pVih->dwPictAspectRatioY = 0; (bug)