Monday, February 18, 2008

How can we achive the Dynamic Buffer size for the output pin of a Filter?

How can we achive the Dynamic Buffer size for the output pin of a Filter?:
---------------------------------------------------------------------------
within DecideBufferSize() fn, we have to allocate the maximum amount of memory.( if we know) it means the outputPin's media sample size is same as DecideBufferSize() memory size.
DecideBufferSize() fn - allocates 4000 bytes. then Each output media sample is having 4000 bytes of memory.Assume that Frame1 is having only 3000 bytes.For the rest of the 1000 bytes we have to fill it with zeroes.
ZeroMemory() fn is available to set the zero for specified buffer size.

Frame1 Output Sample:
Transform(IMediaSample* pInms,IMediaSample* pOutms){
BYTE* pbInputData; DWORD dwInputSize;
BYTE* pbOutputData; DWORD dwOutputSize; pInms->GetPointer(&pbInputData); dwInputSize = pInms->Getsize(); //3000
//Frame1 have only 3000 bytes of data. pOutms->GetPointer(&pbOutputData); dwOutputSize = pOutms->GetSize();
ZeroMemory(pbOutputData,dwOutputSize); memcpy(pbOutputData,pbInputData,dwInputSize); // only 3000 bytes are copied, the rest of the 1000 bytes are 0 }
we can use this mechanism for Resize filter .
we can allocate memory for the maximum resolution for the output pin.
1900x1400x3 - is the maximum resolution. For the Rest of the bytes just Fill them with zeroes.

No comments: