पर बिटमैप्स के रूप में वीडियो फ्रेम ड्रा करें मैं ब्लैकमैजिक एसडीके का उपयोग करके एक पूर्वावलोकन एप्लिकेशन लिखने की कोशिश कर रहा हूं, लेकिन मुझे चटपट प्लेबैक मिल रहा है। मैं एमएफसी फ्रेमवर्क का उपयोग कर रहा हूं, और मेरी वीडियो पूर्वावलोकन विंडो के लिए सीडब्ल्यूएनडी को उप-वर्गीकृत कर रहा हूं।एमएफसी विंडो
जब वीडियो का प्रत्येक फ्रेम आता है, तो मैं आरजीबी में रंग रूपांतरण करता हूं और फिर आरजीबी बिटमैप प्रदर्शित करने के लिए एक फ़ंक्शन कॉल करता हूं।
void VideoPreview::Display(int width, int height, byte* buffer)
{
__int64 begin = GetTickCount();
HRESULT hr;
CRect rcRect, statusBarRect;
GetClientRect (rcRect);
BITMAPINFO bmInfo;
ZeroMemory(&bmInfo, sizeof(BITMAPINFO));
bmInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmInfo.bmiHeader.biBitCount = 32;
bmInfo.bmiHeader.biPlanes = 1;
bmInfo.bmiHeader.biWidth = width;
bmInfo.bmiHeader.biHeight = -height;
dc->SetStretchBltMode(COLORONCOLOR);
int iResult = StretchDIBits(*dc,
rcRect.left, rcRect.top, rcRect.right, rcRect.bottom,
0, 0, width, height,
buffer, &bmInfo, 0, SRCCOPY);
DWORD dwError;
if (iResult == 0 || iResult == GDI_ERROR)
{
dwError = GetLastError();
}
else
fpsCount++;
procTimeCount += GetTickCount() - begin;
}
चिकनी वीडियो बनाने के लिए क्या किया जा सकता है?
अद्यतन:
मैं Direct2D बजाय GDI के साथ जा रहा समाप्त हो गया और बेहतर प्रदर्शन मिल गया है। नीचे दिए गए कोड है कि मैं क्या प्रतिपादन के लिए अब का उपयोग कर रहा है:
// initialization
HRESULT hr = D2D1CreateFactory(
D2D1_FACTORY_TYPE_SINGLE_THREADED,
&pD2DFactory
);
// Obtain the size of the drawing area.
RECT rc;
GetClientRect(&rc);
// Create a Direct2D render target
hr = pD2DFactory->CreateHwndRenderTarget(
D2D1::RenderTargetProperties(),
D2D1::HwndRenderTargetProperties(
this->GetSafeHwnd(),
D2D1::SizeU(
1280, 720
/*rc.right - rc.left,
rc.bottom - rc.top*/)
),
&pRT);
D2D1_BITMAP_PROPERTIES properties;
properties.pixelFormat = D2D1::PixelFormat(
DXGI_FORMAT_B8G8R8A8_UNORM,
D2D1_ALPHA_MODE_IGNORE);
properties.dpiX = properties.dpiY = 96;
hr = pRT->CreateBitmap(D2D1::SizeU(1280, 720), properties, &pBitmap);
ASSERT(SUCCEEDED(hr));
// per frame code
// buffer is rgb frame
HRESULT hr;
pRT->BeginDraw();
pBitmap->CopyFromMemory(NULL, buffer, width*4);
pRT->DrawBitmap(pBitmap);
pRT->EndDraw();
एक समय में एक फ्रेम करना चतुर वीडियो का कारण बन जाएगा क्योंकि यह आज के प्रोसेसर के साथ भी बहुत धीमा है। आपको एक वीडियो पाइपलाइन का उपयोग करने की आवश्यकता है। –
वैसे वीडियो को यथासंभव वास्तविक समय के करीब प्रदर्शित करने की आवश्यकता है। वीडियो पाइपलाइन पर कोई सुझाव? – wshirey
क्षमा करें, अगर मेरे पास कोई सुझाव था तो मैंने जवाब छोड़ दिया होगा। –