コード例 #1
0
ファイル: AviFile.cpp プロジェクト: MattHung/sage-graphics
HRESULT	CAviFile::AppendFrameUsual(int nWidth, int nHeight, LPVOID pBits,int nBitsPerPixel)
{
	DWORD	dwSize=nWidth*nHeight*nBitsPerPixel/8;

	if(FAILED(AVIStreamWrite(m_pAviCompressedStream,m_lSample++,1,pBits,dwSize,0,NULL,NULL)))
		return E_FAIL;

    return S_OK;
}
コード例 #2
0
ファイル: avi_encode.c プロジェクト: Alexpux/simage
int
avi_encode_bitmap(void *handle, unsigned char *buf, int rgb2bgr)
{
  /* Note: buf must be a 24-bit RGB (or BGR) image with the same size as
     given to avi_begin_encode. It is the caller's responsibility to
     check this.

     If rgb2bgr, the color ordering in the buffer will be modified from RGB to BGR.
     NB: this means that the buffer will be modified.

     2003-03-14 thammer.
  */
#ifdef HAVE_VFW
  HRESULT hr;
  avi_encode_context *context;

  context = (avi_encode_context *)handle;

  /* For some reason, AVIStreamWrite requires the color components to
     be ordered BGR instead of RGB */
  if (rgb2bgr) {
    int x, y, r, nc, w, h;
    nc = 3;
    w = context->width;
    h = context->height;
    for (x=0; x<w; x++)
      for (y=0; y<h; y++) {
        r = buf[x * nc + y * nc * w + 0];
        buf[x * nc + y * nc * w + 0] = buf[x * nc + y * nc * w + 2];
        buf[x * nc + y * nc * w + 2] = r;
      }
  }

  hr = AVIStreamWrite(context->pscomp,
                      context->framenumber,
                      1,
                      (LPBYTE) buf,
                      context->width * context->height * 3, /* nc = 3 (24 bit) */
                      AVIIF_KEYFRAME,
                      NULL,
                      NULL);

  /*
    fixme 20020227 thammer: Is it correct / smart to let every frame be
    a keyframe? Check avi doc and virtualdub.  */

  if (hr != AVIERR_OK)
    return 0;

  context->framenumber++;

  return 1;
#else /* HAVE_VFW */
  return 0;
#endif /* HAVE_VFW */
};
コード例 #3
0
ファイル: Win32Avi.c プロジェクト: matthewbauer/blueMSX
void aviAddFrame(void* buffer, int length)
{
    if (!aviStatusOk) {
        return;
    }

    if (AVIStreamWrite(aviVidStream, frameCount++, 1, buffer, length, AVIIF_KEYFRAME, NULL, NULL) != 0) {
        aviStatusOk = 0;
    }
}
コード例 #4
0
ファイル: aviwrite.cpp プロジェクト: Ahmar/hostile-takeover
void AviRecorder::AddAudio(byte *pb8Unsigned, dword cb)
{
	if (!m_fAudioReady)
		return;

	// Write to the audio stream

	AVIStreamWrite(m_pstmAudio, m_nSample, cb, pb8Unsigned, cb, 0, NULL, NULL);
	m_nSample += cb;
}
コード例 #5
0
ファイル: AVI.cpp プロジェクト: MounikaArkala/txstateprojects
HRESULT AddAviAudio (HAVI avi, void *dat, unsigned long numbytes)
{
	TAviUtil *au;
	unsigned long numsamps;
	HRESULT hr;

	if (!avi)
		return AVIERR_BADHANDLE;
	if ((!dat) || (!numbytes))
		return AVIERR_BADPARAM;
	au = (TAviUtil*)avi;
	if (au->iserr)
		return AVIERR_ERROR;
	if (!au->wfx.nChannels)
		return AVIERR_BADFORMAT;

	// make sure it's a whole number of samples
	numsamps = numbytes * 8 / au->wfx.wBitsPerSample;
	if ((numsamps * au->wfx.wBitsPerSample / 8) != numbytes)
		return AVIERR_BADPARAM;

	if (!au->audStream)	// create the stream if necessary
	{
		AVISTREAMINFO ahdr;
		ZeroMemory(&ahdr, sizeof(ahdr));
		ahdr.fccType = streamtypeAUDIO;
		ahdr.dwScale = au->wfx.nBlockAlign;
		ahdr.dwRate = au->wfx.nSamplesPerSec * au->wfx.nBlockAlign; 
		ahdr.dwSampleSize = au->wfx.nBlockAlign;
		ahdr.dwQuality = (DWORD)-1;
		hr = AVIFileCreateStream(au->pfile, &au->audStream, &ahdr);
		if (hr)
		{
			au->iserr = TRUE;
			return hr;
		}
		hr = AVIStreamSetFormat(au->audStream, 0, &au->wfx, sizeof(WAVEFORMATEX));
		if (hr)
		{
			au->iserr = TRUE;
			return hr;
		}
	}

	// now we can write the data
	hr = AVIStreamWrite(au->audStream, au->nsamp, numsamps, dat, numbytes, 0, NULL, NULL);
	if (hr)
	{
		au->iserr = TRUE;
		return hr;
	}
	au->nsamp += numsamps;
	return S_OK;
}
コード例 #6
0
ファイル: Win32Avi.c プロジェクト: matthewbauer/blueMSX
void aviAddSound(Int16* buffer, int count)
{
    if (!aviStatusOk) {
        return;
    }

    if (AVIStreamWrite(aviSndStream, sampleCount, count, buffer, count * 4, 0, NULL, NULL) != 0) {
        aviStatusOk = 0;
    }

    sampleCount += count;
}
コード例 #7
0
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
}
コード例 #8
0
ファイル: aviout.cpp プロジェクト: Plombo/fceux
static void avi_destroy(struct AVIFile** avi_out)
{
	if(!(*avi_out))
		return;

	if((*avi_out)->sound_added)
	{
		if((*avi_out)->compressed_streams[AUDIO_STREAM])
		{
			if ((*avi_out)->audio_buffer_pos > 0) {
				if(FAILED(AVIStreamWrite(avi_file->compressed_streams[AUDIO_STREAM],
				                         avi_file->sound_samples, (*avi_out)->audio_buffer_pos / (*avi_out)->wave_format.nBlockAlign,
				                         (*avi_out)->audio_buffer, (*avi_out)->audio_buffer_pos, 0, NULL, &avi_file->ByteBuffer)))
				{
					avi_file->valid = 0;
				}
				(*avi_out)->sound_samples += (*avi_out)->audio_buffer_pos / (*avi_out)->wave_format.nBlockAlign;
				(*avi_out)->tBytes += avi_file->ByteBuffer;
				(*avi_out)->audio_buffer_pos = 0;
			}

			LONG test = AVIStreamClose((*avi_out)->compressed_streams[AUDIO_STREAM]);
			(*avi_out)->compressed_streams[AUDIO_STREAM] = NULL;
			(*avi_out)->streams[AUDIO_STREAM] = NULL;				// compressed_streams[AUDIO_STREAM] is just a copy of streams[AUDIO_STREAM]
		}
	}

	if((*avi_out)->video_added)
	{
		if((*avi_out)->compressed_streams[VIDEO_STREAM])
		{
			AVIStreamClose((*avi_out)->compressed_streams[VIDEO_STREAM]);
			(*avi_out)->compressed_streams[VIDEO_STREAM] = NULL;
		}

		if((*avi_out)->streams[VIDEO_STREAM])
		{
			AVIStreamClose((*avi_out)->streams[VIDEO_STREAM]);
			(*avi_out)->streams[VIDEO_STREAM] = NULL;
		}
	}

	if((*avi_out)->avi_file)
	{
		AVIFileClose((*avi_out)->avi_file);
		(*avi_out)->avi_file = NULL;
	}

	free((*avi_out)->convert_buffer);
	free(*avi_out);
	*avi_out = NULL;
}
コード例 #9
0
ファイル: AVIDump.cpp プロジェクト: Zombiebest/Dolphin
void AVIDump::AddFrame(char *data)
{
	AVIStreamWrite(m_streamCompressed, ++m_frameCount, 1, (LPVOID) data, m_bitmap.biSizeImage, AVIIF_KEYFRAME, NULL, &m_byteBuffer);
	m_totalBytes += m_byteBuffer;
	// Close the recording if the file is more than 2gb
	// VfW can't properly save files over 2gb in size, but can keep writing to them up to 4gb.
	if (m_totalBytes >= 2000000000)
	{
		CloseFile();
		m_fileCount++;
		CreateFile();
	}
}
コード例 #10
0
ファイル: avifile.cpp プロジェクト: BuckeyeDude/Wabbitemu
HRESULT CAviFile::AppendAudioData(WAVEFORMATEX *wfx, void *dat, unsigned long numbytes) {
	if (dat == NULL || numbytes == 0) {
		return AVIERR_BADPARAM;
	}
	
	if (wfx->nChannels == 0) {
		return AVIERR_BADFORMAT;
	}

	unsigned long numsamps = numbytes * 8 / wfx->wBitsPerSample;
	if ((numsamps * wfx->wBitsPerSample / 8) != numbytes) {
		return AVIERR_BADPARAM;
	}

	if (m_pAviAudioStream == NULL) // create the stream if necessary
	{
		if (m_pAviFile == NULL) {
			return S_OK;
		}

		AVISTREAMINFO ahdr;
		ZeroMemory(&ahdr, sizeof(ahdr));
		ahdr.fccType = streamtypeAUDIO;
		ahdr.dwScale = wfx->nBlockAlign;
		ahdr.dwRate = wfx->nSamplesPerSec * wfx->nBlockAlign;
		ahdr.dwSampleSize = wfx->nBlockAlign;
		ahdr.dwQuality = (DWORD)-1;
		HRESULT hr = AVIFileCreateStream(m_pAviFile, &m_pAviAudioStream, &ahdr);
		if (hr != AVIERR_OK) {
			SetErrorMessage(_T("Unable to create audio stream"));
			return E_FAIL;
		}

		hr = AVIStreamSetFormat(m_pAviAudioStream, m_lVSample, wfx, sizeof(WAVEFORMATEX) + wfx->cbSize);
		if (hr != AVIERR_OK) {
			SetErrorMessage(_T("Unable to set audio stream format"));
			return E_FAIL;
		}
	}

	HRESULT hr = AVIStreamWrite(m_pAviAudioStream, m_lASample, numsamps, dat, numbytes, 0, NULL, NULL);
	if (hr != AVIERR_OK) {
		SetErrorMessage(_T("Unable to Write Audio Stream to the output Movie File"));
		return E_FAIL;
	}

	m_lASample += numsamps;
	return S_OK;
}
コード例 #11
0
ファイル: avifile.cpp プロジェクト: BuckeyeDude/Wabbitemu
HRESULT	CAviFile::AppendFrameUsual(int nWidth, int nHeight, LPVOID pBits, WORD nBitsPerPixel)
{
	DWORD dwSize = nWidth * nHeight * nBitsPerPixel / 8;

	if (FAILED(AVIStreamWrite(m_pAviCompressedStream, m_lVSample++, 1, pBits, dwSize, 0, NULL, NULL))) 
	{
		SetErrorMessage(_T("Unable to Write Video Stream to the output Movie File"));

		ReleaseMemory();

		return E_FAIL;
	}

	return S_OK;
}
コード例 #12
0
ファイル: AVIOutput.cpp プロジェクト: Kriole/snes9x-rr
static void clean_up(AVIFile* _avi)
{
	AVIFile& avi = *_avi;

	if(avi.sound_added)
	{
		if(avi.compressed_streams[AUDIO_STREAM])
		{
			if (avi.audio_buffer_pos > 0) {
				if(FAILED(AVIStreamWrite(avi.compressed_streams[AUDIO_STREAM],
				                         avi.sound_samples, avi.audio_buffer_pos / avi.wave_format.nBlockAlign,
				                         avi.audio_buffer, avi.audio_buffer_pos, 0, NULL, &avi.ByteBuffer)))
				{
					avi.valid = false;
				}
				avi.sound_samples += avi.audio_buffer_pos / avi.wave_format.nBlockAlign;
				avi.tBytes += avi.ByteBuffer;
				avi.audio_buffer_pos = 0;
			}

			AVIStreamClose(avi.compressed_streams[AUDIO_STREAM]);
			avi.compressed_streams[AUDIO_STREAM] = NULL;
			avi.streams[AUDIO_STREAM] = NULL;				// compressed_streams[AUDIO_STREAM] is just a copy of streams[AUDIO_STREAM]
		}
	}

	if(avi.video_added)
	{
		if(avi.compressed_streams[VIDEO_STREAM])
		{
			AVIStreamClose(avi.compressed_streams[VIDEO_STREAM]);
			avi.compressed_streams[VIDEO_STREAM] = NULL;
		}

		if(avi.streams[VIDEO_STREAM])
		{
			AVIStreamClose(avi.streams[VIDEO_STREAM]);
			avi.streams[VIDEO_STREAM] = NULL;
		}
	}

	if(avi.avi_file)
	{
		AVIFileClose(avi.avi_file);
		avi.avi_file = NULL;
	}
}
コード例 #13
0
ファイル: MainFrm.cpp プロジェクト: hiccupzhu/misc_starting
// Function name	: PASCAL VideoCallbackProc
// Description	    : Encode the captured frame
// Return type		: LRESULT FAR 
// Argument         : HWND hWnd
// Argument         : LPVIDEOHDR lpVHdr
LRESULT FAR PASCAL VideoCallbackProc(HWND hWnd, LPVIDEOHDR lpVHdr)
{
	unsigned char *bufi, *buf;
	int type=0;
	int quant=0;
	int declen=0;
	int enclen=0;
	bufi = new unsigned char[lpVHdr->dwBytesUsed+40];	//original image
	buf = new unsigned char[lpVHdr->dwBytesUsed];		//coded stream

	memcpy((void *)(bufi), lpVHdr->lpData, lpVHdr->dwBytesUsed);
	
	unsigned char *buf1;
	buf1 = buf;
	

	if (m_vfwState==ENCDEC) {
   //Encode
		buf1 = (unsigned char*)ICSeqCompressFrame(&pc,0,bufi, &IsKeyFrame,&FrameSize);
		//enc_main(bufi, buf, (int *)&FrameSize, &IsKeyFrame, -1);
		////////////////////////////////
		if (bSaveAVI){
			AVIStreamSetFormat(pMainFrame->ps,pMainFrame->m_Frame++,lpbiTmp,sizeof(BITMAPINFO));
			AVIStreamWrite(pMainFrame->ps,pMainFrame->m_Frame, 1, (LPBYTE)buf1,
						 lpbiTmp->bmiHeader.biSizeImage,AVIIF_KEYFRAME,NULL,NULL);
		}
		////////////////////////////////
   //Decode
		ICDecompress(hic2,0,&lpbiTmp->bmiHeader,buf1,&lpbiOut->bmiHeader,&bufo[40]);
	} else {
		enc_main(bufi,buf, &IsKeyFrame,&type,&quant,&enclen);
		declen = dec_main(buf, bufi, enclen,lpbiIn->bmiHeader.biWidth);
		pMainFrame->conv.YV12_to_RGB24(bufi,
									   bufi+(lpbiIn->bmiHeader.biWidth*lpbiIn->bmiHeader.biHeight),
									   bufi+(lpbiIn->bmiHeader.biWidth*lpbiIn->bmiHeader.biHeight*5/4),
									   &bufo[40],
									   lpbiIn->bmiHeader.biWidth,
									   lpbiIn->bmiHeader.biHeight);
	}

	pMainFrame->GetActiveView()->InvalidateRect(NULL,FALSE);											

	delete bufi;
	delete buf;

	return (LRESULT) TRUE;
}
コード例 #14
0
void NxVideo_Avi_Recorder::AddVideoFrame( unsigned char * bmBits )
{
	HRESULT hr;

	// compress bitmap
	hr = AVIStreamWrite( mVideo->m_pStreamCompressed,	// stream pointer
		mVideo->m_lFrame,						// time of this frame
		1,						// number to write
		bmBits,					// image buffer
		mVideo->m_bih.biSizeImage,		// size of this frame
		AVIIF_KEYFRAME,			// flags....
		NULL,
		NULL);

	// updating frame counter
	mVideo->m_lFrame++;
}
コード例 #15
0
ファイル: AviFile.cpp プロジェクト: MattHung/sage-graphics
HRESULT CAviFile::AppendFrameUsual(HBITMAP hBitmap)
{
	BITMAPINFO	bmpInfo;

	bmpInfo.bmiHeader.biBitCount=0;
	bmpInfo.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);

	GetDIBits(m_hAviDC,hBitmap,0,0,NULL,&bmpInfo,DIB_RGB_COLORS);

	bmpInfo.bmiHeader.biCompression=BI_RGB;

	GetDIBits(m_hAviDC,hBitmap,0,bmpInfo.bmiHeader.biHeight,m_lpBits,&bmpInfo,DIB_RGB_COLORS);

	if(FAILED(AVIStreamWrite(m_pAviCompressedStream,m_lSample++,1,m_lpBits,bmpInfo.bmiHeader.biSizeImage,0,NULL,NULL)))
		return E_FAIL;

    return S_OK;
}
コード例 #16
0
bool mitk::MovieGeneratorWin32::AddFrame(void *data)
{
  HRESULT hr = AVIStreamWrite(m_pStreamCompressed, // stream pointer
                              m_lFrame,            // time of this frame
                              1,                   // number to write
                              (BYTE *)data,        // image buffer
                              m_bih.biSizeImage,   // size of this frame
                              AVIIF_KEYFRAME,      // flags....
                              NULL,
                              NULL);
  // updating frame counter
  m_lFrame++;

  if (hr == AVIERR_OK)
    return true;
  else
    return false;
}
コード例 #17
0
ファイル: AviFile.cpp プロジェクト: stainlessio/Linkage
HRESULT CAviFile::AppendFrameUsual( CDIBSection *pDIBSection, int Count )
{
	while( Count > 0 )
	{
		if(FAILED(AVIStreamWrite(m_pAviCompressedStream,m_lSample++,1,pDIBSection->m_pBits,pDIBSection->m_bmpInfo.bmiHeader.biSizeImage,0,NULL,NULL)))
		{
			SetErrorMessage(_T("Unable to Write Video Stream to the output Movie File"));

			ReleaseMemory();

			m_LastError = E_FAIL;
			return E_FAIL;
		}
		--Count;
	}

    return S_OK;
}
コード例 #18
0
ファイル: aviout.cpp プロジェクト: snowasnow/DeSmuME
void DRV_AviSoundUpdate(void* soundData, int soundLen)
{
	int nBytes;

	if(!avi_file || !avi_file->valid || !avi_file->sound_added)
		return;

	nBytes = soundLen * avi_file->wave_format.nBlockAlign;
    if(FAILED(AVIStreamWrite(avi_file->compressed_streams[AUDIO_STREAM],
                             avi_file->sound_samples, soundLen,
                             soundData, nBytes, 0, NULL, &avi_file->ByteBuffer)))
	{
		avi_file->valid = 0;
		return;
	}

	avi_file->sound_samples += soundLen;
	avi_file->tBytes += avi_file->ByteBuffer;
}
コード例 #19
0
ファイル: AVIGenerator.cpp プロジェクト: bestdpf/xface-error
HRESULT CAVIGenerator::AddFrame(BYTE *bmBits)
{
	HRESULT hr;

	// compress bitmap
	hr = AVIStreamWrite(m_pStreamCompressed,	// stream pointer
		m_lFrame,						// time of this frame
		1,						// number to write
		bmBits,					// image buffer
		m_bih.biSizeImage,		// size of this frame
		AVIIF_KEYFRAME,			// flags....
		NULL,
		NULL);

	// updating frame counter
	m_lFrame++;

	return hr;
}
コード例 #20
0
ファイル: AVIWrite.cpp プロジェクト: Brukwa/VisualBoyAdvance
bool AVIWrite::AddFrame(const int frame, const char *bmp)
{
  if (m_failed)
    return false;
  
  // write the frame to the video stream
  if(FAILED(AVIStreamWrite(m_streamCompressed,
                           frame,
                           1,
                           (LPVOID)bmp,
                           m_bitmap.biSizeImage,
                           AVIIF_KEYFRAME,
                           NULL,
                           NULL))) {
    m_failed = true;
    return false;
  }
  return true;
}
コード例 #21
0
bool plAVIWriterImp::ICaptureFrame(plPipeline* pipeline)
{
    plMipmap frame;
    pipeline->CaptureScreen(&frame, true);

    double time = hsTimer::GetSysSeconds() - fStartTime;
    time *= kFramesPerSec;

    HRESULT err;
    err = AVIStreamWrite(   fCompressedHandle,
                            int(time),
                            1,
                            (LPBYTE)frame.GetAddr32(0,0),
                            frame.GetTotalSize(),
                            AVIIF_KEYFRAME,
                            NULL,
                            NULL);

    return (err == AVIERR_OK);
}
コード例 #22
0
ファイル: Main.cpp プロジェクト: xmoeproject/X-moe
	/**
	 * AVIファイルにデータを記録
	 */
	void recordAVI(int frame) {
		if (pavi && pstm) {
			if (frame > lastFrame) {
				// サイズが変わってたら例外
				if (aviWidth != _width ||
					aviHeight != _height) {
					TVPThrowExceptionMessage(L"layer size has changed");
				}
				// 吉里吉里のバッファは DIB と同じ構造なのでこの処理で通る
				int size = _height * -_pitch;
				const unsigned char *buffer = _buffer + (_height-1) * _pitch;
				if (AVIStreamWrite(hasCv ? ptmp : pstm, frame, 1, (void*)buffer, size, AVIIF_KEYFRAME, NULL, NULL ) != 0) {
					TVPThrowExceptionMessage(L"AVIStreamWrite");
				}
				lastFrame = frame;
			}
		} else {
			TVPThrowExceptionMessage(L"AVI file not opened");
		}
	}
コード例 #23
0
ファイル: AVIOutput.cpp プロジェクト: SteveBeaupre/SNES9X
void AVIAddVideoFrame(void* bitmap_data, struct AVIFile* avi_out)
{
	if(!(*avi_out).valid ||
		!(*avi_out).video_added)
	{
		return;
	}

    if(FAILED(AVIStreamWrite((*avi_out).compressed_streams[VIDEO_STREAM],
                             (*avi_out).video_frames,
                             1,
                             bitmap_data,
                             (*avi_out).bitmap_format.biSizeImage,
                             AVIIF_KEYFRAME, NULL, NULL)))
	{
		(*avi_out).valid = false;
		return;
	}

	(*avi_out).video_frames++;
}
コード例 #24
0
ファイル: AVIOutput.cpp プロジェクト: SteveBeaupre/SNES9X
void AVIAddSoundSamples(void* sound_data, const int num_samples, struct AVIFile* avi_out)
{
	if(!(*avi_out).valid ||
		!(*avi_out).sound_added)
	{
		return;
	}

	int data_length = num_samples * (*avi_out).wave_format.nBlockAlign;
    if(FAILED(AVIStreamWrite((*avi_out).compressed_streams[AUDIO_STREAM],
                             (*avi_out).sound_samples,
                             num_samples,
                             sound_data,
                             data_length,
                             0, NULL, NULL)))
	{
		(*avi_out).valid = false;
		return;
	}

	(*avi_out).sound_samples += num_samples;
}
コード例 #25
0
ファイル: AviFile.cpp プロジェクト: Banbury/starshatter-open
HRESULT
AviFile::AddFrame(const Bitmap& bmp)
{
    HRESULT hr = E_FAIL;

    if (!iserr && !play && bmp.IsHighColor() && bmp.Width() == rect.w && bmp.Height() == rect.h) {
        int      w      = bmp.Width();
        int      h      = bmp.Height();
        BYTE*    buffer = new(__FILE__,__LINE__) BYTE[frame_size];
        BYTE*    dst    = buffer;

        for (int y = 0; y < bmp.Height(); y++) {
            Color* src = bmp.HiPixels()  + (h - 1 - y) * w;

            for (int x = 0; x < bmp.Width(); x++) {
                *dst++ = (BYTE) src->Blue();
                *dst++ = (BYTE) src->Green();
                *dst++ = (BYTE) src->Red();
                src++;
            }
        }

#pragma warning(suppress: 6001)
        hr = AVIStreamWrite(ps_comp, nframe, 1, buffer, frame_size, AVIIF_KEYFRAME, 0, 0);
        
        if (SUCCEEDED(hr)) {
            nframe++;
        }
        else {
            Print("AVIStreamWriteFile failed. %08x\n", hr);
            iserr = true;
        }

        delete [] buffer;
    }

    return hr;
}
コード例 #26
0
ファイル: aviout.cpp プロジェクト: snowasnow/DeSmuME
void DRV_AviVideoUpdate(const u16* buffer)
{
	if(!avi_file || !avi_file->valid)
		return;

	do_video_conversion(buffer);

    if(FAILED(AVIStreamWrite(avi_file->compressed_streams[VIDEO_STREAM],
                                 avi_file->video_frames, 1, avi_file->convert_buffer,
                                 avi_file->bitmap_format.biSizeImage, AVIIF_KEYFRAME,
                                 NULL, &avi_file->ByteBuffer)))
	{
		avi_file->valid = 0;
		return;
	}

	avi_file->video_frames++;
	avi_file->tBytes += avi_file->ByteBuffer;

	// segment / split AVI when it's almost 2 GB (2000MB, to be precise)
	if(!(avi_file->video_frames % 60) && avi_file->tBytes > 2097152000)
		AviNextSegment();
}
コード例 #27
0
ファイル: AVIOutput.cpp プロジェクト: AdmiralCurtiss/snes9x
void AVIAddSoundSamples(void* sound_data, const int num_samples, struct AVIFile* avi_out)
{
	if(!avi_out->valid ||
		!avi_out->sound_added)
	{
		return;
	}

	int data_length = num_samples * avi_out->wave_format.nBlockAlign;
    if(FAILED(AVIStreamWrite(avi_out->compressed_streams[AUDIO_STREAM],
                             avi_out->sound_samples,
                             num_samples,
                             sound_data,
                             data_length,
                             0, NULL, &avi_out->ByteBuffer)))
	{
		avi_out->valid = false;
		return;
	}

	avi_out->sound_samples += num_samples;
	avi_out->tBytes += avi_out->ByteBuffer;
}
コード例 #28
0
ファイル: AVIWrite.cpp プロジェクト: Brukwa/VisualBoyAdvance
bool AVIWrite::AddSound(const char *sound, int len)
{
  // return if we failed somewhere already
  if(m_failed)
    return false;

  int samples = len / m_soundFormat.nBlockAlign;

  if(FAILED(AVIStreamWrite(m_streamSound,
                           m_samplesSound,
                           samples,
                           (LPVOID)sound,
                           len,
                           0,
                           NULL,
                           NULL))) {
    m_failed = true;
    return false;
  }
  m_samplesSound += samples;

  return true;
}
コード例 #29
0
bool CAVIFile::AddFrame(const int frame, const char *bmp)
{
  HRESULT hr;
  
  if (!bOK)
    return false;
  
  hr = AVIStreamWrite(psCompressed,	// stream pointer
                      frame,				// time of this frame
                      1,				// number to write
                      (LPVOID)bmp,
                      bitmap.biSizeImage,	// size of this frame
                      AVIIF_KEYFRAME,
                      NULL,
                      NULL);
  if (hr != AVIERR_OK) {
    bOK = false;
    return false;
  }

  nFrames++;
  return true;
}
コード例 #30
0
ファイル: avifile.cpp プロジェクト: BuckeyeDude/Wabbitemu
HRESULT CAviFile::AppendFrameUsual(HBITMAP hBitmap)
{
	BITMAPINFO	bmpInfo;

	bmpInfo.bmiHeader.biBitCount=0;
	bmpInfo.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
	
	GetDIBits(m_hAviDC,hBitmap,0,0,NULL,&bmpInfo,DIB_RGB_COLORS);

	bmpInfo.bmiHeader.biCompression=BI_RGB;	

	GetDIBits(m_hAviDC,hBitmap,0,bmpInfo.bmiHeader.biHeight,m_lpBits,&bmpInfo,DIB_RGB_COLORS);

	if (FAILED(AVIStreamWrite(m_pAviCompressedStream, m_lVSample++, 1, m_lpBits, bmpInfo.bmiHeader.biSizeImage, 0, NULL, NULL)))
	{
		SetErrorMessage(_T("Unable to Write Video Stream to the output Movie File"));

		ReleaseMemory();

		return E_FAIL;
	}

	return S_OK;
}