Quantcast
Channel: Intel® Software - Media
Viewing all articles
Browse latest Browse all 2185

IMediaSample to pass to encoder

$
0
0

Here is my setup:

H264 encoded video.mp4 ---> LAV splitter ---> IntelQuickSync Decoder filter ---> My Filter ---> IntelQuickSync Encoder filter --> Enhanced Video Renderer

In "My Filter", in the receive function, if we simply do:

HRESULT OutputFrameGenerator::ReceiveInputFrame( InputPin& inputPin, IMediaSample& inputSample )

{

return m_outputPin.Deliver( &inputSample );

}

everything works fine. However if I try to simply copy the inputSample to another IMediaSample object, the delivery is successful, but the encoder crashes. Here is some test code just meant to illustrate the issue:

HRESULT OutputFrameGenerator::ReceiveInputFrame( InputPin& inputPin, IMediaSample& inputSample )
{
HRESULT retVal = S_OK;

IMediaSample* outputSample = nullptr;
REFERENCE_TIME startTime = 0;
REFERENCE_TIME endTime = 0;
REFERENCE_TIME startMediaTime = 0;
REFERENCE_TIME endMediaTime = 0;

m_outputPin.GetDeliveryBuffer( &outputSample, nullptr, nullptr, 0 );

retVal = inputSample.GetTime( &startTime, &endTime );
switch( retVal )
{
case VFW_S_NO_STOP_TIME:
retVal = outputSample->SetTime(&startTime, NULL);
break;
case S_OK:
retVal = outputSample->SetTime(&startTime, &endTime);
break;
default:
break;
}
retVal = inputSample.GetMediaTime( &startMediaTime, &endMediaTime );
switch( retVal )
{
case VFW_E_MEDIA_TIME_NOT_SET:
retVal = outputSample->SetMediaTime( NULL, NULL );
break;
case S_OK:
retVal = outputSample->SetMediaTime( &startMediaTime, &endMediaTime );
break;
default:
break;
}

unsigned int length = inputSample.GetActualDataLength();

retVal = outputSample->SetActualDataLength( length );
retVal = outputSample->SetDiscontinuity( inputSample.IsDiscontinuity() );
retVal = outputSample->SetPreroll( inputSample.IsPreroll() );
retVal = outputSample->SetSyncPoint( inputSample.IsSyncPoint() );

BYTE* inputPtr;
BYTE* outputPtr;
inputSample.GetPointer( &inputPtr );
outputSample->GetPointer( &outputPtr );

memcpy( outputPtr, inputPtr, length );
retVal = m_outputPin.Deliver( outputSample );
outputSample->Release();

}

We get this output:

First-chance exception at 0x000000018041BA02 (libmfxhw64.dll) in graphedit_x64.exe: 0xC0000005: Access violation reading location 0x000000001900E000.
First-chance exception at 0x00000001801A4AC5 (libmfxhw64.dll) in graphedit_x64.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.
The thread 0x2f90 has exited with code 1 (0x1).
The thread 0xe00 has exited with code 0 (0x0).

Thoughts?


Viewing all articles
Browse latest Browse all 2185

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>