3

I'm developing USB camera streaming Desktop application using MediaFoundation SourceReader technique. The camera is having USB3.0 support and gives 60fps for 1080p MJPG video format resolution.

I used Software MJPEG Decoder MFT to convert MJPG to YUY2 frames and then converted into the RGB32 frame to draw on the window. Instead of 60fps, I'm able to render only 30fps on the window when using this software decoder. I have posted a question on this site and got some suggestion to use Intel Hardware MJPEG Decoder MFT to solve frame drop issue.

I have faced an error 0xC00D36B5 - MF_E_NOTACCEPTING when calling IMFTransform::ProcessInput() method. To solve this error, MSDN suggested using IMFTranform interface asynchronously. So, I used IMFMediaEventGenerator interface to GetEvent for every In/Out sample. Successfully, I can process only one input sample and then continuously IMFMediaEventGenerator:: GetEvent() methods returns MF_E_NO_EVENTS_AVAILABLE error(GetEvent() is synchronous).

I have tried to configure an asynchronous callback for SourceReader as well as IMFTransform but MFAsyncCallback:: Invoke method is not invoking, hence I planned to use GetEvent method.

Am I missing anything?If Yes, Someone guides me to use Intel Hardware Decoder into my project?

oguz ismail
  • 1
  • 16
  • 47
  • 69
Emily
  • 89
  • 8
  • have you tried to assemble a topology in topoedit first? – Mgetz Feb 03 '17 at 15:58
  • Thank you for your reply, Mgetz.The Camera supports both YUY2 and MJPG video format. Initially, Camera plays YUY2 video format and need to change MJPG format. I know how to build the graph in DirectShow. I didn't know how to switch from YUY2 to MJPEG video format.Could you tell me how to assemble a topology for MJPG format? Moreover, I have added this decoder in MediaSession topology, everything got success and received 0XC00D5212(MF_E_TOPO_CODEC_NOT_FOUND) in the event. – Emily Feb 05 '17 at 09:46
  • Hence the recommendation to try using the topoedit utility that ships with the SDK to assemble a topology and test that it works. If you can't construct a topology in topoedit... it's probably not possible. – Mgetz Feb 05 '17 at 13:59
  • Thank you for your reply Mgetz. I forgot to mention that I have worked on the topoedit tool to stream MJPG video format. With this tool, I couldn't assemble a topology for MJPG format. Do you know how to assemble/switch from YUY2 to MJPG format? – Emily Feb 06 '17 at 06:08

1 Answers1

2

Intel Hardware MJPEG Decoder MFT is an asynchronous MFT and if you are managing it directly, you are responsible to apply asynchronous model. You seem to be doing this but you don't provide information that allows nailing the problem down. Yes, you are supposed to use event model described in ProcessInput, ProcessOutput sections of the article linked above. As you get the first frame, you should debug further to make it work with smooth continuous processing.

When you use APIs like media session our source reader, you have Media Foundation itself dealing with the MFTs. It is capable of doing synchronous and asynchronous consumption when appropriate. In this case, however, you don't do IMFTransform calls and even from your vague description it comes you are doing it wrong way.

Roman R.
  • 68,205
  • 6
  • 94
  • 158
  • Thank you for correcting my mistake, Roman. I have registered an asynchronous callback and tried to get asynchronous events but I didn't get any events from IMFAsyncCallback::Invoke(). Can you please tell me how to register the asynchronous callback for SourceReader and access Hardware MFT? – Emily Feb 06 '17 at 05:59
  • I have registered the IMFAsyncCallback callback successfully for MFT. I received MFTransformNeedInput event to process input sample twice but MFTransformHaveOutput event is not at all invoked. I have attached code which I'm using it in my project. PFA the dropbox link to review my code : https://www.dropbox.com/s/t6figfl9b2kyp6y/HwMJPEGDecoderMFT_Code_Query.txt?dl=0. I have commented ProcessOutputSample() method in my code and checked, continuously MFTransformNeedInput event type receiving continuously. Could you please tell me what am doing wrong and why i didnt receive ProcessOutputSample? – Emily Feb 16 '17 at 13:57
  • @Abika: It is just a code snippet, I don't like a few moments there but more important is that it's not runnable and I am not sure what is causing the original problem you have issues with. I definitely don't like the way that you do `WaitForSingleObject` sequentially from a code fragment guarded by critical section. – Roman R. Feb 16 '17 at 16:56