I want to decode data using media foundation.
I have read this article:H.264 Decoder
when I create the decoder how to put the input byte data and get the output byte data?
I do notwant it read from files. i have byte array get from socket and I can play it using vlc how to decode the byte data ? then I can display it.
I searched that each frame starts with 0x00 0x00 0x00 0x01 and I can read each frame bytes and send to the decoder to get right data right?
now according @Romain.R 's example I can get the IMFMediaBuffer but I the Bitmap I can not use it directlly. I need convert it to RGB since it is NV12. how to do it in media foundation or direct2D so I can use gpu to accelerate it?
H.264 Video Decoder Media Foundation Transform decodes H.264 encoded stream with or without hardware acceleration.
Decode H.264 ES using Media Foundation shows how to manage the MFT in 100 lines of C++ code.
In the case of hardware acceleration, the transform does decoding on GPU leveraging DXVA, and you would obtain IMFSample
and IMFMediaBuffer
output backed by DirectX textures with video frames.
I can not use it directlly. I need convert it to RGB since it is NV12. how to do it in media foundation or direct2D so I can use gpu to accelerate it?
As documentation says, decoder output is MFVideoFormat_NV12
or close YUV 4:2:0 pixel formats. You can use another MFT Video Processor MFT to convert between the formats, including to RGB and including with GPU acceleration.
Quite so often you don't need to chain the transforms and manage them directly, you can, for example, use Source Reader to read from media source or byte stream (I guess you can find a suitable stock primitive for H.264/AVC ES), then set desired output format, and pull from the reader having it manage the required MFT chain underneath.