Processes inputs but now eval is failing
This commit is contained in:
Родитель
b6da2f51e9
Коммит
a992ef42cf
|
@ -149,12 +149,6 @@
|
|||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Capture.h" />
|
||||
<ClInclude Include="CHWMFT\CAutoLock.h" />
|
||||
<ClInclude Include="CHWMFT\CHWMFT.h" />
|
||||
<ClInclude Include="CHWMFT\CHWMFT_DebugLogger.h" />
|
||||
<ClInclude Include="CHWMFT\CHWMFT_DecodeTask.h" />
|
||||
<ClInclude Include="CHWMFT\CSampleQueue.h" />
|
||||
<ClInclude Include="CHWMFT\IMYMFT.h" />
|
||||
<ClInclude Include="common.h" />
|
||||
<ClInclude Include="common\CAutoLock.h" />
|
||||
<ClInclude Include="common\CHWMFT_DebugLogger.h" />
|
||||
|
@ -165,25 +159,20 @@
|
|||
<ClInclude Include="common\GrowArray.h" />
|
||||
<ClInclude Include="Resource.h" />
|
||||
<ClInclude Include="SegmentModel.h" />
|
||||
<ClInclude Include="TransformAsync.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Capture.cpp" />
|
||||
<ClCompile Include="CHWMFT\CAutoLock.cpp" />
|
||||
<ClCompile Include="CHWMFT\CHWMFT.cpp" />
|
||||
<ClCompile Include="CHWMFT\CHWMFT_DebugLogger.cpp" />
|
||||
<ClCompile Include="CHWMFT\CHWMFT_DecodeTask.cpp" />
|
||||
<ClCompile Include="CHWMFT\CHWMFT_IMFAsyncCallback_Impl.cpp" />
|
||||
<ClCompile Include="CHWMFT\CHWMFT_IMFMediaEventGenerator_Impl.cpp" />
|
||||
<ClCompile Include="CHWMFT\CHWMFT_IMFShutdown_Impl.cpp" />
|
||||
<ClCompile Include="CHWMFT\CHWMFT_IMFTransform_Impl.cpp" />
|
||||
<ClCompile Include="CHWMFT\CHWMFT_IUnknown_Impl.cpp" />
|
||||
<ClCompile Include="CHWMFT\CSampleQueue.cpp" />
|
||||
<ClCompile Include="CHWMFT\dllmain.cpp" />
|
||||
<ClCompile Include="common\CAutoLock.cpp" />
|
||||
<ClCompile Include="common\CHWMFT_DebugLogger.cpp" />
|
||||
<ClCompile Include="common\CSampleQueue.cpp" />
|
||||
<ClCompile Include="PreviewWnd.cpp" />
|
||||
<ClCompile Include="SegmentModel.cpp" />
|
||||
<ClCompile Include="TransformAsync.cpp" />
|
||||
<ClCompile Include="TransformAsync_IMFAsyncCallback.cpp" />
|
||||
<ClCompile Include="TransformAsync_IMFMediaEventGenerator.cpp" />
|
||||
<ClCompile Include="TransformAsync_IMFShutdown.cpp" />
|
||||
<ClCompile Include="TransformAsync_IMFTransform.cpp" />
|
||||
<ClCompile Include="utils.cpp" />
|
||||
<ClCompile Include="winmain.cpp" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -7,36 +7,25 @@
|
|||
<ClCompile Include="utils.cpp" />
|
||||
<ClCompile Include="winmain.cpp" />
|
||||
<ClCompile Include="common\CSampleQueue.cpp" />
|
||||
<ClCompile Include="common\CHWMFT_DebugLogger.cpp" />
|
||||
<ClCompile Include="common\CAutoLock.cpp" />
|
||||
<ClCompile Include="CHWMFT\CAutoLock.cpp" />
|
||||
<ClCompile Include="CHWMFT\CHWMFT.cpp" />
|
||||
<ClCompile Include="CHWMFT\CHWMFT_DebugLogger.cpp" />
|
||||
<ClCompile Include="CHWMFT\CHWMFT_DecodeTask.cpp" />
|
||||
<ClCompile Include="CHWMFT\CHWMFT_IMFAsyncCallback_Impl.cpp" />
|
||||
<ClCompile Include="CHWMFT\CHWMFT_IMFMediaEventGenerator_Impl.cpp" />
|
||||
<ClCompile Include="CHWMFT\CHWMFT_IMFShutdown_Impl.cpp" />
|
||||
<ClCompile Include="CHWMFT\CHWMFT_IMFTransform_Impl.cpp" />
|
||||
<ClCompile Include="CHWMFT\CHWMFT_IUnknown_Impl.cpp" />
|
||||
<ClCompile Include="CHWMFT\CSampleQueue.cpp" />
|
||||
<ClCompile Include="CHWMFT\dllmain.cpp" />
|
||||
<ClCompile Include="TransformAsync.cpp" />
|
||||
<ClCompile Include="TransformAsync_IMFAsyncCallback.cpp" />
|
||||
<ClCompile Include="TransformAsync_IMFMediaEventGenerator.cpp" />
|
||||
<ClCompile Include="TransformAsync_IMFShutdown.cpp" />
|
||||
<ClCompile Include="TransformAsync_IMFTransform.cpp" />
|
||||
<ClCompile Include="common\CHWMFT_DebugLogger.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="SegmentModel.h" />
|
||||
<ClInclude Include="Capture.h" />
|
||||
<ClInclude Include="Resource.h" />
|
||||
<ClInclude Include="common.h" />
|
||||
<ClInclude Include="common\CHWMFT_DebugLogger.h" />
|
||||
<ClInclude Include="common\CAutoLock.h" />
|
||||
<ClInclude Include="common\CSampleQueue.h" />
|
||||
<ClInclude Include="common\GrowArray.h" />
|
||||
<ClInclude Include="common\critsec.h" />
|
||||
<ClInclude Include="CHWMFT\CAutoLock.h" />
|
||||
<ClInclude Include="CHWMFT\CHWMFT.h" />
|
||||
<ClInclude Include="CHWMFT\CHWMFT_DebugLogger.h" />
|
||||
<ClInclude Include="CHWMFT\CHWMFT_DecodeTask.h" />
|
||||
<ClInclude Include="CHWMFT\CSampleQueue.h" />
|
||||
<ClInclude Include="CHWMFT\IMYMFT.h" />
|
||||
<ClInclude Include="TransformAsync.h" />
|
||||
<ClInclude Include="common\CHWMFT_DebugLogger.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#include "Capture.h"
|
||||
#include "resource.h"
|
||||
#include "CHWMFT/CHWMFT.h"
|
||||
#include "TransformAsync.h"
|
||||
#include <winrt/Windows.Foundation.h>
|
||||
#include <winrt/base.h>
|
||||
#include <mfreadwrite.h>
|
||||
|
@ -404,7 +404,7 @@ HRESULT CaptureManager::StartPreview()
|
|||
|
||||
// Add the transform
|
||||
winrt::com_ptr<IMFTransform>pMFT;
|
||||
hr = CHWMFT::CreateInstance(pMFT.put());
|
||||
hr = TransformAsync::CreateInstance(pMFT.put());
|
||||
|
||||
// IMFCaptureSource
|
||||
hr = pSource->AddEffect(0, pMFT.get());
|
||||
|
|
|
@ -125,6 +125,10 @@ HRESULT TransformAsync::QueryInterface(REFIID iid, void** ppv)
|
|||
{
|
||||
*ppv = static_cast<IMFAsyncCallback*>(this);
|
||||
}
|
||||
else if (iid == __uuidof(TransformAsync))
|
||||
{
|
||||
*ppv = (TransformAsync*)this;
|
||||
}
|
||||
else if (iid == IID_IUnknown)
|
||||
{
|
||||
*ppv = static_cast<IUnknown*>(this);
|
||||
|
@ -164,10 +168,14 @@ HRESULT TransformAsync::ScheduleFrameInference(void)
|
|||
** we know m_pInputSampleQueue can never be
|
||||
** NULL due to InitializeTransform()
|
||||
***************************************/
|
||||
|
||||
CHECK_HR(hr = m_pInputSampleQueue->GetNextSample(pInputSample.put()));
|
||||
|
||||
// Create a pInferenceTask based on the chosen segmentModel, pass input sample
|
||||
// TODO: punkObject as an IMFSample?
|
||||
// TODO: Check to make sure pInputSample isn't null
|
||||
|
||||
|
||||
CHECK_HR(hr = MFCreateAsyncResult(pInputSample.get(), // Pointer to object stored in async result
|
||||
this, // Pointer to IMFAsyncCallback interface
|
||||
this, // Pointer to IUnkonwn of state object
|
||||
|
@ -200,7 +208,8 @@ HRESULT TransformAsync::SubmitEval(IMFSample* pInputSample)
|
|||
// Ensure we still have a valid d3d device
|
||||
CHECK_HR(hr = CheckDX11Device());
|
||||
|
||||
// Use the IMFSampleAllocator to allocate d3d11 video samples
|
||||
// Use the IMFSampleAllocator to allocate d3d11 video samples'
|
||||
// TODO: Is the the right way to get sample?
|
||||
CHECK_HR(hr = MFCreateSample(pOutputSample.put()));
|
||||
|
||||
// We allocate samples when have a dx device
|
||||
|
@ -216,6 +225,7 @@ HRESULT TransformAsync::SubmitEval(IMFSample* pInputSample)
|
|||
|
||||
// **** 2. Run inference on input sample
|
||||
src = SampleToD3Dsurface(pInputSample);
|
||||
// TODO: Fix device manager because pOutputSample isn't d3d backed, this call fails
|
||||
dest = SampleToD3Dsurface(pOutputSample.get());
|
||||
{
|
||||
// Do the copies inside runtest
|
||||
|
@ -701,8 +711,8 @@ HRESULT TransformAsync::InitializeTransform(void)
|
|||
CHECK_HR(hr = MFCreateAttributes(m_spAttributes.put(), MFT_NUM_DEFAULT_ATTRIBUTES));
|
||||
CHECK_HR(hr = m_spAttributes->SetUINT32(MF_TRANSFORM_ASYNC, TRUE));
|
||||
CHECK_HR(hr = m_spAttributes->SetUINT32(MFT_SUPPORT_DYNAMIC_FORMAT_CHANGE, TRUE));
|
||||
/*CHECK_HR(hr = m_spAttributes->SetUINT32(MF_SA_D3D_AWARE, TRUE));
|
||||
CHECK_HR(hr = m_spAttributes->SetUINT32(MF_SA_D3D11_AWARE, TRUE));*/
|
||||
CHECK_HR(hr = m_spAttributes->SetUINT32(MF_SA_D3D_AWARE, TRUE));
|
||||
CHECK_HR(hr = m_spAttributes->SetUINT32(MF_SA_D3D11_AWARE, TRUE));
|
||||
|
||||
// Initialize attributes for output sample allocator
|
||||
CHECK_HR(hr = MFCreateAttributes(m_spOutputAttributes.put(), 3));
|
||||
|
@ -934,13 +944,46 @@ HRESULT TransformAsync::OnDrain(
|
|||
{
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
AutoLock lock(m_critSec);
|
||||
if (m_pOutputSampleQueue->IsQueueEmpty())
|
||||
{
|
||||
IMFMediaEvent* pDrainCompleteEvent = NULL;
|
||||
hr = MFCreateMediaEvent(METransformDrainComplete, GUID_NULL, S_OK, NULL, &pDrainCompleteEvent);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
break;
|
||||
}
|
||||
/*******************************
|
||||
** Todo: This MFT only has one
|
||||
** input stream, so the drain
|
||||
** is always on stream zero.
|
||||
** Update this is your MFT
|
||||
** has more than one stream
|
||||
*******************************/
|
||||
hr = pDrainCompleteEvent->SetUINT32(MF_EVENT_MFT_INPUT_STREAM_ID, 0);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
break;
|
||||
}
|
||||
/***************************************
|
||||
** Since this in an internal function
|
||||
** we know m_pEventQueue can never be
|
||||
** NULL due to InitializeTransform()
|
||||
***************************************/
|
||||
hr = m_pEventQueue->QueueEvent(pDrainCompleteEvent);
|
||||
SAFE_RELEASE(pDrainCompleteEvent);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_dwStatus |= (MYMFT_STATUS_DRAINING);
|
||||
|
||||
m_dwStatus |= (MYMFT_STATUS_DRAINING);
|
||||
|
||||
}
|
||||
/*******************************
|
||||
** Todo: This MFT only has one
|
||||
** input stream, so it does not
|
||||
|
|
|
@ -44,23 +44,26 @@ HRESULT TransformAsync::Invoke(
|
|||
return hr;
|
||||
}
|
||||
|
||||
// Get the IMFSample tied to this specific Invoke call
|
||||
CHECK_HR(hr = pAsyncResult->GetObjectW(pObjectUnk.put()));
|
||||
pInputSample = pObjectUnk.try_as<IMFSample>();
|
||||
if (!pInputSample)
|
||||
{
|
||||
hr = E_NOINTERFACE;
|
||||
return hr;
|
||||
}
|
||||
|
||||
// Get the pMFT current state
|
||||
// TODO: pStateUnk isn't a TransformAsync>?
|
||||
CHECK_HR(hr = pAsyncResult->GetState(pStateUnk.put()));
|
||||
pMFT = pStateUnk.try_as<TransformAsync>();
|
||||
hr = pStateUnk->QueryInterface(__uuidof(TransformAsync), pMFT.put_void());
|
||||
//pMFT = pStateUnk.try_as<TransformAsync>();
|
||||
if (!pMFT)
|
||||
{
|
||||
hr = E_NOINTERFACE;
|
||||
return hr;
|
||||
}
|
||||
|
||||
// Get the IMFSample tied to this specific Invoke call
|
||||
CHECK_HR(hr = pAsyncResult->GetObjectW(pObjectUnk.put()));
|
||||
pInputSample.try_as<IMFSample>();
|
||||
if (!pInputSample)
|
||||
{
|
||||
hr = E_NOINTERFACE;
|
||||
return hr;
|
||||
}
|
||||
|
||||
// Now that scheduler has told us to process this sample, call SubmitEval with next
|
||||
// Available set of bindings, session.
|
||||
|
|
|
@ -836,13 +836,26 @@ HRESULT TransformAsync::ProcessInput(
|
|||
hr = E_POINTER;
|
||||
return hr;
|
||||
}
|
||||
|
||||
/*****************************************
|
||||
** Todo: If your MFT supports more than one
|
||||
** stream, make sure you modify
|
||||
** MFT_MAX_STREAMS and adjust this function
|
||||
** accordingly
|
||||
*****************************************/
|
||||
if (dwInputStreamID >= 1)
|
||||
{
|
||||
hr = MF_E_INVALIDSTREAMNUMBER;
|
||||
return hr;
|
||||
}
|
||||
|
||||
// First, put sample into the input Queue
|
||||
|
||||
/***************************************
|
||||
** Since this in an internal function
|
||||
** we know m_pInputSampleQueue can never be
|
||||
** NULL due to InitializeTransform()
|
||||
***************************************/
|
||||
/***************************************
|
||||
** Since this in an internal function
|
||||
** we know m_pInputSampleQueue can never be
|
||||
** NULL due to InitializeTransform()
|
||||
***************************************/
|
||||
CHECK_HR(hr = m_pInputSampleQueue->AddSample(pSample));
|
||||
|
||||
// Now schedule the work to decode the sample
|
||||
|
|
Загрузка…
Ссылка в новой задаче