⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 line_buf_test.c

📁 s3c6400 video code,you play video smooth with it,it is hardware codec
💻 C
📖 第 1 页 / 共 2 页
字号:
#ifdef FPS	LOG_MSG(LOG_TRACE, "Test_MPEG4_Decoder_Line_Buffer", 	\		"Decoding Time : %u, Frame Count : %d, FPS : %f\n", time, frame_cnt, (float)frame_cnt*1000/time);#endif	///////////////////////////////////////	///    7. SsbSipMPEG4DecodeDeInit    ///	///////////////////////////////////////	SsbSipMPEG4DecodeDeInit(handle);	munmap(in_addr, file_size);	LOG_MSG(LOG_TRACE, "Test_MPEG4_Decoder_Line_Buffer", "\n\n@@@ Program ends.\n");	close(in_fd);	close(out_fd);	return 0;}int Test_H263_Decoder_Line_Buffer(int argc, char **argv){	void    		*handle;	void			*pStrmBuf;	int				nFrameLeng = 0;	unsigned char	*pYUVBuf;	long			nYUVLeng;	int				in_fd, out_fd;	int				file_size;	char			*in_addr;	struct stat				s;	MMAP_STRM_PTR 			file_strm;	SSBSIP_MPEG4_STREAM_INFO stream_info;	#ifdef FPS	struct timeval	start, stop;	unsigned int	time = 0;	int				frame_cnt = 0;#endif#ifdef ROTATE_ENABLE	int				rotation_value;#endif	if (argc != 3) {		printf("Usage : mfc <H263 input filename> <output filename>\n");		return -1;	}	///////////////////////////////////	// Input/Output Stream File Open //	///////////////////////////////////	in_fd	= open(argv[1], O_RDONLY);	out_fd	= open(argv[2], O_RDWR | O_CREAT | O_TRUNC, 0644);	if( (in_fd < 0) || (out_fd < 0) ) {		LOG_MSG(LOG_ERROR, "Test_MPEG4_Decoder_Line_Buffer", "Input/Output file open failed\n");		return -1;	}	// get input file size	fstat(in_fd, &s);	file_size = s.st_size;	// Input file should be mapped with memory. 	// because file operations have a lot of performance down.	// So, I Strongly recommend you to use mmap() of input file.	in_addr = (char *)mmap(0, file_size, PROT_READ, MAP_SHARED, in_fd, 0);	if(in_addr == NULL) {		LOG_MSG(LOG_ERROR, "Test_MPEG4_Decoder_Line_Buffer", "Mmap of Input file was failed\n");		return -1;	}	//////////////////////////////////////	///    1. Create new instance      ///	///      (SsbSipMPEG4DecodeInit)   ///	//////////////////////////////////////	handle = SsbSipMPEG4DecodeInit();	if (handle == NULL) {		LOG_MSG(LOG_ERROR, "Test_H263_Decoder_Line_Buffer", "MPEG4_Dec_Init Failed.\n");		return -1;	}	/////////////////////////////////////////////	///    2. Obtaining the Input Buffer      ///	///      (SsbSipMPEG4DecodeGetInBuf)       ///	/////////////////////////////////////////////	pStrmBuf = SsbSipMPEG4DecodeGetInBuf(handle, 200000);	if (pStrmBuf == NULL) {		LOG_MSG(LOG_ERROR, "Test_H263_Decoder_Line_Buffer", "SsbSipMPEG4DecodeGetInBuf Failed.\n");		SsbSipMPEG4DecodeDeInit(handle);		return -1;	}	////////////////////////////////////	// H263 CONFIG stream extraction  //	////////////////////////////////////	file_strm.p_start = file_strm.p_cur = (unsigned char *)in_addr;	file_strm.p_end = (unsigned char *)(in_addr + file_size);	nFrameLeng = ExtractConfigStreamH263(&file_strm, pStrmBuf, INPUT_BUFFER_SIZE, NULL);	////////////////////////////////////	//	Rotation Test				  //	////////////////////////////////////#ifdef ROTATE_ENABLE	rotation_value = 0x11;	SsbSipMPEG4DecodeSetConfig(handle, MPEG4_DEC_SETCONF_POST_ROTATE, &rotation_value);#endif	////////////////////////////////////////////////////////////////	///    3. Configuring the instance with the config stream    ///	///       (SsbSipMPEG4DecodeExe)                             ///	////////////////////////////////////////////////////////////////	if (SsbSipMPEG4DecodeExe(handle, nFrameLeng) != SSBSIP_MPEG4_DEC_RET_OK) {		LOG_MSG(LOG_ERROR, "Test_H263_Decoder_Line_Buffer", "MPEG4 Decoder Configuration Failed.\n");		return -1;	}	/////////////////////////////////////	///   4. Get stream information   ///	/////////////////////////////////////	SsbSipMPEG4DecodeGetConfig(handle, MPEG4_DEC_GETCONF_STREAMINFO, &stream_info);	LOG_MSG(LOG_TRACE, "Test_H263_Decoder_Line_Buffer", "\t<STREAMINFO> width=%d   height=%d.\n", stream_info.width, stream_info.height);	while(1) {	#ifdef FPS		gettimeofday(&start, NULL);	#endif			//////////////////////////////////		///       5. DECODE            ///		///    (SsbSipMPEG4DecodeExe)   ///		//////////////////////////////////		if (SsbSipMPEG4DecodeExe(handle, nFrameLeng) != SSBSIP_MPEG4_DEC_RET_OK)			break;	#ifdef FPS		gettimeofday(&stop, NULL);		time += measureTime(&start, &stop);		frame_cnt++;	#endif		//////////////////////////////////////////////		///    6. Obtaining the Output Buffer      ///		///      (SsbSipMPEG4DecodeGetOutBuf)       ///		//////////////////////////////////////////////		pYUVBuf = SsbSipMPEG4DecodeGetOutBuf(handle, &nYUVLeng);	#ifndef FPS		write(out_fd, pYUVBuf, (stream_info.width * stream_info.height * 3) >> 1);	#endif			/////////////////////////////		// Next H.264 VIDEO stream //		/////////////////////////////		nFrameLeng = NextFrameH263(&file_strm, pStrmBuf, INPUT_BUFFER_SIZE, NULL);		if (nFrameLeng < 4)			break;	}#ifdef FPS	LOG_MSG(LOG_TRACE, "Test_H263_Decoder_Line_Buffer", 	\		"Decoding Time : %u, Frame Count : %d, FPS : %f\n", time, frame_cnt, (float)frame_cnt*1000/time);#endif	///////////////////////////////////////	///    7. SsbSipMPEG4DecodeDeInit    ///	///////////////////////////////////////	SsbSipMPEG4DecodeDeInit(handle);	munmap(in_addr, file_size);		LOG_MSG(LOG_TRACE, "Test_H263_Decoder_Line_Buffer", "\n\n@@@ Program ends.\n");	close(in_fd);	close(out_fd);	return 0;}int Test_VC1_Decoder_Line_Buffer(int argc, char **argv){	void    		*handle;	void			*pStrmBuf;	int				nFrameLeng = 0;	unsigned char	*pYUVBuf;	long			nYUVLeng;	int				in_fd, out_fd;	int				file_size;	char			*in_addr;	struct stat				s;	MMAP_STRM_PTR 			file_strm;	SSBSIP_MPEG4_STREAM_INFO stream_info;	#ifdef FPS	struct timeval	start, stop;	unsigned int	time = 0;	int				frame_cnt = 0;#endif#ifdef ROTATE_ENABLE	int				rotation_value;#endif	if (argc != 3) {		printf("Usage : mfc <VC-1 input filename> <output filename>\n");		return -1;	}	///////////////////////////////////	// Input/Output Stream File Open //	///////////////////////////////////	in_fd	= open(argv[1], O_RDONLY);	out_fd	= open(argv[2], O_RDWR | O_CREAT | O_TRUNC, 0644);	if( (in_fd < 0) || (out_fd < 0) ) {		LOG_MSG(LOG_ERROR, "Test_MPEG4_Decoder_Line_Buffer", "Input/Output file open failed\n");		return -1;	}	// get input file size	fstat(in_fd, &s);	file_size = s.st_size;	// Input file should be mapped with memory. 	// because file operations have a lot of performance down.	// So, I Strongly recommend you to use mmap() of input file.	in_addr = (char *)mmap(0, file_size, PROT_READ, MAP_SHARED, in_fd, 0);	if(in_addr == NULL) {		LOG_MSG(LOG_ERROR, "Test_MPEG4_Decoder_Line_Buffer", "Mmap of Input file was failed\n");		return -1;	}	//////////////////////////////////////	///    1. Create new instance      ///	///      (SsbSipVC1DecodeInit)     ///	//////////////////////////////////////	handle = SsbSipVC1DecodeInit();	if (handle == NULL) {		LOG_MSG(LOG_ERROR, "Test_VC1_Decoder_Line_Buffer", "VC1_Dec_Init Failed.\n");		return -1;	}	/////////////////////////////////////////////	///    2. Obtaining the Input Buffer      ///	///      (SsbSipVC1DecodeGetInBuf)       ///	/////////////////////////////////////////////	pStrmBuf = SsbSipVC1DecodeGetInBuf(handle, 200000);	if (pStrmBuf == NULL) {		LOG_MSG(LOG_ERROR, "Test_VC1_Decoder_Line_Buffer", "SsbSipVC1DecodeGetInBuf Failed.\n");		SsbSipVC1DecodeDeInit(handle);		return -1;	}	////////////////////////////////////	// H263 CONFIG stream extraction  //	////////////////////////////////////	file_strm.p_start = file_strm.p_cur = (unsigned char *)in_addr;	file_strm.p_end = (unsigned char *)(in_addr + file_size);	nFrameLeng = ExtractConfigStreamVC1(&file_strm, pStrmBuf, INPUT_BUFFER_SIZE, NULL);	////////////////////////////////////	//	Rotation Test				  //	////////////////////////////////////#ifdef ROTATE_ENABLE	rotation_value = 0x11;	SsbSipVC1DecodeSetConfig(handle, VC1_DEC_SETCONF_POST_ROTATE, &rotation_value);#endif	////////////////////////////////////////////////////////////////	///    3. Configuring the instance with the config stream    ///	///       (SsbSipVC1DecodeExe)                             ///	////////////////////////////////////////////////////////////////	if (SsbSipVC1DecodeExe(handle, nFrameLeng) != SSBSIP_VC1_DEC_RET_OK) {		LOG_MSG(LOG_ERROR, "Test_VC1_Decoder_Line_Buffer", "VC1 Decoder Configuration Failed.\n");		return -1;	}	/////////////////////////////////////	///   4. Get stream information   ///	/////////////////////////////////////	SsbSipVC1DecodeGetConfig(handle, VC1_DEC_GETCONF_STREAMINFO, &stream_info);	LOG_MSG(LOG_TRACE, "Test_VC1_Decoder_Line_Buffer", "\t<STREAMINFO> width=%d   height=%d.\n", stream_info.width, stream_info.height);	while(1) {	#ifdef FPS		gettimeofday(&start, NULL);	#endif			//////////////////////////////////		///       5. DECODE            ///		///    (SsbSipVC1DecodeExe)    ///		//////////////////////////////////		if (SsbSipVC1DecodeExe(handle, nFrameLeng) != SSBSIP_VC1_DEC_RET_OK)			break;	#ifdef FPS		gettimeofday(&stop, NULL);		time += measureTime(&start, &stop);		frame_cnt++;	#endif		//////////////////////////////////////////////		///    6. Obtaining the Output Buffer      ///		///      (SsbSipVC1DecodeGetOutBuf)       ///		//////////////////////////////////////////////		pYUVBuf = SsbSipVC1DecodeGetOutBuf(handle, &nYUVLeng);	#ifndef FPS		write(out_fd, pYUVBuf, (stream_info.width * stream_info.height * 3) >> 1);	#endif			/////////////////////////////		// Next VC-1 VIDEO stream  //		/////////////////////////////		nFrameLeng = NextFrameVC1(&file_strm, pStrmBuf, INPUT_BUFFER_SIZE, NULL);		if (nFrameLeng < 4)			break;	}#ifdef FPS	LOG_MSG(LOG_TRACE, "Test_H263_Decoder_Line_Buffer", 	\		"Decoding Time : %u, Frame Count : %d, FPS : %f\n", time, frame_cnt, (float)frame_cnt*1000/time);#endif	///////////////////////////////////////	///    7. SsbSipMPEG4DecodeDeInit    ///	///////////////////////////////////////	SsbSipVC1DecodeDeInit(handle);	munmap(in_addr, file_size);		LOG_MSG(LOG_TRACE, "Test_VC1_Decoder_Line_Buffer", "\n\n@@@ Program ends.\n");	close(in_fd);	close(out_fd);	return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -