Esempio n. 1
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;
}
Esempio n. 2
0
void MovieMaker::EndCapture()
{
    fprintf( stderr, "\n" );
	if (ps)
        {
		AVIStreamClose(ps);
        ps = NULL;
        }

	if (psCompressed)
        {
		AVIStreamClose(psCompressed);
        psCompressed = NULL;
        }

	if (psText)
        {
		AVIStreamClose(psText);
        psText = NULL;
        }

	if (pfile)
        {
		AVIFileClose(pfile);
        pfile = NULL;
        }

	WORD wVer = HIWORD(VideoForWindowsVersion());
	if (wVer >= 0x010A)
	    {
		AVIFileExit();
	    }

}
Esempio n. 3
0
void AviRecorder::Stop()
{
	m_fAudioReady = false;

	if (m_pstmVideo != NULL) {
		AVIStreamClose(m_pstmVideo);
		m_pstmVideo = NULL;
	}

	if (m_pstmAudio != NULL) {
		AVIStreamClose(m_pstmAudio);
		m_pstmAudio = NULL;
	}

	if (m_pavif != NULL) {
		AVIFileClose(m_pavif);
		m_pavif = NULL;
	}

	AVIFileExit();

	m_nSample = 0;
	delete m_pbmFlip;
	m_pbmFlip = NULL;
	delete m_ptbmPointer;
	m_ptbmPointer = NULL;
}
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;
}
CAVIFileReader::~CAVIFileReader()
{
    LogMessage("CAVIFileReader::~CAVIFileReader started");

    if (NULL != m_pAudioStream)
    {
        AVIStreamRelease(m_pAudioStream);
        m_pAudioStream = NULL;
    }

    if (NULL != m_pWaveFormat)
    {
        FreeMemory(m_pWaveFormat);
        m_pWaveFormat = NULL;
    }


    //
    // AVIFileExit must be called on the same thread as AVIFileInit.
    // therefore this object must be created and deleted on the same thread
    //

    AVIFileExit();

    LogMessage("CAVIFileReader::~CAVIFileReader completed");
}
Esempio n. 6
0
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;
}
Esempio n. 7
0
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;
}
void plAVIWriterImp::Close()
{
    plgDispatch::Dispatch()->UnRegisterForExactType(plRenderMsg::Index(), GetKey());

#if HS_BUILD_FOR_WIN32
    hsTimer::SetRealTime(fOldRealTime);

    if (fStreamHandle)
    {
        AVIStreamClose(fStreamHandle);
        fStreamHandle = nil;
    }

    if (fCompressedHandle)
    {
        AVIStreamClose(fCompressedHandle);
        fCompressedHandle = nil;
    }

    if (fFileHandle)
    {
        AVIFileClose(fFileHandle);
        fFileHandle = nil;
    }

    AVIFileExit();
#endif
}
Esempio n. 9
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;
}
Esempio n. 10
0
/*
---------------------------------------------------------------------------------------
- destructor
---------------------------------------------------------------------------------------
*/
AviVideoRenderer::~AviVideoRenderer()
{
	CloseAVI();
	--_init_counter;

	if(_init_counter == 0)
		AVIFileExit();		// Release The File
}
Esempio n. 11
0
File: AVI.cpp Progetto: DCubix/1.4.0
void CAvi::cleanUp(void)												// Properly Closes The Avi File
{
	glDeleteTextures( 1, &m_textureId );
	DeleteObject(m_hBitmap);										// Delete The Device Dependant Bitmap Object
	DrawDibClose(m_hdd);											// Closes The DrawDib Device Context
	AVIStreamGetFrameClose(m_pgf);								// Deallocates The GetFrame Resources
	AVIStreamRelease(m_pavi);										// Release The Stream
	AVIFileExit();												// Release The File
}
Esempio n. 12
0
void AVIClose(struct AVIFile** avi_out)
{
	if(*avi_out)
	{
		clean_up(*avi_out);
		delete *avi_out;
	}
	*avi_out = NULL;
	AVIFileExit();
}
Esempio n. 13
0
void FreAviDLL()
{			
	if (!hPPAviDll)
		return;
	if (dll_AVIFileExit)
		AVIFileExit();
	if (dll_TermVFW)
		TermVFW();
	FreeLibrary( hPPAviDll );
	hPPAviDll = NULL;
}
Esempio n. 14
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;
}
Esempio n. 15
0
void VideoReader::Close()
{
    // Close the stream and file. 
    AVIFileRelease(m_pf); 
    AVIFileExit();

    if (m_lpBuffer != NULL)
    {
        free(m_lpBuffer);
    }
}
Esempio n. 16
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;

}
Esempio n. 17
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
}
Esempio n. 19
0
void AVIOBJ::CloseAVI(void)												// Properly Closes The Avi File
{

    DeleteObject(hBitmap);										// Delete The Device Dependant Bitmap Object
    if (hdd) DrawDibClose(hdd);											// Closes The DrawDib Device Context
    if (pgf)
    {
        AVIStreamGetFrameClose(pgf);								// Deallocates The GetFrame Resources
        AVIStreamRelease(pavi);										// Release The Stream
        AVIFileExit();												// Release The File
    }

}
Esempio n. 20
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;
}
Esempio n. 21
0
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;
}
Esempio n. 22
0
int __stdcall WinMain ( HINSTANCE hInstance, HINSTANCE hPrevInstance, char* lpCmdLine, int nCmdShow )
{
   _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );

   hInst = hInstance ;

   AVIFileInit();

   DialogBoxParam ( hInstance, "vo_Dialog", 0, (DLGPROC)DlgProc, 0 ) ;

   AVIFileExit();

   return 0 ;
}
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);
}
Esempio n. 24
0
AVIWrite::~AVIWrite()
{
  if(m_streamSound)
    AVIStreamClose(m_streamSound);

  if(m_streamCompressed)
    AVIStreamClose(m_streamCompressed);
  
  if(m_stream)
    AVIStreamClose(m_stream);

  if(m_file)
    AVIFileClose(m_file);

  AVIFileExit();
}
Esempio n. 25
0
int
avi_end_encode(void *handle)
{
#ifdef HAVE_VFW
  avi_encode_context *context;

  context = (avi_encode_context *)handle;
  avi_cleanup_context(context);
  free(context);
  AVIFileExit();
  return 1;
#else /* HAVE_VFW */
  return 0
#endif /* HAVE_VFW */

    };
void Movie::close()
{
    if (DataPointer_)
    {
        /* Delete each movie object data */
        DeleteObject(mcrAVIData->hBitmap);
        DrawDibClose(mcrAVIData->hDrawDIB);
        
        AVIStreamGetFrameClose(mcrAVIData->pGetFrame);
        AVIStreamRelease(mcrAVIData->pVideoStream);
        AVIFileExit();
        
        /* Delete the movie data */
        delete mcrAVIData;
    }
}
Esempio n. 27
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 */
}
Esempio n. 28
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;
}
Esempio n. 29
0
void AVI :: Close(void)												// Properly Closes The Avi File
{
	if(mpf)
	{
		DeleteObject(hBitmap);										// Delete The Device Dependant Bitmap Object
		DrawDibClose(hdd);											// Closes The DrawDib Device Context
		AVIStreamGetFrameClose(pgf);								// Deallocates The GetFrame Resources
		AVIStreamRelease(pavi);										// Release The Stream
		AVIFileExit();												// Release The File
	}

	// clear everything else
	pos=0;
	width=height=0;
	mpf=0;
	pdata=NULL;
	loop=false;
}
Esempio n. 30
0
File: ppm.cpp Progetto: Rageous/Core
void AVIExporter::close() {
    if (videoStream) {
        AVIStreamRelease(videoStream);
        videoStream = 0;
    }

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

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

    AVIFileExit();
}