locked
IMFTransform::ProcessInput - API question RRS feed

  • Question

  • Hi,

    In the IMFTransform::ProcessInput  method documentation it is stated that:

    "In most cases, if the method succeeds, the MFT stores the sample and holds a reference count on the IMFSample pointer. Do not re-use the sample until the MFT releases the sample. Instead of storing the sample, however, an MFT might copy the sample data into a new buffer. In that case, the MFT should set the MFT_INPUT_STREAM_DOES_NOT_ADDREF flag in the IMFTransform::GetInputStreamInfo method."

    So, in the case that ProcessInput() stores the sample, how am I to know when it released the reference and I may reuse the sample.

    The reason I ask this is because I would like to do the following:

    1. Allocate sample (and buffer).

    2. Call ProcessOutput() to fill the sample buffer with media data.

    3. Call ProcessInput() and give it the sample.

    4. Once ProcessInput() does is done with the sample, I would like to be able to give it to ProcessOutput() again to refill.

    Obviously I mean to use a pool of pre-allocated samples, and the reason I would like to use this approach is so that I won't need to allocate a new sample each time.

    The problem I have is: How can I tell that ProcessInput() is done with the sample? Is there a way for the MFT to notify the caller that it no longer uses the sample?


    Thanks
    Saturday, April 14, 2012 12:26 AM

All replies

  • If you are just doing this for memory efficiency, then you probably do not need to allocate samples yourself.  The MF media session allocates a set of samples to meet the demand of the pipeline and cycles through these samples, so steps are already taken to be efficient with memory.

    If you need to track samples because they correspond to some limited resource (for example, video surfaces), then typically a custom IMFSample implementation is used that issues a callback on the allocator when its reference count goes to 0.  MFCreateVideoSampleFromSurface/IMFTrackedClass use this pattern already within the media foundation pipeline.

    Monday, May 21, 2012 8:01 PM