djknickerbocker
Programmer
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
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