#include
Void VideoQuencecompressor :: Init (HIC HIC, BitmapInfo * Pbiinput, BitmapInfo * PBIOUTPUT, Long LQ, Long Lkeyrate) {ICINFO INFO; LRESULT RES; int Cbsizein, CBSIZEOUT
Cbsizein = pbiinput-> bmiheader.bisize pbiinput-> bmiheader.biclrused * 4; cbsizeout = pbioutput-> bmiheader.bisize pbioutput-> bmiheader.biutput * 4;
This-> HIC = HIC; this-> pbiinput = (BitmapInfo *) New char [cbsizein]; this-> pbioutput = (bitmapinfo *) new char [cbsizeout]; this-> lkeyrate = lkeyrate;
Memcpy (this-> pbiinput, pbiinput, cbsizein); memcpy (this-> pbioutput, pbioutput, cbsizeout);
LKeyRateCounter = 1;
// Retrieve Compressor Information.
Res = icgetInfo (HIC, & Info, SizeOf Info);
If (! res) throw "Unable to retrieve video compressor information."
// Analyze compressor.
THIS-> dwflags = info.dwflags;
IF (info.dwflags & vidcf_temporal) {if (! (info.dwflags & vidcf_fastTemport) {// allocate Backbuffer
IF (! (pprevbuffer = new char [pBIINPUT-> bmiheader.bisizeImage])) throw "videosequence" :: init - memory allocation error ";}}
IF (Info.dwflags & Vid_quality) quality = lq; else lquality = 0;
// Allocate Destination Buffer
LmaxPackedSize = ICCompressgetsize (HIC, PBIINPUT, PBIOUTPUT);
IF (! (poutputbuffer = new char [lmaxpackedsize])) throw "videosequence" :: init - memory allocation error ";
// save configure state. // // ORDINARILY, WE WOULDN'T Do this, but the microsoft mpeg-4 Compressor That Causees It to reset ITS // Configuration Data After a Compression Session. This Occurs // in All Versions from v1 through v3. /// stupid fscking matrox driver returns -1 !!! cbconfigdata = icgetstatesize (HIC);
IF (cbconfigdata> 0) {if (! (pconfigdata = new char [cbconfigData)) throw "videosequence" :: init - memory allocation error ";
CBConfigData = icgetState (HIC, PCONFIGDATA, CBCONFIGDATA);
// AS ODD As this May Seem, IF this isn't Done, THENDEO5 / / COMPRESSOR WORD ALLOW DATA RATE CONTROL Until the next // compression Operation!
IcSetState (HIC, PCONFIGDATA, CBCONFIGDATA);
LMAXFRAMESIZE = 0; lslopspace = 0;}
bool VideoSequenceCompressor :: GetInstalledCodecs () {// Fill video codec list m_vInstalledCodecList.RemoveAll (); ICINFO codecInfo; HIC hic; int i = 0, j = 0; for (i = 0; ICInfo (ICTYPE_VIDEO, i, & codecInfo); i ) {hic = ICOpen (codecInfo.fccType, codecInfo.fccHandler, ICMODE_COMPRESS); if (hic) {if (codecInfo.fccType = ICTYPE_VIDEO) {ICClose (hic);! continue;} // Find out the compressor name ICGetInfo. (hic, & codecInfo, sizeof (codecInfo)); TVideoCodecInfo cnfo; cnfo.hic = hic; cnfo.fccHandler = codecInfo.fccHandler; memcpy (cnfo.szDescription, codecInfo.szDescription, 128 * sizeof (WCHAR)); memcpy (cnfo. SZDriver, Codecinfo.szdriver, 128 * SizeOf (Wchar)); Memcpy (cnfo.szname, codecinfo.szname, 16 * sizeof (wchar)); // Get State # if 1 dword size; size = icgetstatesize (HIC); if (size) {pbyte pv = new byte [size]; icget State (HIC, PV, SIZE); CNFo.SetSettings (PV, SIZE); CNFo.SetSettings1st (PV, Size); cnfo.setSettings2nd (PV, SIZE); Delete [] PV;} #ENDIF M_VINSTALLEDCODECLIST.SetaTtive (j , EnumeratevideoCodecs (640, 480); Return true;
bool VideoSequenceCompressor :: EnumerateVideoCodecs (int width, int height) {// Fill video codec list m_vVideoCodecList.RemoveAll (); BITMAPINFO bmpInfo; BITMAPINFOHEADER bi; memset (& bi, 0, sizeof (BITMAPINFOHEADER)); bi.biSize = sizeof (BITMAPINFOHEADER Bi.biwidth = width; bi.biheight = height; bi.biPlanes = 1; bi.biBitcount = 24; bi.bi.bi.bisizeimage = 0; bmpinfo.bmihead = bi; HIC HIC; INT i = 0, j = 0; for (i = 0; i // RGB bmpInfo.bmiHeader.biCompression = BI_RGB; bmpInfo.bmiHeader.biBitCount = 24; // Skip this compressor if it can not handle the format dwSupportedFormats = ICCompressQuery (hic, & bmpInfo, NULL) == ICERR_OK FLO_VIDEO_RGB32:. 0? ; // YV12 bmpInfo.bmiHeader.biCompression = '21VY'; bmpInfo.bmiHeader.biBitCount = 12;. // Skip this compressor if it can not handle the format dwSupportedFormats | = ICCompressQuery (hic, & bmpInfo, NULL) == ICERR_OK? FLO_VIDEO_YV12: 0; // YUY2 bmpInfo.bmiHeader.biCompression = '2YUY'; bmpInfo.bmiHeader.biBitCount = 16;. // Skip this compressor if it can not handle the format dwSupportedFormats | = ICCompressQuery (hic, & bmpInfo, NULL) == ICERR_OK? FLO_VIDEO_YUY2: 0; M_VinstalledCodeClist [i] .dwsupportedFormats = dwsupportedFormats;