Date: Sat, 19 Sep 1998 14:33:57 -0700 (PDT)
From: "Eugene Epshteyn"
To: Zaheer Shamsi
Subject: Re: Video compression... On Sun, 20 Sep 1998, Zaheer Shamsi wrote: > I went thru the iccompressxxx
> fucntions to but confused what to use and how to use. For audio, you need to setup WAVEFORMATEX structure and pass it to
capSetAudioFormat(). The audio you get in the callback function will be
already compressed. For video, you need to use ICxxx() functions. I don't remember what
exactly goes on on decompression side, but I will tell you about the
compression. Here's how to use ICxxx() compression functions: (1) At the initialization: (Here's the example of opening H263 compressor. You need to choose
compressor, which is apporpriate for your application.) HIC hic ; // Open the compressor
hic = ICOpen(ICTYPE_VIDEO, H263, ICMODE_FASTCOMPRESS); where H263 is defined like this: #define H263 (mmioFOURCC('h', '2', '6', '3')) // set compression options COMPVARS compressopt; NOTE: you can use ICCompressorChoose() to set COMPVARS structure. This
function fill bring up a dialog box, which will let you choose the
compressor yourself. If you don't use ICCompressorChoose(), you will need to assign members of
COMPVARS yourself: // You need to assign the fields with the input (uncompressed) format
// of the video which you obtain from the video capture
BITMAPINFO* pBitmapIn = NULL ; DWORD inSize = capGetVideoFormatSize(/* capture window */) ; pBitmapIn = (BITMAPINFO*) malloc(inSize) ; Here's the safe way to do it: capGetVideoFormat(
/* handle to your capture window*/,
pBitmapIn,
sizeof(BITMAPINFO)); /* modify relevant fields of bitmap_in according to your desired format */ BITMAPINFO* pBitmapOut = NULL ; DWORD outSize = ICCompressGetFormatSize(hic, pBitmapIn) ; pBitmapOut = (BITMAPINFO*) malloc(outSize) ; // get output bitmap format:
ICCompressGetFormat(hic, pBitmapIn, pBitmapOut) ; compressopt.cbSize = sizeof(COMPVARS);
compressopt.dwFlags = ICMF_COMPVARS_VALID;
compressopt.hic = hic;
compressopt.lpbiOut = pBitmapOut ;
compressopt.lKey = /* up to you: read COMPVARS documentation */ ;
compressopt.lQ = /* up to you */ ; (1.5) Just before you start capture: ICSeqCompressFrameStart(&compressopt, pBitmapIn); (2) In the callback function: LRESULT CALLBACK VideoCallbackProc(HWND hWnd, LPVIDEOHDR lpVHdr)
{ BOOL keyframe ;
long size = /* maximum desired size; read ICSeqCompressFrame()
documentation */ char* pCompressedFrame = (char*) ICSeqCompressFrame(
&compressopt,
0,
lpVHdr->lpData,
&keyframe,
&size) ; // you should get a pointer to compressed frame; I don't think you need
// to deallocate the data yourself, b/c compressor should do it for you.
// Make sure you send the size along with the data, b/c it will be
// variable. }
// end of callback function (2.5) Just after you stop capture: ICSeqCompressFrameEnd(&compressopt); (3) Cleanup: ICCompressorFree(&compressopt); NOTE: don't do free(pBitmapOut), b/c ICCompressorFree() will do
free(compressopt.lpbiOut), which is the same thing. NOTE: I don't remember if you need to call ICClose() on hic (see (1)) or
if ICCompressorFree() does it for you. That should do the compression for you. ----------------------------------------------- On the decompression side, I _suspect_ you need to use
ICImageDecompress(), where you obtain HIC the same way you obtained it
above (or set it to NULL: see documentation), lpbiIn is the same as
pBitmapOut above, lpbiOut is the same as pBitmapIn above, and lpBits is
the address of the buffer with the bits you received. What you get back
is the handle to uncompressed DIB, which you can convert to a pointer. And for audio you probably need to use waveOutOpen() and related
functions. --Eugene --
------------------------------------ ------------------------------------
~ Yevgeniy 'Eugene' Epshteyn ~ ~ nyethspE `eneguE` yinegveY ~
~ email: Eugene_Epshteyn@yahoo.com ~ ~ moc.oohay@nyethspE_eneguE :liame ~
~ www: http://eye.seagull.net ~ ~ ten.llugaes.eye\\:ptth :www ~
------------------------------------ ------------------------------------