ImageEn, unit iemmf

TIEMFReceivedSample.DecodeSample

TIEMFReceivedSample.DecodeSample


Declaration

function DecodeSample(destBitmap: TIEBitmap): boolean;


Description

Decodes a video sample, filling the specified bitmap with the converted data.

Presently the following conversions are possible:
RGB24 -> RGB24 (copy only)
RGB32 -> RGB24
YUY2 -> RGB24
I420 -> RGB24
NV12 -> RGB24

Parameter Description
destBitmap The destination bitmap for the decoded video sample

Returns True on success. Returns False if the sample is not a video sample or if no decoder is found.


Example 1

// Handler for TImageEnView.OnMediaFoundatioNotify event
procedure TForm1.ImageEnView1MediaFoundationNotify(Sender, MediaFoundationObject: TObject; NotifyType: TIEMediaFountationNotifyType);
var
  sample: TIEMFReceivedSample;
begin
  if NotifyType = iemfnFRAME then // is this a frame?
  begin
    sample := ImageEnView1.IO.MediaFoundationSourceReader.GetNextSample();  // retrieve frame sample
    try
      sample.DecodeSample(ImageEnView1.IEBitmap); // convert frame sample to bitmap
      ImageEnView1.Update();                      // update TImageEnView to show the new bitmap
    finally
      sample.Free();                              // free the sample
    end;
  end;
end;


Applications add new decoders by using the IEMediaFoundationGetVideoSampleDecoders function and implementing the TIEMediaFoundationVideoSampleDecoder abstract class.


Example 2

IEMediaFoundationGetVideoSampleDecoders().Add(TIEMediaFoundationVideoSampleDecoder_YOURFORMAT.Create());