×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Transform Filter w/ Overlay

Transform Filter w/ Overlay

Transform Filter w/ Overlay

(OP)
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

RE: Transform Filter w/ Overlay

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close