您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ AVIFileOpen函数代码示例

51自学网 2021-06-01 19:38:51
  C++
这篇教程C++ AVIFileOpen函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中AVIFileOpen函数的典型用法代码示例。如果您正苦于以下问题:C++ AVIFileOpen函数的具体用法?C++ AVIFileOpen怎么用?C++ AVIFileOpen使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了AVIFileOpen函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: close

bool CvCaptureAVI_VFW::open( const char* filename ){    close();    icvInitCapture_VFW();    if( !filename )        return false;    HRESULT hr = AVIFileOpen( &avifile, filename, OF_READ, NULL );    if( SUCCEEDED(hr))    {        hr = AVIFileGetStream( avifile, &avistream, streamtypeVIDEO, 0 );        if( SUCCEEDED(hr))        {            hr = AVIStreamInfo( avistream, &aviinfo, sizeof(aviinfo));            if( SUCCEEDED(hr))            {                size.width = aviinfo.rcFrame.right - aviinfo.rcFrame.left;                size.height = aviinfo.rcFrame.bottom - aviinfo.rcFrame.top;                BITMAPINFOHEADER bmihdr = icvBitmapHeader( size.width, size.height, 24 );                film_range.start_index = (int)aviinfo.dwStart;                film_range.end_index = film_range.start_index + (int)aviinfo.dwLength;                fps = (double)aviinfo.dwRate/aviinfo.dwScale;                pos = film_range.start_index;                getframe = AVIStreamGetFrameOpen( avistream, &bmihdr );                if( getframe != 0 )                    return true;            }        }    }    close();    return false;}
开发者ID:MasaMune692,项目名称:alcexamples,代码行数:35,


示例2: test_ash1_corruption2

static void test_ash1_corruption2(void){    COMMON_AVI_HEADERS cah;    char filename[MAX_PATH];    PAVIFILE pFile;    int res;    PAVISTREAM pStream1;    AVISTREAMINFO asi1;    GetTempPath(MAX_PATH, filename);    strcpy(filename+strlen(filename), testfilename);    /* Corrupt the block alignment in the audio format header */    init_test_struct(&cah);    cah.pcmwf.wf.nBlockAlign = 0xdead;    create_avi_file(&cah, filename);    res = AVIFileOpen(&pFile, filename, OF_SHARE_DENY_WRITE, 0L);    ok(res == 0, "Unable to open file: error=%u/n", res);    res = AVIFileGetStream(pFile, &pStream1, 0, 1);    ok(res == 0, "Unable to open audio stream: error=%u/n", res);    ok(AVIStreamInfo(pStream1, &asi1, sizeof(AVISTREAMINFO)) == 0, "Unable to read stream info/n");    /* The result will also be the corrupt value, as explained above. */    ok(asi1.dwSampleSize == 0xdead, "got 0x%x (expected 0xdead)/n", asi1.dwSampleSize);    AVIStreamRelease(pStream1);    AVIFileRelease(pFile);    ok(DeleteFile(filename) !=0, "Deleting file %s failed/n", filename);}
开发者ID:austin987,项目名称:wine,代码行数:33,


示例3: test_ash1_corruption

static void test_ash1_corruption(void){    COMMON_AVI_HEADERS cah;    char filename[MAX_PATH];    PAVIFILE pFile;    int res;    PAVISTREAM pStream1;    AVISTREAMINFO asi1;    GetTempPath(MAX_PATH, filename);    strcpy(filename+strlen(filename), testfilename);    /* Corrupt the sample size in the audio stream header */    init_test_struct(&cah);    cah.ash1.dwSampleSize = 0xdeadbeef;    create_avi_file(&cah, filename);    res = AVIFileOpen(&pFile, filename, OF_SHARE_DENY_WRITE, 0L);    ok(res == 0, "Unable to open file: error=%u/n", res);    res = AVIFileGetStream(pFile, &pStream1, 0, 1);    ok(res == 0, "Unable to open audio stream: error=%u/n", res);    res = AVIStreamInfo(pStream1, &asi1, sizeof(AVISTREAMINFO));    ok(res == 0, "Unable to read stream info: error=%u/n", res);    /* The result will still be 2, because the value is dynamically replaced with the nBlockAlign       value from the stream format header. The next test will prove this */    ok(asi1.dwSampleSize == 2, "got %u (expected 2)/n", asi1.dwSampleSize);    AVIStreamRelease(pStream1);    AVIFileRelease(pFile);    ok(DeleteFile(filename) !=0, "Deleting file %s failed/n", filename);}
开发者ID:austin987,项目名称:wine,代码行数:35,


示例4: CreateAvi

HAVI CreateAvi (const TCHAR *filename, int frameperiod, const WAVEFORMATEX *wfx){	PAVIFILE pfile;	HRESULT hr;	TAviUtil *au;	AVIFileInit();	hr = AVIFileOpen(&pfile, filename, OF_WRITE | OF_CREATE, NULL);	if (hr)	{		AVIFileExit();		return NULL;	}	au = (TAviUtil *)malloc(sizeof(TAviUtil));	au->pfile = pfile;	if (wfx)		CopyMemory(&au->wfx, wfx, sizeof(WAVEFORMATEX));	else	ZeroMemory(&au->wfx, sizeof(WAVEFORMATEX));	au->period = frameperiod;	au->audStream = NULL;	au->vidStream = NULL;	au->vidStreamComp = NULL;	au->nframe = 0;	au->nsamp = 0;	au->iserr = FALSE;	return (HAVI)au;}
开发者ID:MounikaArkala,项目名称:txstateprojects,代码行数:27,


示例5: FileDlg

void CMainFrame::InitAVIWriteOpt(){	CString filename;	CFileDialog FileDlg(FALSE,_T("avi"));	if (FileDlg.DoModal()==IDOK)	{		filename = FileDlg.GetPathName();		//capGetVideoFormat(m_hWndCap,&m_InInfo,sizeof(m_InInfo));		m_Frame = 0 ;		//AVI文件初始化		AVIFileInit() ;		bSaveAVI = TRUE;				//打开文件		AVIFileOpen(&m_pFile,filename,OF_WRITE | OF_CREATE,NULL);		memset(&strhdr, 0, sizeof(strhdr)) ;		strhdr.fccType    = streamtypeVIDEO; 		strhdr.fccHandler = 0  ;		strhdr.dwScale    = 1  ;		strhdr.dwRate     = 25 ; 		strhdr.dwSuggestedBufferSize = lpbiIn->bmiHeader.biSizeImage;		SetRect(&strhdr.rcFrame, 0, 0, lpbiIn->bmiHeader.biWidth, lpbiIn->bmiHeader.biHeight);		ps = NULL;		//文件文件流		AVIFileCreateStream(m_pFile,&ps,&strhdr); 				//开始捕捉		capCaptureSequenceNoFile(m_hWndCap);	}}
开发者ID:hiccupzhu,项目名称:misc_starting,代码行数:30,


示例6: AVIFileInit

int imFileFormatAVI::New(const char* file_name){  /* initializes avi file library, can be called many times */  AVIFileInit();  /* creates a new file */  HRESULT hr = AVIFileOpen(&file, file_name, OF_WRITE | OF_CREATE, NULL);  if (hr != 0)  {    AVIFileExit();    if (hr == AVIERR_FILEOPEN)      return IM_ERR_OPEN;    else if (hr == AVIERR_BADFORMAT || hr == REGDB_E_CLASSNOTREG)      return IM_ERR_FORMAT;    else      return IM_ERR_ACCESS;  }  this->frame = 0;  this->stream = 0;  this->use_compressor = 0;  this->dib = 0;  return IM_ERR_NONE;}
开发者ID:gcfavorites,项目名称:tastools,代码行数:26,


示例7: Open

bool CBmpToAvi::Open( LPCTSTR szFile, LPBITMAPINFO lpbmi ){	if (szFile == NULL)		return false;	m_nFrames = 0;	if (AVIFileOpen(&m_pfile, szFile, OF_WRITE | OF_CREATE, NULL))		return false;	m_si.fccType = streamtypeVIDEO;	m_si.fccHandler = BI_RGB;	m_si.dwScale = 1;	m_si.dwRate = 5; // 每秒5帧	SetRect(&m_si.rcFrame, 0, 0, lpbmi->bmiHeader.biWidth, lpbmi->bmiHeader.biHeight);	m_si.dwSuggestedBufferSize = lpbmi->bmiHeader.biSizeImage;	if (AVIFileCreateStream(m_pfile, &m_pavi, &m_si))		return false;	if (AVIStreamSetFormat(m_pavi, 0, lpbmi, sizeof(BITMAPINFO)) != AVIERR_OK)		return false;	return true;}
开发者ID:26597925,项目名称:Remote,代码行数:26,


示例8: AVIFileInit

bool CAviHelper::AVI_resolution(const wstring& strAviFileName, int& width, int& height){	AVIFileInit();	PAVIFILE avi;	int res = AVIFileOpen(&avi, WS2S(strAviFileName).c_str(), OF_READ, NULL);	int n = GetLastError();	if (res!=AVIERR_OK)	{		//an error occures		if (avi!=NULL)			AVIFileRelease(avi);		return false;	}	AVIFILEINFO avi_info;	memset(&avi_info, 0, sizeof(AVIFILEINFO));	res = AVIFileInfo(avi, &avi_info, sizeof(AVIFILEINFO));	if( res != AVIERR_OK)	{		AVIFileExit();		return false;	}	width = avi_info.dwWidth;	height = avi_info.dwHeight;	AVIFileExit();	return true;}
开发者ID:killbug2004,项目名称:DvrWorkstation,代码行数:29,


示例9: AVIFileOpen

bool CAVIFile::Open(const char *filename){  HRESULT hr = AVIFileOpen(&pfile,		    // returned file pointer                           filename,							// file name                           OF_WRITE | OF_CREATE,		    // mode to open file with                           NULL);							// use handler determined  // from file extension....  if (hr != AVIERR_OK) {    bOK = false;    return false;  }  memset(&strhdr, 0, sizeof(strhdr));  strhdr.fccType                = streamtypeVIDEO;// stream type  strhdr.fccHandler             = 0;  strhdr.dwScale                = 1;  strhdr.dwRate                 = rate;  strhdr.dwSuggestedBufferSize  = bitmap.biSizeImage;  SetRect(&strhdr.rcFrame,          0,          0,		    // rectangle for stream          (int) bitmap.biWidth,          (int) bitmap.biHeight);        // And create the stream;  hr = AVIFileCreateStream(pfile,		    // file pointer                           &ps,		    // returned stream pointer                           &strhdr);	    // stream header  if (hr != AVIERR_OK) {    bOK = false;    return false;  }        memset(&opts, 0, sizeof(opts));    if(!AVISaveOptions(hWindow, 0, 1, &ps, aopts)) {    bOK = false;    return false;  }        hr = AVIMakeCompressedStream(&psCompressed, ps, &opts, NULL);  if (hr != AVIERR_OK) {    bOK = false;    return false;  }        hr = AVIStreamSetFormat(psCompressed, 0,                          &bitmap,	    // stream format                          bitmap.biSize +   // format size                          bitmap.biClrUsed * sizeof(RGBQUAD));  if (hr != AVIERR_OK) {    bOK = false;    return false;  }  return true;}
开发者ID:BackupTheBerlios,项目名称:vbastep-svn,代码行数:56,


示例10: OpenSoundFile

BOOL OpenSoundFile(HWND hWnd,PAVISTREAM *pavi)	{#ifndef INTERIM_64_BIT	// CCJ	OPENFILENAME ofn;	char filter[256];	AVIBuildFilter(filter,sizeof(filter),FALSE);	ofn.lStructSize       = sizeof(OPENFILENAME);	ofn.hwndOwner         = hWnd;	ofn.hInstance         = NULL;		ofn.lpstrTitle        = GetResString(IDS_RB_OPENSOUND);	ofn.lpstrFilter       = filter;	ofn.lpstrCustomFilter = NULL;	ofn.nMaxCustFilter    = 0;	ofn.nFilterIndex      = 0;	ofn.lpstrFile         = fileName;	ofn.nMaxFile          = sizeof(fileName);	ofn.lpstrFileTitle    = NULL;	ofn.nMaxFileTitle     = 0;	ofn.lpstrInitialDir   = NULL;	ofn.Flags             = OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST|OFN_HIDEREADONLY;	ofn.nFileOffset       = 0;	ofn.nFileExtension    = 0;	ofn.lpstrDefExt       = NULL;	ofn.lCustData         = 0;	ofn.lpfnHook          = NULL;	ofn.lpTemplateName    = NULL;	if (GetOpenFileNamePreview(&ofn)) {		HRESULT		hr;    	PAVIFILE	pfile;		PAVISTREAM	pstream;		BOOL res = TRUE;   	 	hr = AVIFileOpen(&pfile,fileName,OF_READ,NULL);    	if (hr) return FALSE;		if (AVIFileGetStream(				pfile,&pstream,streamtypeAUDIO,0) != AVIERR_OK) {						res = FALSE;			goto done;			}				*pavi = pstream;	done:		AVIFileRelease(pfile);		return res;	} else {		return FALSE;		}#else	// INTERIM_64_BIT	return FALSE;#endif	// INTERIM_64_BIT	}
开发者ID:2asoft,项目名称:xray,代码行数:56,


示例11: _Open

		bool AviFrameGraber::_Open(void){			//thread_handle_ !=NULL means it is already opened			if (thread_handle_!=NULL)	return false;			int res=AVIFileOpen(&avi_file_, file_path_.c_str(), OF_READ, NULL);			if (res!=AVIERR_OK){				woodychang0611::diagnostics::SendError(_T("AviFrameGraber Open File Fail"));				_Close();				return false;			}			res=AVIFileGetStream(avi_file_, &stream_, streamtypeVIDEO, 0/*first stream*/);			if (res!=AVIERR_OK){				woodychang0611::diagnostics::SendError(_T("AviFrameGraber Get Stream Fail"));				_Close();				return false;			}			if (AVIStreamStart(stream_)==-1 || AVIStreamLength(stream_)==-1){				woodychang0611::diagnostics::SendError(_T("AviFrameGraber Stream Start or Length no correct"));				_Close();				return false;											}			AVIFileInfo(avi_file_, &avi_info_, sizeof(AVIFILEINFO));			BITMAPINFOHEADER bih;			bih.biSize = sizeof(BITMAPINFOHEADER);			bih.biWidth = avi_info_.dwWidth;			bih.biHeight = avi_info_.dwHeight;			bih.biPlanes = 1;			bih.biBitCount = 24;			bih.biCompression = BI_RGB;			bih.biSizeImage = 0;			bih.biXPelsPerMeter = 0;			bih.biYPelsPerMeter = 0;			bih.biClrUsed = 0;			bih.biClrImportant = 0;			frame_=AVIStreamGetFrameOpen(stream_, (LPBITMAPINFOHEADER) &bih);			if (frame_ !=NULL){				start_frame_ = AVIStreamStart(stream_);				frame_length_ = AVIStreamLength(stream_);				current_frame_ = start_frame_;				//Set Frame info				frame_info_.start_frame_=start_frame_;				frame_info_.frame_length_ =frame_length_; 				frame_info_.frame_per_second_=(FLOAT32)avi_info_.dwRate/avi_info_.dwScale;				frame_info_.frame_width_=(UINT16) avi_info_.dwWidth;				frame_info_.frame_height_=(UINT16)  avi_info_.dwHeight;				_status = FRAME_SUBJECT_PAUSE;				thread_handle_ =CreateThread(NULL ,0,this->_ThreadFunc,this,0,NULL);				return true;			}else{				woodychang0611::diagnostics::SendError(_T("AviFrameGraber Get Frame Failed"));			}			return false;		}
开发者ID:woodychang0611,项目名称:CLRImageDemo,代码行数:54,


示例12: Open

bool AVIWrite::Open(const char *filename){  // create the AVI file  if(FAILED(AVIFileOpen(&m_file,                        filename,                        OF_WRITE | OF_CREATE,                        NULL))) {    m_failed = true;    return false;  }  // setup the video stream information  ZeroMemory(&m_header, sizeof(AVISTREAMINFO));  m_header.fccType = streamtypeVIDEO;  m_header.dwScale = 1;  m_header.dwRate = m_fps;  m_header.dwSuggestedBufferSize  = m_bitmap.biSizeImage;  // create the video stream  if(FAILED(AVIFileCreateStream(m_file,                                &m_stream,                                &m_header))) {    m_failed = true;    return false;  }        ZeroMemory(&m_options, sizeof(AVICOMPRESSOPTIONS));  m_arrayOptions[0] = &m_options;  // call the dialog to setup the compress options to be used  if(!AVISaveOptions(AfxGetApp()->m_pMainWnd->GetSafeHwnd(), 0, 1, &m_stream, m_arrayOptions)) {    m_failed = true;    return false;  }    // create the compressed stream  if(FAILED(AVIMakeCompressedStream(&m_streamCompressed, m_stream, &m_options, NULL))) {    m_failed = true;    return false;  }    // setup the video stream format  if(FAILED( AVIStreamSetFormat(m_streamCompressed, 0,                                &m_bitmap,                                m_bitmap.biSize +                                m_bitmap.biClrUsed * sizeof(RGBQUAD)))) {    m_failed = true;    return false;  }  return true;}
开发者ID:Brukwa,项目名称:VisualBoyAdvance,代码行数:51,


示例13: CreateAvi

HAVI CreateAvi(const char *fn, int frameperiod, const WAVEFORMATEX *wfx){ IAVIFile *pfile;  AVIFileInit();  HRESULT hr = AVIFileOpen(&pfile, fn, OF_WRITE|OF_CREATE, NULL);  if (hr!=AVIERR_OK) {AVIFileExit(); return NULL;}  TAviUtil *au = new TAviUtil;  au->pfile = pfile;  if (wfx==NULL) ZeroMemory(&au->wfx,sizeof(WAVEFORMATEX)); else CopyMemory(&au->wfx,wfx,sizeof(WAVEFORMATEX));  au->period = frameperiod;  au->as=0; au->ps=0; au->psCompressed=0;  au->nframe=0; au->nsamp=0;  au->iserr=false;  return (HAVI)au;}
开发者ID:QuinntyneBrown,项目名称:blog,代码行数:14,


示例14: AVIFileInit

void VideoReader::Open(CString strFilePath){        AVIFileInit();    LONG hr;      hr = AVIStreamOpenFromFile(&m_pAviStream, strFilePath, streamtypeVIDEO, 0, OF_READ, NULL);    if (hr != 0){         // Handle failure.        AfxMessageBox(L"Failed to open file, file must be an uncompressed video.");     }    else    {        HRESULT          hr;         AVISTREAMINFO    strhdr;         LONG             lStreamSize;          // Determine the size of the format data using         // AVIStreamFormatSize.         AVIStreamFormatSize(m_pAviStream, 0, &lStreamSize);         if (lStreamSize > sizeof(m_bi)) // Format too large?             return;         lStreamSize = sizeof(m_bi);         hr = AVIStreamReadFormat(m_pAviStream, 0, &m_bi, &lStreamSize); // Read format         if (m_bi.biCompression != BI_RGB) // Wrong compression format?             return;         hr = AVIStreamInfo(m_pAviStream, &strhdr, sizeof(strhdr));         // Create new AVI file using AVIFileOpen.         hr = AVIFileOpen(&m_pf, strFilePath + L".Processed.avi", OF_WRITE | OF_CREATE, NULL);         if (hr != 0)             return;         m_currentSize = AVIStreamStart(m_pAviStream);        // Allocate memory for the bitmaps.         m_lpBuffer = (BYTE *)malloc(m_bi.biSizeImage);     }}
开发者ID:bryan610,项目名称:concrtextras,代码行数:42,


示例15: test_amh_corruption

static void test_amh_corruption(void){    COMMON_AVI_HEADERS cah;    char filename[MAX_PATH];    PAVIFILE pFile;    int res;    GetTempPath(MAX_PATH, filename);    strcpy(filename+strlen(filename), testfilename);    /* Make sure only AVI files with the proper headers will be loaded */    init_test_struct(&cah);    cah.fh[3] = mmioFOURCC('A', 'V', 'i', ' ');    create_avi_file(&cah, filename);    res = AVIFileOpen(&pFile, filename, OF_SHARE_DENY_WRITE, 0L);    ok(res != 0, "Able to open file: error=%u/n", res);    ok(DeleteFile(filename) !=0, "Deleting file %s failed/n", filename);}
开发者ID:austin987,项目名称:wine,代码行数:20,


示例16: AVIFileInit

BOOL FMPlayerDShow::GetAVIInfo(const tchar* pFileName){	AVIFileInit();	PAVIFILE pfile;	BOOL bOK = FALSE; 	if(AVIFileOpen(&pfile, pFileName, OF_SHARE_DENY_NONE, 0L) == 0)	{		AVIFILEINFO afi;		memset(&afi, 0, sizeof(afi));		AVIFileInfo(pfile, &afi, sizeof(AVIFILEINFO));		CComPtr<IAVIStream> pavi;		if(AVIFileGetStream(pfile, &pavi, streamtypeVIDEO, 0) == AVIERR_OK)		{			AVISTREAMINFO si;			AVIStreamInfo(pavi, &si, sizeof(si));			m_FourCC = FormatFourCC(si.fccHandler);			m_FrameRate = (double)si.dwRate / (double)si.dwScale; 			LONG lFormat; 			if (0 == AVIStreamFormatSize(pavi, 0, &lFormat))			{				char* pBuf = new char[lFormat];				if (0 == AVIStreamReadFormat(pavi, 0, pBuf, &lFormat))				{					BITMAPINFOHEADER* pHeader = (BITMAPINFOHEADER*)pBuf; 					m_StreamFormat = FormatFourCC(pHeader->biCompression);				}				delete[] pBuf; 			}			bOK = TRUE; 		}		AVIFileRelease(pfile);	}	AVIFileExit();	return bOK; }
开发者ID:codeboost,项目名称:libertv,代码行数:41,


示例17: close

bool CAviLoader::open( const char* filename ){    close();    icvInitCapture_VFW();    if( !filename )        return false;    HRESULT hr = AVIFileOpen( &avifile, filename, OF_READ, NULL );    if( SUCCEEDED(hr))    {        hr = AVIFileGetStream( avifile, &avistream, streamtypeVIDEO, 0 );        if( SUCCEEDED(hr))        {            hr = AVIStreamInfo( avistream, &aviinfo, sizeof(aviinfo));            if( SUCCEEDED(hr))            {                //int fcc = aviinfo.fccHandler;                data_offset = 0;                size.width = aviinfo.rcFrame.right - aviinfo.rcFrame.left;                size.height = aviinfo.rcFrame.bottom - aviinfo.rcFrame.top;                BITMAPINFOHEADER bmih = icvBitmapHeader( size.width, size.height, 24 );				if(frame)					delete []frame;				frame = new unsigned char[size.width*size.height*3];                                film_range.start_index = (int)aviinfo.dwStart;                film_range.end_index = film_range.start_index + (int)aviinfo.dwLength;                fps = (double)aviinfo.dwRate/aviinfo.dwScale;                pos = film_range.start_index;                getframe = AVIStreamGetFrameOpen( avistream, &bmih );                if( getframe != 0 )                    return true;            }        }    }    close();    return false;}
开发者ID:dlsyaim,项目名称:sm-eye-app,代码行数:41,


示例18: Close

bool CAviToBmp::Open(LPCTSTR Path){	Close();	if (FAILED(m_hr = AVIFileOpen(&m_pFile, Path, OF_READ, NULL)))		return(FALSE);	if (FAILED(m_hr = AVIFileGetStream(m_pFile, &m_pStream, streamtypeVIDEO, 0)))		return(FALSE);	m_FrameCount = AVIStreamLength(m_pStream);	long	Start = AVIStreamStart(m_pStream);	if (Start < 0)		return(FALSE);	long	FmtSize; 	if (FAILED(m_hr = AVIStreamReadFormat(m_pStream, Start, NULL, &FmtSize)))		return(FALSE);	m_pBmpInfo = (LPBITMAPINFO)new BYTE[FmtSize];	if (FAILED(m_hr = AVIStreamReadFormat(m_pStream, Start, m_pBmpInfo, &FmtSize)))		return(FALSE);	m_pGetFrame = AVIStreamGetFrameOpen(m_pStream, (LPBITMAPINFOHEADER)AVIGETFRAMEF_BESTDISPLAYFMT);	if (m_pGetFrame == NULL)		return(FALSE);	return(TRUE);}
开发者ID:fdiskcn,项目名称:Whorld,代码行数:22,


示例19: sprintf

 void AVIExporter::open() {    frameIdx = 0;    fileSize = 0;    // generate output file name depending on video file index    std::string fileName = outputFileName;    if (fileIdx++ > 0) {        char insertion[32];        sprintf(insertion, ".part%02d", fileIdx);        size_t dotLPos = fileName.rfind('.');        if (dotLPos != std::string::npos) {            fileName.insert(dotLPos, insertion);        } else {            fileName += insertion;        }    }    AVIFileInit();    HRESULT aviOpenResult = AVIFileOpen(&outputFile, fileName.c_str(), OF_WRITE | OF_CREATE, NULL);    if (aviOpenResult != AVIERR_OK) {        debugLog("Failed to open avi file: %s - %08x/n", fileName.c_str(), aviOpenResult);        close();        throw ExporterException(fileName);    }    if (!CreateVideoStream(frameRate, display.width, display.height, &outputFile, &videoStream)) {        debugLog("Failed to create video stream for avi file: %s/n", fileName.c_str());        close();        throw ExporterException(fileName);    }    if (!MakeCompressedVideoStream(display.width, display.height, &videoOptions, videoStream, &compressedVideoStream)) {        debugLog("Failed to create compressed video stream for avi file: %s/n", fileName.c_str());        close();        throw ExporterException(fileName);    }}
开发者ID:Rageous,项目名称:Core,代码行数:38,


示例20: HIWORD

HRESULT CAVIGenerator::InitEngine(){	AVISTREAMINFO strHdr; // information for a single stream 	static AVICOMPRESSOPTIONS opts;	static AVICOMPRESSOPTIONS FAR * aopts[1] = {&opts};	static bool first = true;	TCHAR szBuffer[1024];	HRESULT hr;	m_sError=_T("Ok");	// Step 0 : Let's make sure we are running on 1.1 	DWORD wVer = HIWORD(VideoForWindowsVersion());	if (wVer < 0x010a)	{		 // oops, we are too old, blow out of here 		m_sError=_T("Version of Video for Windows too old. Come on, join the 21th century!");		return S_FALSE;	}	// Step 1 : initialize AVI engine	AVIFileInit();	// Step 2 : Open the movie file for writing....	hr = AVIFileOpen(&m_pAVIFile,			// Address to contain the new file interface pointer		       (LPCSTR)m_sFile,				// Null-terminated string containing the name of the file to open		       OF_WRITE | OF_CREATE,	    // Access mode to use when opening the file. 		       NULL);						// use handler determined from file extension.											// Name your file .avi -> very important	if (hr != AVIERR_OK)	{//		sprintf(szBuffer,_T("AVI Engine failed to initialize. Check filename %s."),m_sFile);		m_sError=szBuffer;		// Check it succeded.		switch(hr)		{		case AVIERR_BADFORMAT: 			m_sError+=_T("The file couldn't be read, indicating a corrupt file or an unrecognized format.");			break;		case AVIERR_MEMORY:					m_sError+=_T("The file could not be opened because of insufficient memory."); 			break;		case AVIERR_FILEREAD:			m_sError+=_T("A disk error occurred while reading the file."); 			break;		case AVIERR_FILEOPEN:					m_sError+=_T("A disk error occurred while opening the file.");			break;		case REGDB_E_CLASSNOTREG:					m_sError+=_T("According to the registry, the type of file specified in AVIFileOpen does not have a handler to process it");			break;		}		return hr;	}	// Fill in the header for the video stream....	memset(&strHdr, 0, sizeof(strHdr));	strHdr.fccType                = streamtypeVIDEO;	// video stream type	strHdr.fccHandler             = 0;	strHdr.dwScale                = 1;					// should be one for video	strHdr.dwRate                 = m_dwRate;		    // fps	strHdr.dwSuggestedBufferSize  = m_bih.biSizeImage;	// Recommended buffer size, in bytes, for the stream.	SetRect(&strHdr.rcFrame, 0, 0,		    // rectangle for stream	    (int) m_bih.biWidth,	    (int) m_bih.biHeight);	// Step 3 : Create the stream;	hr = AVIFileCreateStream(m_pAVIFile,		    // file pointer			         &m_pStream,		    // returned stream pointer			         &strHdr);	    // stream header	// Check it succeded.	if (hr != AVIERR_OK)	{		m_sError=_T("AVI Stream creation failed. Check Bitmap info.");		if (hr==AVIERR_READONLY)		{			m_sError+=_T(" Read only file.");		}		return hr;	}//	if (first)	{		// Step 4: Get codec and infos about codec		memset(&opts, 0, sizeof(opts));		// Poping codec dialog		if (!AVISaveOptions(NULL, 0, 1, &m_pStream, (LPAVICOMPRESSOPTIONS FAR *) &aopts))		{			AVISaveOptionsFree(1,(LPAVICOMPRESSOPTIONS FAR *) &aopts);			return S_FALSE;		}//		first = false;	}		// Step 5:  Create a compressed stream using codec options.	hr = AVIMakeCompressedStream(&m_pStreamCompressed, //.........这里部分代码省略.........
开发者ID:bestdpf,项目名称:xface-error,代码行数:101,


示例21: avi_begin_encode

void *avi_begin_encode(const char *filename, int width, int height, int fps, const char *preferences_filename){#ifdef HAVE_VFW  avi_encode_context *context;  HRESULT hr;  BOOL ret;  AVISTREAMINFO strhdr;  BITMAPINFO bi;  AVICOMPRESSOPTIONS opts;  AVICOMPRESSOPTIONS * aopts[1];  int rowsize;  int imagesize;  int numbits;  int prefsReadFromFile;  if ( (width % 4 != 0) || (height % 4 != 0) )    return NULL; /* width and height must be divisible by 4 (several codecs crashes if this is not true) */  context = (avi_encode_context *) malloc(sizeof(avi_encode_context));  avi_init_context(context);  context->width = width;  context->height = height;  AVIFileInit();  /* Open file */  hr = AVIFileOpen(&context->pfile , filename, OF_WRITE | OF_CREATE, NULL);  if (hr != AVIERR_OK) {    avi_cleanup_context(context);    free(context);    return NULL;  }  /*    fixme 20020304 thammer: Investigate what happens if the file allready exists.    Preliminary tests indicate that the new stream is just added to the existing    file (increasing the file size), instead of truncating the file first, as the    documentation for AVIFileOpen states.  */  numbits = 24;  rowsize = (width * numbits + 31) / 32 * 4; /* aligned to 32 bits */  imagesize = rowsize * height;  memset(&strhdr, 0, sizeof(strhdr));  strhdr.fccType = streamtypeVIDEO;  strhdr.fccHandler = 0;  strhdr.dwScale = 1;  strhdr.dwRate = fps;  strhdr.dwSuggestedBufferSize = imagesize;  strhdr.rcFrame.left = 0;  strhdr.rcFrame.top = 0;  strhdr.rcFrame.right = width;  strhdr.rcFrame.bottom = height;  /* Create stream */  hr = AVIFileCreateStream(context->pfile, &context->ps, &strhdr);  if (hr != AVIERR_OK) {    avi_cleanup_context(context);    free(context);    return NULL;  }  aopts[0] = &opts;  memset(&opts, 0, sizeof(opts));  prefsReadFromFile = 0;  if ( (preferences_filename != NULL) && (strlen(preferences_filename)>0) ) {    FILE *file;    int size;    file = fopen(preferences_filename, "rb");    if (file==NULL) {      /* file doesn't exist, must pop up GUI to get options */      ret = AVISaveOptions(NULL, ICMF_CHOOSE_KEYFRAME | ICMF_CHOOSE_DATARATE, 1, &context->ps, (LPAVICOMPRESSOPTIONS *) &aopts);      if (!ret) {        /* User pressed [Cancel] */        avi_cleanup_context(context);        free(context);        return NULL;      }      /* Save options to file*/      file = fopen(preferences_filename, "wb");      if (file == NULL) {        avi_cleanup_context(context);        free(context);        return NULL;      }      /* write AVICOMPRESSOPTIONS struct */      size = fwrite(&opts, sizeof(AVICOMPRESSOPTIONS), 1, file);      /* write AVICOMPRESSOPTIONS.cbFormat */      size = fwrite(&opts.cbFormat, 4, 1, file);      /* write AVICOMPRESSOPTIONS.lpFormat */      size = fwrite(opts.lpFormat, opts.cbFormat, 1, file);      /* write AVICOMPRESSOPTIONS.cbParms *///.........这里部分代码省略.........
开发者ID:Alexpux,项目名称:simage,代码行数:101,


示例22: avisynth_read_header

static int avisynth_read_header(AVFormatContext *s, AVFormatParameters *ap){  AVISynthContext *avs = s->priv_data;  HRESULT res;  AVIFILEINFO info;  DWORD id;  AVStream *st;  AVISynthStream *stream;  AVIFileInit();  res = AVIFileOpen(&avs->file, s->filename, OF_READ|OF_SHARE_DENY_WRITE, NULL);  if (res != S_OK)    {      av_log(s, AV_LOG_ERROR, "AVIFileOpen failed with error %ld", res);      AVIFileExit();      return -1;    }  res = AVIFileInfo(avs->file, &info, sizeof(info));  if (res != S_OK)    {      av_log(s, AV_LOG_ERROR, "AVIFileInfo failed with error %ld", res);      AVIFileExit();      return -1;    }  avs->streams = av_mallocz(info.dwStreams * sizeof(AVISynthStream));  for (id=0; id<info.dwStreams; id++)    {      stream = &avs->streams[id];      stream->read = 0;      if (AVIFileGetStream(avs->file, &stream->handle, 0, id) == S_OK)        {          if (AVIStreamInfo(stream->handle, &stream->info, sizeof(stream->info)) == S_OK)            {              if (stream->info.fccType == streamtypeAUDIO)                {                  WAVEFORMATEX wvfmt;                  LONG struct_size = sizeof(WAVEFORMATEX);                  if (AVIStreamReadFormat(stream->handle, 0, &wvfmt, &struct_size) != S_OK)                    continue;                  st = av_new_stream(s, id);                  st->codec->codec_type = CODEC_TYPE_AUDIO;                  st->codec->block_align = wvfmt.nBlockAlign;                  st->codec->channels = wvfmt.nChannels;                  st->codec->sample_rate = wvfmt.nSamplesPerSec;                  st->codec->bit_rate = wvfmt.nAvgBytesPerSec * 8;                  st->codec->bits_per_sample = wvfmt.wBitsPerSample;                  stream->chunck_samples = wvfmt.nSamplesPerSec * (uint64_t)info.dwScale / (uint64_t)info.dwRate;                  stream->chunck_size = stream->chunck_samples * wvfmt.nChannels * wvfmt.wBitsPerSample / 8;                  st->codec->codec_tag = wvfmt.wFormatTag;                  st->codec->codec_id = wav_codec_get_id(wvfmt.wFormatTag, st->codec->bits_per_sample);                }              else if (stream->info.fccType == streamtypeVIDEO)                {                  BITMAPINFO imgfmt;                  LONG struct_size = sizeof(BITMAPINFO);                  stream->chunck_size = stream->info.dwSampleSize;                  stream->chunck_samples = 1;                  if (AVIStreamReadFormat(stream->handle, 0, &imgfmt, &struct_size) != S_OK)                    continue;                  st = av_new_stream(s, id);                  st->codec->codec_type = CODEC_TYPE_VIDEO;                  st->r_frame_rate.num = stream->info.dwRate;                  st->r_frame_rate.den = stream->info.dwScale;                  st->codec->width = imgfmt.bmiHeader.biWidth;                  st->codec->height = imgfmt.bmiHeader.biHeight;                  st->codec->bits_per_sample = imgfmt.bmiHeader.biBitCount;                  st->codec->bit_rate = (uint64_t)stream->info.dwSampleSize * (uint64_t)stream->info.dwRate * 8 / (uint64_t)stream->info.dwScale;                  st->codec->codec_tag = imgfmt.bmiHeader.biCompression;                  st->codec->codec_id = codec_get_id(codec_bmp_tags, imgfmt.bmiHeader.biCompression);                  st->duration = stream->info.dwLength;                }              else                {                  AVIStreamRelease(stream->handle);                  continue;                }              avs->nb_streams++;              st->codec->stream_codec_tag = stream->info.fccHandler;              av_set_pts_info(st, 64, info.dwScale, info.dwRate);              st->start_time = stream->info.dwStart;            }        }    }//.........这里部分代码省略.........
开发者ID:AnthonyNystrom,项目名称:MobiVU,代码行数:101,


示例23: avi_open

static int avi_open(const char* filename, const BITMAPINFOHEADER* pbmih, const WAVEFORMATEX* pwfex, const struct VideoSystemInfo* vsi){	int error = 1;	int result = 0;	do	{		// close existing first		FCEUI_AviEnd();		if(!truncate_existing(filename))			break;		if(!pbmih)			break;		// create the object		avi_create(&avi_file);		// set video size and framerate		avi_file->start_scanline = vsi->start_scanline;		avi_file->end_scanline = vsi->end_scanline;		//zero 20-oct-2012 - AVIFileClose has bugs in it which cause overflows in the calculation of dwTotalFrames, so some programs are unhappy with the resulting files.		//so I reduced the precision here by the minimum number of shifts necessary to make it not overflow		avi_file->fps = vsi->fps >> 3;		avi_file->fps_scale = (16 * 1024 * 1024) >> 3;		avi_file->convert_buffer = (uint8*)malloc(VIDEO_WIDTH*(vsi->end_scanline-vsi->start_scanline)*3);		// open the file		if(FAILED(AVIFileOpen(&avi_file->avi_file, filename, OF_CREATE | OF_WRITE, NULL)))			break;		// create the video stream		set_video_format(pbmih, avi_file);		memset(&avi_file->avi_video_header, 0, sizeof(AVISTREAMINFO));		avi_file->avi_video_header.fccType = streamtypeVIDEO;		avi_file->avi_video_header.dwScale = avi_file->fps_scale;		avi_file->avi_video_header.dwRate = avi_file->fps;		avi_file->avi_video_header.dwSuggestedBufferSize = avi_file->bitmap_format.biSizeImage;		if(FAILED(AVIFileCreateStream(avi_file->avi_file, &avi_file->streams[VIDEO_STREAM], &avi_file->avi_video_header)))			break;		if(use_prev_options)		{			avi_file->compress_options[VIDEO_STREAM] = saved_avi_info.compress_options[VIDEO_STREAM];			avi_file->compress_options_ptr[VIDEO_STREAM] = &avi_file->compress_options[0];		}		else		{			// get compression options			memset(&avi_file->compress_options[VIDEO_STREAM], 0, sizeof(AVICOMPRESSOPTIONS));			avi_file->compress_options_ptr[VIDEO_STREAM] = &avi_file->compress_options[0];//retryAviSaveOptions: //mbg merge 7/17/06 removed			error = 0;			if(!AVISaveOptions(hAppWnd, 0, 1, &avi_file->streams[VIDEO_STREAM], &avi_file->compress_options_ptr[VIDEO_STREAM]))				break;			error = 1;		}		// create compressed stream		if(FAILED(AVIMakeCompressedStream(&avi_file->compressed_streams[VIDEO_STREAM], avi_file->streams[VIDEO_STREAM], &avi_file->compress_options[VIDEO_STREAM], NULL)))			break;		// set the stream format		if(FAILED(AVIStreamSetFormat(avi_file->compressed_streams[VIDEO_STREAM], 0, (void*)&avi_file->bitmap_format, avi_file->bitmap_format.biSize)))			break;		// add sound (if requested)		if(pwfex)		{			// add audio format			set_sound_format(pwfex, avi_file);			// create the audio stream			memset(&avi_file->avi_sound_header, 0, sizeof(AVISTREAMINFO));			avi_file->avi_sound_header.fccType = streamtypeAUDIO;			avi_file->avi_sound_header.dwQuality = (DWORD)-1;			avi_file->avi_sound_header.dwScale = avi_file->wave_format.nBlockAlign;			avi_file->avi_sound_header.dwRate = avi_file->wave_format.nAvgBytesPerSec;			avi_file->avi_sound_header.dwSampleSize = avi_file->wave_format.nBlockAlign;			avi_file->avi_sound_header.dwInitialFrames = 1;			if(FAILED(AVIFileCreateStream(avi_file->avi_file, &avi_file->streams[AUDIO_STREAM], &avi_file->avi_sound_header)))				break;			// AVISaveOptions doesn't seem to work for audio streams			// so here we just copy the pointer for the compressed stream			avi_file->compressed_streams[AUDIO_STREAM] = avi_file->streams[AUDIO_STREAM];			// set the stream format			if(FAILED(AVIStreamSetFormat(avi_file->compressed_streams[AUDIO_STREAM], 0, (void*)&avi_file->wave_format, sizeof(WAVEFORMATEX))))				break;		}		// initialize counters		avi_file->video_frames = 0;		avi_file->sound_samples = 0;		avi_file->tBytes = 0;		avi_file->ByteBuffer = 0;		avi_file->audio_buffer_pos = 0;//.........这里部分代码省略.........
开发者ID:Plombo,项目名称:fceux,代码行数:101,


示例24: avisynth_read_header

int avisynth_read_header() {    avs = (AVISynthContext *) av_mallocz(sizeof(AVISynthContext));    HRESULT res;    AVIFILEINFO info;    DWORD id;    AVIFileInit();    res = AVIFileOpen(&avs->file, read_config_filepath(), OF_READ|OF_SHARE_DENY_WRITE, NULL);    if (res != S_OK)    {        av_log(s, AV_LOG_ERROR, "AVIFileOpen failed with error %ld", res);        AVIFileExit();        return -1;    }    res = AVIFileInfo(avs->file, &info, sizeof(info));    if (res != S_OK)    {        av_log(s, AV_LOG_ERROR, "AVIFileInfo failed with error %ld", res);        AVIFileExit();        return -1;    }    avs->streams = (AVISynthStream *) av_mallocz(info.dwStreams * sizeof(AVISynthStream));    assert(info.dwStreams == 1);    for (id=0; id<info.dwStreams; id++)    {        stream = &avs->streams[id];        stream->read = 0;        if (AVIFileGetStream(avs->file, &stream->handle, 0, id) == S_OK)        {            if (AVIStreamInfo(stream->handle, &stream->info, sizeof(stream->info)) == S_OK)            {                if (stream->info.fccType == streamtypeAUDIO)                {                    assert(false); // don't do audio yet                    LONG struct_size = sizeof(WAVEFORMATEX);                    if (AVIStreamReadFormat(stream->handle, 0, &wvfmt, &struct_size) != S_OK)                        continue;                    /* audio:                    st = avformat_new_stream(s, NULL);                    st->id = id;                    st->codec->codec_type = AVMEDIA_TYPE_AUDIO;                    st->codec->block_align = wvfmt.nBlockAlign;                    st->codec->channels = wvfmt.nChannels;                    st->codec->sample_rate = wvfmt.nSamplesPerSec;                    st->codec->bit_rate = wvfmt.nAvgBytesPerSec * 8;                    st->codec->bits_per_coded_sample = wvfmt.wBitsPerSample;                    st->codec->codec_tag = wvfmt.wFormatTag;                    st->codec->codec_id = ff_wav_codec_get_id(wvfmt.wFormatTag, st->codec->bits_per_coded_sample);                    */                    stream->chunck_samples = wvfmt.nSamplesPerSec * (__int64)info.dwScale / (__int64) info.dwRate;                    stream->chunck_size = stream->chunck_samples * wvfmt.nChannels * wvfmt.wBitsPerSample / 8;                }                else if (stream->info.fccType == streamtypeVIDEO)                {                    LONG struct_size = sizeof(BITMAPINFO);                    stream->chunck_size = stream->info.dwSampleSize;                    stream->chunck_samples = 1;                    if (AVIStreamReadFormat(stream->handle, 0, &savedVideoFormat, &struct_size) != S_OK)                        continue;                    /*                    stream->info.dwRate is numerator                    stream->info.dwScale is denominator [?]                    savedVideoFormat.bmiHeader.biWidth                    */                    /*st = avformat_new_stream(s, NULL);                    st->id = id;                    st->codec->codec_type = AVMEDIA_TYPE_VIDEO;                    st->r_frame_rate.num = stream->info.dwRate;                    st->r_frame_rate.den = stream->info.dwScale;                    st->codec->width = savedVideoFormat.bmiHeader.biWidth;                    st->codec->height = savedVideoFormat.bmiHeader.biHeight;                    st->codec->bits_per_coded_sample = savedVideoFormat.bmiHeader.biBitCount;                    st->codec->bit_rate = (uint64_t)stream->info.dwSampleSize * (uint64_t)stream->info.dwRate * 8 / (uint64_t)stream->info.dwScale;                    st->codec->codec_tag = savedVideoFormat.bmiHeader.biCompression;                    st->codec->codec_id = ff_codec_get_id(ff_codec_bmp_tags, savedVideoFormat.bmiHeader.biCompression);                    if (st->codec->codec_id == CODEC_ID_RAWVIDEO && savedVideoFormat.bmiHeader.biCompression== BI_RGB) {                      st->codec->extradata = av_malloc(9 + FF_INPUT_BUFFER_PADDING_SIZE);                      if (st->codec->extradata) {                        st->codec->extradata_size = 9;                        memcpy(st->codec->extradata, "BottomUp", 9);                      }                    }//.........这里部分代码省略.........
开发者ID:rdp-org,项目名称:avisynth-as-directshow-capture,代码行数:101,


示例25: test_default_data

static void test_default_data(void){    COMMON_AVI_HEADERS cah;    char filename[MAX_PATH];    PAVIFILE pFile;    int res;    LONG lSize;    PAVISTREAM pStream0;    PAVISTREAM pStream1;    AVISTREAMINFO asi0;    AVISTREAMINFO asi1;    WAVEFORMATEX wfx;    GetTempPath(MAX_PATH, filename);    strcpy(filename+strlen(filename), testfilename);    init_test_struct(&cah);    create_avi_file(&cah, filename);    res = AVIFileOpen(&pFile, filename, OF_SHARE_DENY_WRITE, 0L);    ok(res != AVIERR_BADFORMAT, "Unable to open file: error1=%u/n", AVIERR_BADFORMAT);    ok(res != AVIERR_MEMORY, "Unable to open file: error2=%u/n", AVIERR_MEMORY);    ok(res != AVIERR_FILEREAD, "Unable to open file: error3=%u/n", AVIERR_FILEREAD);    ok(res != AVIERR_FILEOPEN, "Unable to open file: error4=%u/n", AVIERR_FILEOPEN);    ok(res != REGDB_E_CLASSNOTREG, "Unable to open file: error5=%u/n", REGDB_E_CLASSNOTREG);    ok(res == 0, "Unable to open file: error=%u/n", res);    res = AVIFileGetStream(pFile, &pStream0, 0, 0);    ok(res == 0, "Unable to open video stream: error=%u/n", res);    res = AVIFileGetStream(pFile, &pStream1, 0, 1);    ok(res == 0, "Unable to open audio stream: error=%u/n", res);    res = AVIStreamInfo(pStream0, &asi0, sizeof(AVISTREAMINFO));    ok(res == 0, "Unable to read stream info: error=%u/n", res);    res = AVIStreamInfo(pStream1, &asi1, sizeof(AVISTREAMINFO));    ok(res == 0, "Unable to read stream info: error=%u/n", res);    res = AVIStreamReadFormat(pStream0, AVIStreamStart(pStream1), NULL, &lSize);    ok(res == 0, "Unable to read format size: error=%u/n", res);    res = AVIStreamReadFormat(pStream1, AVIStreamStart(pStream1), &wfx, &lSize);    ok(res == 0, "Unable to read format: error=%u/n", res);    ok(asi0.fccType == streamtypeVIDEO, "got 0x%x (expected streamtypeVIDEO)/n", asi0.fccType);    ok(asi0.fccHandler == 0x30323449, "got 0x%x (expected 0x30323449)/n", asi0.fccHandler);    ok(asi0.dwFlags == 0, "got %u (expected 0)/n", asi0.dwFlags);    ok(asi0.wPriority == 0, "got %u (expected 0)/n", asi0.wPriority);    ok(asi0.wLanguage == 0, "got %u (expected 0)/n", asi0.wLanguage);    ok(asi0.dwScale == 1001, "got %u (expected 1001)/n", asi0.dwScale);    ok(asi0.dwRate == 30000, "got %u (expected 30000)/n", asi0.dwRate);    ok(asi0.dwStart == 0, "got %u (expected 0)/n", asi0.dwStart);    ok(asi0.dwLength == 1, "got %u (expected 1)/n", asi0.dwLength);    ok(asi0.dwInitialFrames == 0, "got %u (expected 0)/n", asi0.dwInitialFrames);    ok(asi0.dwSuggestedBufferSize == 0, "got %u (expected 0)/n", asi0.dwSuggestedBufferSize);    ok(asi0.dwQuality == 0xffffffff, "got 0x%x (expected 0xffffffff)/n", asi0.dwQuality);    ok(asi0.dwSampleSize == 0, "got %u (expected 0)/n", asi0.dwSampleSize);    ok(asi0.rcFrame.left == 0, "got %u (expected 0)/n", asi0.rcFrame.left);    ok(asi0.rcFrame.top == 0, "got %u (expected 0)/n", asi0.rcFrame.top);    ok(asi0.rcFrame.right == 8, "got %u (expected 8)/n", asi0.rcFrame.right);  /* these are based on the values in the mah and not */    ok(asi0.rcFrame.bottom == 6, "got %u (expected 6)/n", asi0.rcFrame.bottom);/* on the ones in the ash which are 0 here */    ok(asi0.dwEditCount == 0, "got %u (expected 0)/n", asi0.dwEditCount);    ok(asi0.dwFormatChangeCount == 0, "got %u (expected 0)/n", asi0.dwFormatChangeCount);    ok(asi1.fccType == streamtypeAUDIO, "got 0x%x (expected streamtypeVIDEO)/n", asi1.fccType);    ok(asi1.fccHandler == 0x1, "got 0x%x (expected 0x1)/n", asi1.fccHandler);    ok(asi1.dwFlags == 0, "got %u (expected 0)/n", asi1.dwFlags);    ok(asi1.wPriority == 0, "got %u (expected 0)/n", asi1.wPriority);    ok(asi1.wLanguage == 0, "got %u (expected 0)/n", asi1.wLanguage);    ok(asi1.dwScale == 1, "got %u (expected 1)/n", asi1.dwScale);    ok(asi1.dwRate == 11025, "got %u (expected 11025)/n", asi1.dwRate);    ok(asi1.dwStart == 0, "got %u (expected 0)/n", asi1.dwStart);    ok(asi1.dwLength == 1637, "got %u (expected 1637)/n", asi1.dwLength);    ok(asi1.dwInitialFrames == 0, "got %u (expected 0)/n", asi1.dwInitialFrames);    ok(asi1.dwSuggestedBufferSize == 0, "got %u (expected 0)/n", asi1.dwSuggestedBufferSize);    ok(asi1.dwQuality == 0xffffffff, "got 0x%x (expected 0xffffffff)/n", asi1.dwQuality);    ok(asi1.dwSampleSize == 2, "got %u (expected 2)/n", asi1.dwSampleSize);    ok(asi1.rcFrame.left == 0, "got %u (expected 0)/n", asi1.rcFrame.left);    ok(asi1.rcFrame.top == 0, "got %u (expected 0)/n", asi1.rcFrame.top);    ok(asi1.rcFrame.right == 0, "got %u (expected 0)/n", asi1.rcFrame.right);    ok(asi1.rcFrame.bottom == 0, "got %u (expected 0)/n", asi1.rcFrame.bottom);    ok(asi1.dwEditCount == 0, "got %u (expected 0)/n", asi1.dwEditCount);    ok(asi1.dwFormatChangeCount == 0, "got %u (expected 0)/n", asi1.dwFormatChangeCount);    ok(wfx.wFormatTag == 1, "got %u (expected 1)/n",wfx.wFormatTag);    ok(wfx.nChannels == 2, "got %u (expected 2)/n",wfx.nChannels);    ok(wfx.wFormatTag == 1, "got %u (expected 1)/n",wfx.wFormatTag);    ok(wfx.nSamplesPerSec == 11025, "got %u (expected 11025)/n",wfx.nSamplesPerSec);    ok(wfx.nAvgBytesPerSec == 22050, "got %u (expected 22050)/n",wfx.nAvgBytesPerSec);    ok(wfx.nBlockAlign == 2, "got %u (expected 2)/n",wfx.nBlockAlign);    AVIStreamRelease(pStream0);    AVIStreamRelease(pStream1);    AVIFileRelease(pFile);    ok(DeleteFile(filename) !=0, "Deleting file %s failed/n", filename);}
开发者ID:austin987,项目名称:wine,代码行数:97,


示例26: load_avi_file

  int load_avi_file()  {    bitm.valid=false;    const char *avifilename = filename->get().c_str();    HRESULT res = AVIFileOpen(&m_aviFile, avifilename, OF_READ, NULL);    if (res!=AVIERR_OK)    {      printf("Couldn't open avi file %s/n",filename->get().c_str());      return 0;    }    res = AVIFileGetStream(m_aviFile, &streamVid, streamtypeVIDEO, 0);    if (res!=AVIERR_OK)    {      AVIFileRelease(m_aviFile);      m_aviFile = NULL;      streamVid = NULL;      printf("Couldn't get stream");      return 0;    }    LONG format_length = 0;    AVIStreamReadFormat(streamVid,0,NULL,&format_length);    //if format_data is not a reasonable size, fail    if (format_length>128)    {      printf("Format data too big");      return 0;    }    //make room for at least 128 bytes, sizeof(int) aligned    int format_data[(128/sizeof(int)) + 1];    AVIStreamReadFormat(streamVid,0,format_data,&format_length);            BITMAPINFOHEADER *bi = (BITMAPINFOHEADER *)format_data;    //only 24 bit output is supported    if (bi->biBitCount!=24)    {      printf("Bitcount %d not supported",bi->biBitCount);      return 0;    }        // Create the PGETFRAME    getFrame = AVIStreamGetFrameOpen(streamVid,NULL);	    //unable to decode the .avi?    if (getFrame==NULL)    {      printf("AVIStreamGetFrameOpen returned NULL");      return 0;    }            // Define the length of the video (necessary for loop reading)		// and its size.		num_frames = AVIStreamLength(streamVid);          if (num_frames<1)    {      printf("Zero frames");      return 0;    }        AVISTREAMINFO psi;    AVIStreamInfo(streamVid, &psi, sizeof(AVISTREAMINFO));    width  = psi.rcFrame.right - psi.rcFrame.left;		height = psi.rcFrame.bottom - psi.rcFrame.top;    dwRate = psi.dwRate;    dwScale = psi.dwScale;    bitm.bpp=(int)(bi->biBitCount/8);    bitm.bformat=GL_BGR;    bitm.size_x=width;    bitm.size_y=height;    bitm.valid=true;    return 1;  }
开发者ID:ChunhuiWu,项目名称:vsxu,代码行数:82,


示例27: avi_open

static int avi_open(const char* filename, const BITMAPINFOHEADER* pbmih, const WAVEFORMATEX* pwfex){	int error = 1;	int result = 0;	do	{		// close existing first		DRV_AviEnd();		if(!truncate_existing(filename))			break;		if(!pbmih)			break;		// create the object		avi_create(&avi_file);		// set video size and framerate		/*avi_file->start_scanline = vsi->start_scanline;		avi_file->end_scanline = vsi->end_scanline;		avi_file->fps = vsi->fps;		avi_file->fps_scale = 16777216-1;		avi_file->convert_buffer = new u8[256*384*3];*/		// open the file		if(FAILED(AVIFileOpen(&avi_file->avi_file, filename, OF_CREATE | OF_WRITE, NULL)))			break;		// create the video stream		set_video_format(pbmih, avi_file);		memset(&avi_file->avi_video_header, 0, sizeof(AVISTREAMINFO));		avi_file->avi_video_header.fccType = streamtypeVIDEO;		avi_file->avi_video_header.dwScale = 6*355*263;		avi_file->avi_video_header.dwRate = 33513982;		avi_file->avi_video_header.dwSuggestedBufferSize = avi_file->bitmap_format.biSizeImage;		if(FAILED(AVIFileCreateStream(avi_file->avi_file, &avi_file->streams[VIDEO_STREAM], &avi_file->avi_video_header)))			break;		if(use_prev_options)		{			avi_file->compress_options[VIDEO_STREAM] = saved_avi_info.compress_options[VIDEO_STREAM];			avi_file->compress_options_ptr[VIDEO_STREAM] = &avi_file->compress_options[0];		}		else		{			// get compression options			memset(&avi_file->compress_options[VIDEO_STREAM], 0, sizeof(AVICOMPRESSOPTIONS));			avi_file->compress_options_ptr[VIDEO_STREAM] = &avi_file->compress_options[0];//retryAviSaveOptions: //mbg merge 7/17/06 removed			error = 0;			if(!AVISaveOptions(MainWindow->getHWnd(), 0, 1, &avi_file->streams[VIDEO_STREAM], &avi_file->compress_options_ptr[VIDEO_STREAM]))				break;			error = 1;		}		// create compressed stream		if(FAILED(AVIMakeCompressedStream(&avi_file->compressed_streams[VIDEO_STREAM], avi_file->streams[VIDEO_STREAM], &avi_file->compress_options[VIDEO_STREAM], NULL)))			break;		// set the stream format		if(FAILED(AVIStreamSetFormat(avi_file->compressed_streams[VIDEO_STREAM], 0, (void*)&avi_file->bitmap_format, avi_file->bitmap_format.biSize)))			break;		// add sound (if requested)		if(pwfex)		{			// add audio format			set_sound_format(pwfex, avi_file);			// create the audio stream			memset(&avi_file->avi_sound_header, 0, sizeof(AVISTREAMINFO));			avi_file->avi_sound_header.fccType = streamtypeAUDIO;			avi_file->avi_sound_header.dwQuality = (DWORD)-1;			avi_file->avi_sound_header.dwScale = avi_file->wave_format.nBlockAlign;			avi_file->avi_sound_header.dwRate = avi_file->wave_format.nAvgBytesPerSec;			avi_file->avi_sound_header.dwSampleSize = avi_file->wave_format.nBlockAlign;			avi_file->avi_sound_header.dwInitialFrames = 1;			if(FAILED(AVIFileCreateStream(avi_file->avi_file, &avi_file->streams[AUDIO_STREAM], &avi_file->avi_sound_header)))				break;			// AVISaveOptions doesn't seem to work for audio streams			// so here we just copy the pointer for the compressed stream			avi_file->compressed_streams[AUDIO_STREAM] = avi_file->streams[AUDIO_STREAM];			// set the stream format			if(FAILED(AVIStreamSetFormat(avi_file->compressed_streams[AUDIO_STREAM], 0, (void*)&avi_file->wave_format, sizeof(WAVEFORMATEX))))				break;		}		// initialize counters		avi_file->video_frames = 0;		avi_file->sound_samples = 0;		avi_file->tBytes = 0;		avi_file->ByteBuffer = 0;		avi_file->audio_buffer_pos = 0;		// success//.........这里部分代码省略.........
开发者ID:snowasnow,项目名称:DeSmuME,代码行数:101,


示例28: CreateCompatibleDC

HRESULT CAviFile::InitMovieCreation(int nFrameWidth, int nFrameHeight, int nBitsPerPixel){	int	nMaxWidth=GetSystemMetrics(SM_CXSCREEN),nMaxHeight=GetSystemMetrics(SM_CYSCREEN);	m_hAviDC = CreateCompatibleDC(NULL);	if(m_hAviDC==NULL)	{		SetErrorMessage("Unable to Create Compatible DC");		m_LastError = E_FAIL;		return E_FAIL;	}	if(nFrameWidth > nMaxWidth)	nMaxWidth= nFrameWidth;	if(nFrameHeight > nMaxHeight)	nMaxHeight = nFrameHeight;	m_hHeap=HeapCreate(HEAP_NO_SERIALIZE, nMaxWidth*nMaxHeight*4, 0);	if(m_hHeap==NULL)	{		SetErrorMessage("Unable to Create Heap");		m_LastError = E_FAIL;		return E_FAIL;	}	m_lpBits=HeapAlloc(m_hHeap, HEAP_ZERO_MEMORY|HEAP_NO_SERIALIZE, nMaxWidth*nMaxHeight*4);	if(m_lpBits==NULL)	{		SetErrorMessage("Unable to Allocate Memory on Heap");		m_LastError = E_FAIL;		return E_FAIL;	}	// Make sure that the file doesn't exist before acting on it.	_unlink( m_szFileName );	DWORD Result = AVIFileOpen( &m_pAviFile, m_szFileName, OF_CREATE|OF_WRITE, NULL );	if( FAILED( Result ) )	{		SetErrorMessage("Unable to Create the Movie File");		m_LastError = E_FAIL;		return E_FAIL;	}	ZeroMemory(&m_AviStreamInfo,sizeof(AVISTREAMINFO));	m_AviStreamInfo.fccType		= streamtypeVIDEO;	m_AviStreamInfo.fccHandler	= m_dwFCCHandler;	m_AviStreamInfo.dwScale		= 1;	m_AviStreamInfo.dwRate		= m_dwFrameRate;	// Frames Per Second;	m_AviStreamInfo.dwQuality	= -1;				// Default Quality	m_AviStreamInfo.dwSuggestedBufferSize = nMaxWidth*nMaxHeight*4;    SetRect(&m_AviStreamInfo.rcFrame, 0, 0, nFrameWidth, nFrameHeight);	strcpy_s( m_AviStreamInfo.szName, sizeof( m_AviStreamInfo.szName ), _T("Video Stream"));	if(FAILED(AVIFileCreateStream(m_pAviFile,&m_pAviStream,&m_AviStreamInfo)))	{		SetErrorMessage("Unable to Create Video Stream in the Movie File");		m_LastError = E_FAIL;		return E_FAIL;	}	ZeroMemory(&m_AviCompressOptions,sizeof(AVICOMPRESSOPTIONS));	m_AviCompressOptions.fccType=streamtypeVIDEO;	m_AviCompressOptions.fccHandler=m_AviStreamInfo.fccHandler;	m_AviCompressOptions.dwFlags=AVICOMPRESSF_VALID;	// m_AviCompressOptions.dwKeyFrameEvery=100;	// m_AviCompressOptions.dwBytesPerSecond=1000; this is ignored for xvid recording	// m_AviCompressOptions.dwQuality=500; this is ignored for xvid recording	HRESULT hResult = AVIMakeCompressedStream( &m_pAviCompressedStream, m_pAviStream, &m_AviCompressOptions, NULL);	if(FAILED(hResult))	{		// One reason this error might occur is if you are using a Codec that is not		// available on your system. Check the mmioFOURCC() code you are using and make		// sure you have that codec installed properly on your machine.		SetErrorMessage("Unable to Create Compressed Stream: Check your CODEC options");		m_LastError = E_FAIL;		return E_FAIL;	}	BITMAPINFO bmpInfo;	ZeroMemory(&bmpInfo,sizeof(BITMAPINFO));	bmpInfo.bmiHeader.biPlanes		= 1;	bmpInfo.bmiHeader.biWidth		= nFrameWidth;	bmpInfo.bmiHeader.biHeight		= nFrameHeight;	bmpInfo.bmiHeader.biCompression	= BI_RGB;	bmpInfo.bmiHeader.biBitCount	= nBitsPerPixel;	bmpInfo.bmiHeader.biSize		= sizeof(BITMAPINFOHEADER);	int LineByteWidth = ( ( bmpInfo.bmiHeader.biWidth * 3 ) + 3 )  & ~3;	bmpInfo.bmiHeader.biSizeImage	= LineByteWidth*bmpInfo.bmiHeader.biHeight;	if(FAILED(AVIStreamSetFormat(m_pAviCompressedStream,0,(LPVOID)&bmpInfo, bmpInfo.bmiHeader.biSize)))	{		// One reason this error might occur is if your bitmap does not meet the Codec requirements.		// For example,		//   your bitmap is 32bpp while the Codec supports only 16 or 24 bpp; Or		//   your bitmap is 274 * 258 size, while the Codec supports only sizes that are powers of 2; etc...		// Possible solution to avoid this is: make your bitmap suit the codec requirements,		// or Choose a codec that is suitable for your bitmap.		SetErrorMessage("Unable to Set Video Stream Format");		m_LastError = E_FAIL;//.........这里部分代码省略.........
开发者ID:stainlessio,项目名称:Linkage,代码行数:101,



注:本文中的AVIFileOpen函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ AVIFileRelease函数代码示例
C++ AVIFileExit函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。