Quantcast
Channel: VBForums - CodeBank - Visual Basic 6 and earlier
Viewing all articles
Browse latest Browse all 1449

Video-Decompression with the VCM (ICM-Win32-API)

$
0
0
Just a small example, how to use the ICM-API (hosted in msvfw32.dll), to decode
YUV-RawData-Blobs as they may come in from Web- or other Cam-Drivers...

These APIs are still supported also on Win8/Win8.1 - and are wrapped here in a
small Class (cICMDecode.cls).

Two example-RawDataBlobs are contained in the Zip-File ...
- one representing a 640x480 12Bit 4:2:0 Input (460800 Bytes)
- the other a 640x480 16Bit 4:2:2 Input (614400 Bytes)

Some Background-Infos about YUV-ColorSpaces and -Decoding can be found here:
http://msdn.microsoft.com/en-us/libr...5%29.aspx#yv12
http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx

The Video-Compression-Manager-API is described here:
http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx

The Form-Code of the small Demo in the Zip depends on vbRichClient5 (downloadable from http://vbRichClient.com),
but the cICMDecode.cls itself has no RC5-dependency - so if you have your own
24Bit-RGB-DIB-Class-encapsulation at hand, you can adapt the Form-Code to your
own destination-buffer-handling - and achieve the same results...

The Form-Code is not very large:
Code:

Option Explicit

Private SrcBytes420_12Bit() As Byte, DecIYUV As New cICMDecode
Private SrcBytes422_16Bit() As Byte, DecYUY2 As New cICMDecode
 
Private DstDIB As cDIB '<- to provide the RGB24-decoding-buffer for both cases

Private Sub Form_Load()
  'try to open the two different ICM-Decoders first
  If Not DecIYUV.OpenDecoder(640, 480, DecIYUV.Make4CC("IYUV"), 12, 24) Then
    MsgBox "Couldn't open the IYUV(4:2:0) decoder": Unload Me: Exit Sub
  End If
  If Not DecYUY2.OpenDecoder(640, 480, DecYUY2.Make4CC("YUY2"), 16, 24) Then
    MsgBox "Couldn't open the YUY2(4:2:2) decoder": Unload Me: Exit Sub
  End If
 
  SrcBytes420_12Bit = New_c.FSO.ReadByteContent(App.Path & "\Planar YUV420.dat")
  SrcBytes422_16Bit = New_c.FSO.ReadByteContent(App.Path & "\Interleaved YUV422.dat")
 
  Set DstDIB = New_c.DIB(640, 480) 'allocate RGB24 decoding-memory in DstDIB
End Sub
 
Private Sub cmd420_Click()
  New_c.Timing True
    DecIYUV.Decode VarPtr(SrcBytes420_12Bit(0)), UBound(SrcBytes420_12Bit) + 1, DstDIB.pDIB
  Caption = New_c.Timing
  DstDIB.DrawTo picVidImg.hDC
End Sub

Private Sub cmd422_Click()
  New_c.Timing True
    DecYUY2.Decode VarPtr(SrcBytes422_16Bit(0)), UBound(SrcBytes422_16Bit) + 1, DstDIB.pDIB
  Caption = New_c.Timing
  DstDIB.DrawTo picVidImg.hDC
End Sub

Here's the Download-Link for the Zip-File (Code and Raw-Data-Files):
http://vbRichClient.com/Downloads/ICMDecoding.zip

And here a ScreenShot:


Olaf

Viewing all articles
Browse latest Browse all 1449

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>