made some decklink/blackmagic specific adjustments, and made some improvements to the automatic fps/resolution selector

master
jp9000 2013-10-06 16:20:14 -07:00
parent d4f54a3c5f
commit 6fda31fc40
2 changed files with 51 additions and 27 deletions

View File

@ -365,6 +365,12 @@ bool DeviceSource::LoadFilters()
//------------------------------------------------
// initialize the basic video variables and data
if(FAILED(err = devicePin->QueryInterface(IID_IAMStreamConfig, (void**)&config)))
{
AppWarning(TEXT("DShowPlugin: Could not get IAMStreamConfig for device pin, result = %08lX"), err);
goto cleanFinish;
}
renderCX = renderCY = 0;
frameInterval = 0;
@ -377,7 +383,23 @@ bool DeviceSource::LoadFilters()
else
{
SIZE size;
if (!GetClosestResolutionFPS(outputList, size, frameInterval, true))
// blackmagic/decklink devices will display a black screen if the resolution/fps doesn't exactly match.
// they should rename the devices to blackscreen
if (sstri(strDeviceName, L"blackmagic") != NULL || sstri(strDeviceName, L"decklink") != NULL)
{
AM_MEDIA_TYPE *pmt;
config->GetFormat(&pmt);
VIDEOINFOHEADER *pVih = reinterpret_cast<VIDEOINFOHEADER*>(pmt->pbFormat);
// Use "preferred" format from the device
size.cx = pVih->bmiHeader.biWidth;
size.cy = pVih->bmiHeader.biHeight;
frameInterval = pVih->AvgTimePerFrame;
DeleteMediaType(pmt);
}
else if (!GetClosestResolutionFPS(outputList, size, frameInterval, true))
{
AppWarning(TEXT("DShowPlugin: Unable to find appropriate resolution"));
renderCX = renderCY = 64;
@ -481,12 +503,6 @@ bool DeviceSource::LoadFilters()
//------------------------------------------------
// configure video pin
if(FAILED(err = devicePin->QueryInterface(IID_IAMStreamConfig, (void**)&config)))
{
AppWarning(TEXT("DShowPlugin: Could not get IAMStreamConfig for device pin, result = %08lX"), err);
goto cleanFinish;
}
AM_MEDIA_TYPE outputMediaType;
CopyMediaType(&outputMediaType, bestOutput->mediaType);
@ -990,6 +1006,9 @@ void DeviceSource::Start()
return;
}
/*if (err == S_FALSE)
AppWarning(L"Ook");*/
bCapturing = true;
}

View File

@ -233,30 +233,35 @@ MediaOutputInfo* GetBestMediaOutput(const List<MediaOutputInfo> &outputList, UIN
if(priority == -1)
continue;
if( (!bUsePreferredType && (priority >= bestPriority || !bestMediaOutput)) ||
(bUsePreferredType && (UINT)outputInfo.videoType == preferredType))
UINT64 curInterval;
if(frameInterval > outputInfo.maxFrameInterval)
curInterval = outputInfo.maxFrameInterval;
else if(frameInterval < outputInfo.minFrameInterval)
curInterval = outputInfo.minFrameInterval;
else
curInterval = frameInterval;
UINT64 intervalDifference = (UINT64)_abs64(INT64(curInterval)-INT64(frameInterval));
if (intervalDifference > closestIntervalDifference)
continue;
bool better;
if (!bUsePreferredType)
better = priority > bestPriority || !bestMediaOutput || intervalDifference < closestIntervalDifference;
else
better = (UINT)outputInfo.videoType == preferredType && intervalDifference <= closestIntervalDifference;
if (better)
{
UINT64 curInterval;
if(frameInterval > outputInfo.maxFrameInterval)
curInterval = outputInfo.maxFrameInterval;
else if(frameInterval < outputInfo.minFrameInterval)
curInterval = outputInfo.minFrameInterval;
else
curInterval = frameInterval;
UINT64 intervalDifference = (UINT64)_abs64(INT64(curInterval)-INT64(frameInterval));
if(intervalDifference <= closestIntervalDifference)
{
closestIntervalDifference = intervalDifference;
bestFrameInterval = curInterval;
bestMediaOutput = &outputInfo;
bestPriority = priority;
}
closestIntervalDifference = intervalDifference;
bestFrameInterval = curInterval;
bestMediaOutput = &outputInfo;
bestPriority = priority;
}
}
}
frameInterval = bestFrameInterval;
return bestMediaOutput;
}
}