What are the pin formats that get chosen in each case? What does your YUV transform filter actually do?
=>Both connected directly with VMR and connected with a transform filter inserted between, Avshws’ output pin format is: YUY2 320*240, 16bits, rcSrc = {0, 0, 320, 240} rcDst = {0, 0, 0, 0}, and the input pin of VMR is YUY2 320*-240, 16bits, rcSrc = {0, 0, 320, 240} rcDst = {0, 0, 0, 0}. both the input pin and the output pin of the transform filter has the same format with Avshws’ output pin. there is no data format transform in the transform filter, it just allocated buffer for the output sample and copied data from input sample’s buffer to the output sample’s buffer.
notice that, in both cases, VMR’s input pin has a negative height -240.
the key code of the transform filter is as the following:
HRESULT CUYVYTransfer::DecideBufferSize(IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *ppropInputRequest)
{
HRESULT result;
ALLOCATOR_PROPERTIES ppropActual;
if (m_pInput->IsConnected() == FALSE)
{
return E_UNEXPECTED;
}
ppropInputRequest->cBuffers = 1;
ppropInputRequest->cbBuffer =m_lFrameSize;
ppropInputRequest->cbPrefix = 0;
result = pAlloc->SetProperties(ppropInputRequest, &ppropActual);
if (result != S_OK)
{
return result;
}
if (ppropActual.cbBuffer < ppropInputRequest->cbBuffer)
{
return E_FAIL;
}
return S_OK;
}
HRESULT CUYVYTransfer::Transform(IMediaSample *pIn, IMediaSample *pOut)
{
uint8_t *src_buffer=NULL;
uint8_t *dest_buffer=NULL;
if( pIn->GetPointer(&src_buffer)!=S_OK)
return S_FALSE;
if(pIn->GetActualDataLength()==0)
return S_FALSE;
if(pOut->GetPointer(&dest_buffer)!=S_OK)
return S_FALSE;
memcpy(dest_buffer,src_buffer,m_lFrameSize);
pOut->SetActualDataLength(m_lFrameSize);
return NOERROR;
}