コード例 #1
0
ファイル: MainFrm.cpp プロジェクト: hiccupzhu/misc_starting
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();
}
コード例 #2
0
ファイル: xvid_encraw.c プロジェクト: headhsu2568/codejam
int main(void)
{

	unsigned char *mp4_buffer = NULL;
	unsigned char *in_buffer = NULL;
	unsigned char *out_buffer = NULL;
  
	int status;
	long frame_type; 
	long m4v_size;
							
/*****************************************************************************
 *                            Arguments checking
 ****************************************************************************/

	if (XDIM <= 0 || XDIM >= 2048 || YDIM <=0 || YDIM >= 2048 ) {
		my_printf("Trying to retreive width and height from PGM header\n");
	}

	my_malloc_init(); // initial memory allocation. by gary
	input_file();   // it give input address,or open input file. by gary
	output_file();  // it give output address, or open output file . by gary

	/* now we know the sizes, so allocate memory */

	in_buffer = (unsigned char *) my_malloc(IMAGE_SIZE(XDIM,YDIM));
	if (!in_buffer)
		goto free_all_memory;

	/* this should really be enough memory ! */
	mp4_buffer = (unsigned char *) my_malloc(IMAGE_SIZE(XDIM,YDIM)*2);
	if (!mp4_buffer)
		goto free_all_memory;	

	clock_gettime(CLOCK_REALTIME, &start_time);    
/*****************************************************************************
 *                            XviD PART  Start
 ****************************************************************************/


	status = enc_init();
	if (status)    
	{ 
		my_printf("Encore INIT problem, return value %d\n", status);
		goto release_all;
	}

/*****************************************************************************
 *                       Encoding loop
 ****************************************************************************/


	do {

			/* read raw data (YUV-format) */

		my_read(in_buffer, 1, IMAGE_SIZE(XDIM, YDIM), input_add);
        input_add = input_add + IMAGE_SIZE(XDIM, YDIM);

/*****************************************************************************
 *                       Encode and decode this frame
 ****************************************************************************/

		status = enc_main(in_buffer, mp4_buffer,
						  &m4v_size, &frame_type);

		output_size += m4v_size;

		my_printf("Frame %5d: intra %1d, size=%6dbytes\n",
			   (int)filenr, (int)frame_type, (int)m4v_size);

/*****************************************************************************
 *                       Save stream to file
 ****************************************************************************/

		/* Write mp4 data */
		my_write(mp4_buffer, m4v_size, 1, output_add_temp);
		output_add_temp = output_add_temp + m4v_size;

		filenr++;

	} while ( filenr < ARG_FRAMENO );

	
      
/*****************************************************************************
 *         Calculate totals and averages for output, print results
 ****************************************************************************/

	clock_gettime(CLOCK_REALTIME, &end_time);    
	printf("sizeof(start_time.tv_sec):%d, sizeof(start_time.tv_nsec):%d\n", sizeof(start_time.tv_sec), sizeof(start_time.tv_nsec));
	printf("s_time.tv_sec:%d, s_time.tv_nsec:%d\n", start_time.tv_sec, start_time.tv_nsec);
	printf("e_time.tv_sec:%d, e_time.tv_nsec:%d\n", end_time.tv_sec, end_time.tv_nsec);
		double execution_time = (double)end_time.tv_sec + (double)end_time.tv_nsec/1000000000.0 
		- (double)start_time.tv_sec - (double)start_time.tv_nsec/1000000000.0;
	printf("diff_time:%.4f(s)\n", execution_time);

	my_memcpy(output_add,&output_size,4);
	finish_file();

	output_size    /= filenr;

	my_printf("Avg: filesize %7d bytes\n",(int)output_size);

/*****************************************************************************
 *                            XviD PART  Stop
 ****************************************************************************/

 release_all:

	if (enc_handle)
	{	
		status = enc_stop();
		if (status)    
			my_printf("Encore RELEASE problem return value %d\n", status);
	}

 free_all_memory:
	my_free(mp4_buffer);
	my_free(in_buffer);

	return 0;

}