Exemplo n.º 1
0
void CAviFile::ReleaseMemory()
{
	m_nAppendFuncSelector=0;		//Point to DummyFunction

	if(m_hAviDC)
	{
		DeleteDC(m_hAviDC);
		m_hAviDC=NULL;
	}
	if(m_pAviCompressedStream)
	{
		AVIStreamRelease(m_pAviCompressedStream);
		m_pAviCompressedStream=NULL;
	}
	if(m_pAviStream)
	{
		AVIStreamRelease(m_pAviStream);
		m_pAviStream=NULL;
	}
	if(m_pAviFile)
	{
		AVIFileRelease(m_pAviFile);
		m_pAviFile=NULL;
	}
	if(m_lpBits)
	{
		HeapFree(m_hHeap,HEAP_NO_SERIALIZE,m_lpBits);
		m_lpBits=NULL;
	}
	if(m_hHeap)
	{
		HeapDestroy(m_hHeap);
		m_hHeap=NULL;
	}
}
Exemplo n.º 2
0
static void free_anim_avi(struct anim *anim)
{
#if defined(_WIN32) && !defined(FREE_WINDOWS)
	int i;
#endif

	if (anim == NULL) return;
	if (anim->avi == NULL) return;

	AVI_close(anim->avi);
	MEM_freeN(anim->avi);
	anim->avi = NULL;

#if defined(_WIN32) && !defined(FREE_WINDOWS)

	if (anim->pgf) {
		AVIStreamGetFrameClose(anim->pgf);
		anim->pgf = NULL;
	}

	for (i = 0; i < anim->avistreams; i++) {
		AVIStreamRelease(anim->pavi[i]);
	}
	anim->avistreams = 0;

	if (anim->pfileopen) {
		AVIFileRelease(anim->pfile);
		anim->pfileopen = 0;
		AVIFileExit();
	}
#endif

	anim->duration = 0;
}
bool NxVideo_Avi_Recorder::CloseVideoFile()
{

	if (mVideo->m_pStream)
	{
		AVIStreamRelease(mVideo->m_pStream);
		mVideo->m_pStream=NULL;
	}

	if (mVideo->m_pStreamCompressed)
	{
		AVIStreamRelease(mVideo->m_pStreamCompressed);
		mVideo->m_pStreamCompressed=NULL;
	}

	if (mVideo->m_pAVIFile)
	{
		AVIFileRelease(mVideo->m_pAVIFile);
		mVideo->m_pAVIFile=NULL;
	}

	// Close engine
	AVIFileExit();
	return true;
}
Exemplo n.º 4
0
void CMainFrame::OnClose()
{
	// TODO: 在此添加消息处理程序代码和/或调用默认值
	capCaptureAbort(m_hWndCap);
	capDriverDisconnect(m_hWndCap);
	Sleep(100);
	capSetCallbackOnError(m_hWndCap,NULL);
	capSetCallbackOnStatus(m_hWndCap,NULL);
	capSetCallbackOnVideoStream(m_hWndCap,NULL);
	delete lpbiIn;
	delete lpbiTmp;
	delete lpbiOut;
	if (m_vfwState==ENCDEC){
		ICDecompressEnd(hic2);
		ICClose(hic2);
		ICSeqCompressFrameEnd(&pc);
		ICCompressEnd(hic1);
		ICClose(hic1);
		AVIStreamClose(ps);
		if(m_pFile != NULL)
			AVIFileRelease(m_pFile);
	}

	enc_stop();
	dec_stop();

	Sleep(100);
	CFrameWnd::OnClose();
}
Exemplo n.º 5
0
Arquivo: api.c Projeto: AlexSteel/wine
static void test_ash1_corruption(void)
{
    COMMON_AVI_HEADERS cah;
    char filename[MAX_PATH];
    PAVIFILE pFile;
    int res;
    PAVISTREAM pStream1;
    AVISTREAMINFOA asi1;

    GetTempPathA(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 = AVIFileOpenA(&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 = AVIStreamInfoA(pStream1, &asi1, sizeof(asi1));
    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(DeleteFileA(filename) !=0, "Deleting file %s failed\n", filename);
}
Exemplo n.º 6
0
Arquivo: api.c Projeto: AlexSteel/wine
static void test_ash1_corruption2(void)
{
    COMMON_AVI_HEADERS cah;
    char filename[MAX_PATH];
    PAVIFILE pFile;
    int res;
    PAVISTREAM pStream1;
    AVISTREAMINFOA asi1;

    GetTempPathA(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 = AVIFileOpenA(&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(AVIStreamInfoA(pStream1, &asi1, sizeof(asi1)) == 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(DeleteFileA(filename) !=0, "Deleting file %s failed\n", filename);
}
Exemplo n.º 7
0
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;
}
Exemplo n.º 8
0
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
	}
Exemplo n.º 9
0
void VideoReader::Close()
{
    // Close the stream and file. 
    AVIFileRelease(m_pf); 
    AVIFileExit();

    if (m_lpBuffer != NULL)
    {
        free(m_lpBuffer);
    }
}
Exemplo n.º 10
0
void CvVideoWriter_VFW::close()
{
    if( uncompressed )
        AVIStreamRelease( uncompressed );
    if( compressed )
        AVIStreamRelease( compressed );
    if( avifile )
        AVIFileRelease( avifile );
    cvReleaseImage( &tempFrame );
    init();
}
Exemplo n.º 11
0
HRESULT CloseAvi(HAVI avi)
{ if (avi==NULL) return AVIERR_BADHANDLE;
  TAviUtil *au = (TAviUtil*)avi;
  if (au->as!=0) AVIStreamRelease(au->as); au->as=0;
  if (au->psCompressed!=0) AVIStreamRelease(au->psCompressed); au->psCompressed=0;
  if (au->ps!=0) AVIStreamRelease(au->ps); au->ps=0;
  if (au->pfile!=0) AVIFileRelease(au->pfile); au->pfile=0;
  AVIFileExit();
  delete au;
  return S_OK;
}
AVIReadHandlerTunnelW32::~AVIReadHandlerTunnelW32() {
    if (mpAvisynthClipInfo) {
        mpAvisynthClipInfo->Release();
        mpAvisynthClipInfo = nullptr;
    }

    if (mpAVIFile) {
        AVIFileRelease(mpAVIFile);
        mpAVIFile = nullptr;
    }
}
Exemplo n.º 13
0
void CAviToBmp::Close()
{
	if (m_pGetFrame != NULL)
		AVIStreamGetFrameClose(m_pGetFrame);
	if (m_pStream != NULL)
		AVIStreamRelease(m_pStream);
	if (m_pFile != NULL)
		AVIFileRelease(m_pFile);
	if (m_pBmpInfo != NULL)
		delete m_pBmpInfo;
	Init();
}
Exemplo n.º 14
0
// AVI_stream_close() should be called when you are finished reading all the frames of an AVI
//
void AVI_stream_close()
{	
//	Assert( AVI_stream.flags & AVI_STREAM_F_USED);

   AVIStreamRelease(AVI_stream.pstream);				// closes the video stream
	AVIFileRelease(AVI_stream.pfile);					// closes the file 
	AVI_stream.flags &= ~AVI_STREAM_F_USED;			// clear the used flag

	AVIFileExit();          // releases AVIFile library 
	AVI_stream_inited = 0;

}
Exemplo n.º 15
0
AviFile::~AviFile()
{
    if (!play) {
        Print("*** Closing AVI file '%s' with %d frames\n", (const char*) filename, nframe);
    }

    if (ps_comp)   AVIStreamRelease(ps_comp);
    if (ps)        AVIStreamRelease(ps);
    if (pfile)     AVIFileRelease(pfile);

    AVIFileExit();
}
void captureVideo(HDC hDC){
	if(saves.size()>0){
		SendMessage(hWnd,WM_COMMAND,MAKEWPARAM(IDC_LISTBOX,LBN_SELCHANGE),0);

		currentFrame = 0;
		GLvoid *imageData = 0;
		while(WWDPhysics->totaltime<10000){
			while(!WWDPhysics->clientMoveAndDisplay(true, hDC)){}

			HDC hdcscreen=GetDC(0), hdc=CreateCompatibleDC(hdcscreen); ReleaseDC(0,hdcscreen);
			HBITMAP hData;

			hData = CreateDIBSection(hdc,(BITMAPINFO*) bi,DIB_RGB_COLORS,&imageData,NULL,NULL);
			GdiFlush(); //flush graphics operations batch to ensure memory contains the right pixels

			if(imageData!=0){
				glReadPixels(0, 0, abs(simWidth), abs(simHeight), GL_BGRA, GL_UNSIGNED_BYTE, imageData); //Copy the image to the array imageData

				DIBSECTION dibs; int sbm = GetObject(hData,sizeof(dibs),&dibs);

				if (sbm!=sizeof(DIBSECTION)){
#ifdef _DEBUG
					printf("dibsection fault\n");
#endif
				}else{
					DWORD keyframe = NULL;
					if(currentFrame==0){keyframe=AVIIF_KEYFRAME;}
					AVIStreamWrite(*pcompressedstream,currentFrame,1,dibs.dsBm.bmBits,dibs.dsBmih.biSizeImage,keyframe,NULL,NULL);
					currentFrame++;
				}
				DeleteObject(hData);
			}
			else{
#ifdef _DEBUG
				printf("frame skipped nr %d\n",currentFrame);
#endif
			}
		}
	}

	//vfw cleanup
	if(VFWReturnVal==0){
		AVIStreamRelease(*pcompressedstream);
		delete(pcompressedstream);
		AVIStreamRelease(*pstream);
		delete pstream;
		AVISaveOptionsFree(1,aopts);
		AVIFileRelease(*pfile);  // closes the file
	}
	AVIFileExit();          // releases AVIFile library
	//\vfw cleanup
}
Exemplo n.º 17
0
void AVIDump::Stop()
{
	// store one copy of the last video frame, CFR case
	if (s_stream_compressed)
		AVIStreamWrite(s_stream_compressed, s_frame_count++, 1, GetFrame(), s_bitmap.biSizeImage, AVIIF_KEYFRAME, nullptr, &s_byte_buffer);
	
	//Dragonbane:: Dump 5 seconds of the same frame for readability
	if (Movie::cmp_justFinished || Movie::cmp_rightFinished && Movie::cmp_leftFinished || (Movie::cmp_rightFinished || Movie::cmp_leftFinished) && Movie::cmp_movieFinished && !Movie::GetNextComparisonMovie(false))
	{
		Movie::cmp_justFinished = false;

		if (s_stream && s_stream_compressed)
		{
			int endFrames = s_frame_rate * 5;
			for (int i = 0; i < endFrames - 1; i++)
			{
				AVIStreamWrite(s_stream, s_frame_count++, 1, nullptr, 0, 0, nullptr, nullptr);
			}
			AVIStreamWrite(s_stream_compressed, s_frame_count++, 1, GetFrame(), s_bitmap.biSizeImage, AVIIF_KEYFRAME, nullptr, &s_byte_buffer);
		}
	}
	
	s_start_dumping = false;
	CloseFile();
	s_file_count = 0;

	//Dragonbane
	if (s_getFrame_temp)
	{
		AVIStreamGetFrameClose(s_getFrame_temp);
		s_getFrame_temp = nullptr;
	}

	if (s_stream_temp)
	{
		AVIStreamClose(s_stream_temp);
		s_stream_temp = nullptr;
	}

	if (s_file_temp)
	{
		AVIFileRelease(s_file_temp);
		s_file_temp = nullptr;

		std::string movie_file_name = GetCurrDumpFile(tempFileCount, true);

		if (File::Exists(movie_file_name))
			File::Delete(movie_file_name);
	}

	NOTICE_LOG(VIDEO, "Stop");
}
Exemplo n.º 18
0
static int avisynth_read_close(AVFormatContext *s)
{
    AviSynthContext *avs = s->priv_data;
    int i;

    for (i = 0; i < avs->nb_streams; i++)
        AVIStreamRelease(avs->streams[i].handle);

    av_free(avs->streams);
    AVIFileRelease(avs->file);
    AVIFileExit();
    return 0;
}
Exemplo n.º 19
0
void CBmpToAvi::Close()
{
	if (m_pavi)
	{
		AVIStreamRelease(m_pavi);
		m_pavi = NULL;
	}
	if (m_pfile)
	{
		AVIFileRelease(m_pfile);
		m_pfile = NULL;
	}		
}
Exemplo n.º 20
0
static void avi_cleanup_context(avi_encode_context *context)
{
  if (context->pscomp)
    AVIStreamRelease(context->pscomp);
  context->pscomp = NULL;

  if (context->ps)
    AVIStreamRelease(context->ps);
  context->ps = NULL;

  if (context->pfile)
    AVIFileRelease(context->pfile);
  context->pfile = NULL;
}
Exemplo n.º 21
0
void CvCaptureAVI_VFW::close()
{
    if( getframe )
        AVIStreamGetFrameClose( getframe );

    if( avistream )
        AVIStreamRelease( avistream );

    if( avifile )
        AVIFileRelease( avifile );

    cvReleaseImage( &frame );
    init();
}
void avisynth_read_close()
{

    int i;

    for (i=0; i<avs->nb_streams; i++)
    {
        AVIStreamRelease(avs->streams[i].handle);
    }

    free(avs->streams);
    AVIFileRelease(avs->file);
    AVIFileExit();
    free(avs);
}
Exemplo n.º 23
0
void imFileFormatAVI::Close()
{
  if (this->dib) imDibDestroy(this->dib);

  if (this->use_compressor) 
  {
    ICSeqCompressFrameEnd(&this->compvars);
    ICCompressorFree(&this->compvars);
  }

  if (this->frame) AVIStreamGetFrameClose(this->frame);
  if (this->stream) AVIStreamRelease(this->stream);

  AVIFileRelease(this->file);
  AVIFileExit();    /* called one for each AVIFileInit */
}
Exemplo n.º 24
0
	/**
	 * AVIファイルを閉じる
	 */
	void closeAVI() {
                if (ptmp) {
                   AVIStreamRelease(ptmp);
                   ptmp = NULL;
                }
		if (pstm) {
			AVIStreamRelease(pstm);
			pstm = NULL;
		}
		if (pavi) {
			AVIFileRelease(pavi);
			pavi = NULL;
		}
                if (hasCv) {
                  ICCompressorFree(&cv);
                }
	}
Exemplo n.º 25
0
Arquivo: ppm.cpp Projeto: Rageous/Core
void AVIExporter::close() {
    if (videoStream) {
        AVIStreamRelease(videoStream);
        videoStream = 0;
    }

    if (compressedVideoStream) {
        AVIStreamRelease(compressedVideoStream);
        compressedVideoStream = 0;
    }

    if (outputFile) {
        AVIFileRelease(outputFile);
        outputFile = 0;
    }

    AVIFileExit();
}
Exemplo n.º 26
0
HRESULT CloseAvi (HAVI avi)
{
	TAviUtil *au;
	if (!avi)
		return AVIERR_BADHANDLE;
	au = (TAviUtil *)avi;
	if (au->audStream)
		AVIStreamRelease(au->audStream);
	if (au->vidStreamComp)
		AVIStreamRelease(au->vidStreamComp);
	if (au->vidStream)
		AVIStreamRelease(au->vidStream);
	if (au->pfile)
		AVIFileRelease(au->pfile);
	AVIFileExit();
	free(au);
	return S_OK;
}
Exemplo n.º 27
0
void CAviLoader::close()
{
    if( getframe )
        AVIStreamGetFrameClose( getframe );

    if( avistream )
        AVIStreamRelease( avistream );

    if( avifile )
        AVIFileRelease( avifile );

    if(frame)
	{
		delete []frame;
		frame = NULL;
	}

    init();
}
Exemplo n.º 28
0
  void release_avi()
  {
    if (getFrame != NULL)
    {
      try
      {
        AVIStreamGetFrameClose(getFrame);
      }
      catch (...)
      {
        printf("AVIStreamGetFrameClose error");
      }
      getFrame = NULL;
	  }

    if (streamVid != NULL)
    {
      try
      {
        AVIStreamRelease(streamVid);
      }
      catch (...)
      {
        printf("AVIStreamRelease error");
      }
      streamVid = NULL;
    }

    if (m_aviFile!=NULL)
    {
      try
      {
        AVIFileRelease(m_aviFile);
      }
      catch (...)
      {
        printf("AVIFileRelease error");
      }
      m_aviFile = NULL;
    }
  }
Exemplo n.º 29
0
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; 
}
Exemplo n.º 30
0
	/////////////////////////////////////////////////////////
	//close Avi file. Close all avi streams
	/////////////////////////////////////////////////////////
	CAviMan::CloseAviFile()
	{
		if(m_aviGetFrame)
			AVIStreamGetFrameClose(m_aviGetFrame);			//close get frame info

		for (DWORD i = 0; i < m_dwNumStreams; i++)
		{
			if(m_aviStream[i])
				AVIStreamRelease(m_aviStream[i]);
		}

		if (m_aviFile) AVIFileRelease(m_aviFile);

		m_aviFile = NULL;
		m_aviVideoStream = NULL;
		m_aviGetFrame = NULL;

		m_dwNumStreams = MAX_AVI_STREAM-1;


	}