I am trying to play an H264 video in a Direct3D app using an IMFSourceReader and a IMFTransform (CLSID_CMSH264DecoderMFT) to do the decoding. On every D3D call to render(), I want to read a sample from the SourceReader, push the sample through the decoder, and grab the uncompressed pixels from the decoder so they can be drawn to screen. Ideally, the decoder would write the decoded frame directly into a D3D surface, but... one thing at a time. (Why am I doing this? Because I want very precise control over which frame of my video draws on every render() call.)
So, I believe that I have properly set the input and output stream types for my decoder. My SourceReader is outputting MFVideoFormat_H264. My decoder input type is MFVideoFormat_H264. But every time I call pReader->ReadSample() and pDecoder->ProcessInput(0,pSample,0) and then pDecoder->GetOutputStatus(&flag), my flag suggests that the decoder needs more data before it can generate an output sample. This goes on for all 1800 calls to pReader->ReadSample, (by which time I've pushed about 8MB of data through my pSample -- just about the entire contents of the input video file, as expected.)
I suspect that my first call to ReadSample() should get me a large enough sample that I can decode the first frame. After all, on the second call, the timestamp returned is no longer 0!
...But my decoder is never satisfied with the data I send it. It keeps wanting more. Even if I just call pDecoder->ProcessOutput(0,1,&db,&status), it returns MF_E_TRANSFORM_NEED_MORE_INPUT.
I'm running Windows 7 64bit, but compiling as a Win32 application.
I haven't been able to find much of anything about this decoder online except for this one msdn page:
http://msdn.microsoft.com/en-us/library/dd797815%28VS.85%29.aspx
The video file that I am using is an H264 wrapped in a .mov. When I explicitly tell my SourceReader to read this file and show me the samples, it properly resolves the format types and knows how to deliver the samples properly for each frame. So I know the video file is ok. I want to use my own instance of the decoder because I feel like I have better control over the MFT_OUTPUT_DATA_BUFFER and will be able to route it more easily to a texture. If this can somehow be done right in the SourceReader, I'd love to avoid messing with an IMFTransform altogether.
Any idea why this might be happening? What details should I provide to make my issue clearer?
Thanks so much!
So, I believe that I have properly set the input and output stream types for my decoder. My SourceReader is outputting MFVideoFormat_H264. My decoder input type is MFVideoFormat_H264. But every time I call pReader->ReadSample() and pDecoder->ProcessInput(0,pSample,0) and then pDecoder->GetOutputStatus(&flag), my flag suggests that the decoder needs more data before it can generate an output sample. This goes on for all 1800 calls to pReader->ReadSample, (by which time I've pushed about 8MB of data through my pSample -- just about the entire contents of the input video file, as expected.)
I suspect that my first call to ReadSample() should get me a large enough sample that I can decode the first frame. After all, on the second call, the timestamp returned is no longer 0!
...But my decoder is never satisfied with the data I send it. It keeps wanting more. Even if I just call pDecoder->ProcessOutput(0,1,&db,&status), it returns MF_E_TRANSFORM_NEED_MORE_INPUT.
I'm running Windows 7 64bit, but compiling as a Win32 application.
I haven't been able to find much of anything about this decoder online except for this one msdn page:
http://msdn.microsoft.com/en-us/library/dd797815%28VS.85%29.aspx
The video file that I am using is an H264 wrapped in a .mov. When I explicitly tell my SourceReader to read this file and show me the samples, it properly resolves the format types and knows how to deliver the samples properly for each frame. So I know the video file is ok. I want to use my own instance of the decoder because I feel like I have better control over the MFT_OUTPUT_DATA_BUFFER and will be able to route it more easily to a texture. If this can somehow be done right in the SourceReader, I'd love to avoid messing with an IMFTransform altogether.
Any idea why this might be happening? What details should I provide to make my issue clearer?
Thanks so much!