Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Transform Filter w/ Overlay

Status
Not open for further replies.

djknickerbocker

Programmer
Jan 20, 2002
2
US
I wrote a transform filter to manipulate video data (i.e. contrast, brightness, etc.) coming out of a MPEG-2 decoder. If I use the RGB types it works fine. However, performance is not very good because of no use of the overlay. So I added support for the YUY2 type and used the Overlay Mixer filter. It passes data through in the Transform(IMediaSample * pIn) method and uses the overlay correctly.

If I set values in the IMediaSample buffer I see the change on the video screen and no performance problems. However, if I read the data and make modifications to it spikes the CPU and makes everything very slow (one frame every 1/2 a second). From what I read I thought maybe I was supposed to use the IDirectDrawSurface. However, the same problem occurs.

I have attached some of the code below. Check out the comments for the PERFORMANCE PROBLEMS to see what I am talking about.

Any ideas on what I am doing wrong?

.
.
.

IDirectDrawMediaSample * _ddmediasample = NULL;
pIn->QueryInterface(IID_IDirectDrawMediaSample, (void
**)&_ddmediasample);

if (_ddmediasample != NULL)
{
IDirectDrawSurface * _ddsurface = NULL;
RECT _rect;

_ddmediasample->GetSurfaceAndReleaseLock(&_ddsurface, &_rect);

if (_ddsurface != NULL)
{
int _dummyvar;
int _imagedatasize;
DDSURFACEDESC _desc;

_desc.dwSize = sizeof(DDSURFACEDESC);
HRESULT _hr = _ddsurface->Lock(NULL, &_desc,
DDLOCK_READONLY|DDLOCK_NOSYSLOCK , NULL);

_imagedatasize = _pbmi->biWidth*_pbmi->biHeight*2;

for (int i=0; i<_imagedatasize; i+=2)
{
// NOTE: MAJOR PERFORMANCE PROBLEMS
((char*)_desc.lpSurface) = ((char*)_desc.lpSurface) + 50;

// NOTE: NO PERFORMANCE PROBLEMS
((char*)_desc.lpSurface) = i+50;

// NOTE: NO PERFORMANCE PROBLEMS
_dummyvar = ((char*)_desc.lpSurface);
_dummyvar += 50;

// NOTE: MAJOR PERFORMANCE PROBLEMS
((char*)_desc.lpSurface) = _dummyvar;
}
_ddsurface->Unlock(NULL);
_ddsurface->Release();
}

_ddmediasample->LockMediaSamplePointer();
_ddmediasample->Release();
}


Thanks,
Doug

 
I have a similier problem, thats it seems you soloved, can you send me the begninig of the code, all the initializing? my projects fails when I try to do: pIn->QueryInterface(IID_IDirectDrawMediaSample, (void **)&_ddmediasample);


thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top