• Advertisement

Archived

This topic is now archived and is closed to further replies.

DirectShow Performance Problem

This topic is 6073 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''ve been messing with DirectShow lately, and have a simple capture/playback app together. The problem I''ve having, is it takes nearly 100% of CPU to render the preview video. If I leave the IVideoWindow alone (i.e. a seperate window pops up for the preview), it works as expected. But if I set the owner window, it takes a great deal of processing power to render the window. I noticed that DShow has problems if the target window isn''t the same size as the preview/capture stream, so I change the size of my preview window to match the size of the video stream. Has anyone else encountered this problem? And what did you do about it?
  
	TESTHR(m_spVideoWindow->put_Owner((OAHWND)hWndRender_));
	
	//Sets the child window

	TESTHR(m_spVideoWindow->put_WindowStyle(WS_CHILD));
	
	//here we create a RECT in which to draw the child window on


	//Display the movie at the original size

	long lWidth, lHeight;
	m_spVideoWindow->get_Width(&lWidth);
	m_spVideoWindow->get_Height(&lHeight);
	
	//Set the Child to this position

	TESTHR(m_spVideoWindow->SetWindowPosition(0, 0, lWidth, lHeight));

	//Make the parent fit the preview

	int c = 12;
	MoveWindow(hWndRender_, c,c, lWidth, lHeight, FALSE);

  
Magmai Kai Holmlor - Not For Rent

Share this post


Link to post
Share on other sites
Advertisement
After more farting around than I''d like to admit, I worked this out (in case anyone else notices that the code in the DirectShow examples doesn''t work for $%*@!)
  
HRESULT hr;

//Make the video rendering surface appear inside the hWndRender_ window

TESTHR(m_spVideoWindow->put_Owner((OAHWND)hWndRender_));
TESTHR(m_spVideoWindow->put_WindowStyle(WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN));

//Retrive the video stream resolution

CComPtr<IBasicVideo> spBasicVideo;
TESTHR(m_spGraphBuilder.QueryInterface(&spBasicVideo));
long vHeight, vWidth;
TESTHR(spBasicVideo->GetVideoSize(&vWidth, &vHeight));

//See what the current window size is

RECT rect;
GetWindowRect(hWndRender_, &rect);
long wWidth, wHeight;
wWidth = rect.right - rect.left;
wHeight = rect.bottom - rect.top;

//See what the available client area is (given the above window size)

GetClientRect(hWndRender_, &rect);
long cWidth, cHeight;
cWidth = rect.right - rect.left;
cHeight = rect.bottom - rect.top;

//Compute the required increase in window size to produce a client area equal to the video resolution

long nHeight, nWidth;
nWidth = wWidth + (vWidth - cWidth);
nHeight = wHeight + (vHeight - cHeight);

//Increase the window size

SetWindowPos(hWndRender_, NULL, 0, 0, nWidth, nHeight, SWP_NOMOVE | SWP_NOOWNERZORDER);

//Verify the results

GetClientRect(hWndRender_, &rect);
cWidth = rect.right - rect.left;
cHeight = rect.bottom - rect.top;
_ASSERT(cWidth == vWidth);
_ASSERT(cHeight == vHeight);

//Set the video render window equal to the video frame resolution

TESTHR(m_spVideoWindow->SetWindowPosition(0,0, vWidth, vHeight));


Magmai Kai Holmlor
- Not For Rent

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Hey! your problem with speed depend of your video card. If you have a card that can do stretching blits by 2D hardware rasterization, there´s no trouble. (the only card that i have seen with this property.- Voodoo-Banshee LightSpeed by STD)

Share this post


Link to post
Share on other sites

  • Advertisement