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

📄 demo.c

📁 s3c6400 video code,you play video smooth with it,it is hardware codec
💻 C
📖 第 1 页 / 共 2 页
字号:
	pp_param4.DstFullHeight	= 240;		// destination height	pp_param4.DstCSpace		= RGB16;	pp_param4.OutPath		= POST_DMA;	pp_param4.Mode			= ONE_SHOT;	// get LCD frame buffer address	fb_size = pp_param.DstFullWidth * pp_param.DstFullHeight * 2;	// RGB565	fb_addr = (char *)mmap(0, fb_size, PROT_READ | PROT_WRITE, MAP_SHARED, fb_fd, 0);	if (fb_addr == NULL) {		printf("LCD frame buffer mmap failed\n");		return -1;	}	// get LCD frame buffer address	fb_size2 = pp_param2.DstFullWidth * pp_param2.DstFullHeight * 2;	// RGB565	fb_addr2 = (char *)mmap(0, fb_size2, PROT_READ | PROT_WRITE, MAP_SHARED, fb_fd2, 0);	if (fb_addr2 == NULL) {		printf("LCD frame buffer mmap failed\n");		return -1;	}	// get LCD frame buffer address	fb_size3 = pp_param3.DstFullWidth * pp_param3.DstFullHeight * 2;	// RGB565	fb_addr3 = (char *)mmap(0, fb_size3, PROT_READ | PROT_WRITE, MAP_SHARED, fb_fd3, 0);	if (fb_addr3 == NULL) {		printf("LCD frame buffer mmap failed\n");		return -1;	}	// get LCD frame buffer address	fb_size4 = pp_param4.DstFullWidth * pp_param4.DstFullHeight * 2;	// RGB565	fb_addr4 = (char *)mmap(0, fb_size4, PROT_READ | PROT_WRITE, MAP_SHARED, fb_fd4, 0);	if (fb_addr4 == NULL) {		printf("LCD frame buffer mmap failed\n");		return -1;	}	osd_info_to_driver.Bpp			= 16;	// RGB16	osd_info_to_driver.LeftTop_x	= 0;		osd_info_to_driver.LeftTop_y	= 0;	osd_info_to_driver.Width		= 400;	// display width	osd_info_to_driver.Height		= 240;	// display height	osd_info_to_driver2.Bpp			= 16;	// RGB16	osd_info_to_driver2.LeftTop_x	= 400;		osd_info_to_driver2.LeftTop_y	= 0;	osd_info_to_driver2.Width		= 400;	// display width	osd_info_to_driver2.Height		= 240;	// display height	osd_info_to_driver3.Bpp			= 16;	// RGB16	osd_info_to_driver3.LeftTop_x	= 0;		osd_info_to_driver3.LeftTop_y	= 240;	osd_info_to_driver3.Width		= 400;	// display width	osd_info_to_driver3.Height		= 240;	// display height	osd_info_to_driver4.Bpp			= 16;	// RGB16	osd_info_to_driver4.LeftTop_x	= 400;		osd_info_to_driver4.LeftTop_y	= 240;	osd_info_to_driver4.Width		= 400;	// display width	osd_info_to_driver4.Height		= 240;	// display height	if(ioctl(fb_fd, SET_OSD_INFO, &osd_info_to_driver)) {		printf("Some problem with the ioctl SET_OSD_INFO\n");		return -1;	}	// set OSD's information 	if(ioctl(fb_fd2, SET_OSD_INFO, &osd_info_to_driver2)) {		printf("Some problem with the ioctl SET_OSD_INFO\n");		return -1;	}	// set OSD's information 	if(ioctl(fb_fd3, SET_OSD_INFO, &osd_info_to_driver3)) {		printf("Some problem with the ioctl SET_OSD_INFO\n");		return -1;	}	// set OSD's information 	if(ioctl(fb_fd4, SET_OSD_INFO, &osd_info_to_driver4)) {		printf("Some problem with the ioctl SET_OSD_INFO\n");		return -1;	}	ioctl(fb_fd, SET_OSD_START);	ioctl(fb_fd2, SET_OSD_START);	ioctl(fb_fd3, SET_OSD_START);	ioctl(fb_fd4, SET_OSD_START);	while(1)	{				dec_exe2.in_strmSize = nStrmSize;		r = ioctl(mfc_fd2, IOCTL_MFC_MPEG4_DEC_EXE, &dec_exe2);		if ( (r < 0) || (dec_exe2.ret_code < 0) ) {			if (get_buf_addr2.ret_code == MFCDRV_RET_ERR_HANDLE_INVALIDATED) {				printf("The Handle of MFC Instance was invalidated!!!\n"); 			}			printf("IOCTL_MFC_MPEG4_DEC_EXE failure...\n");			printf("ret_code : %d, r : %d\n", get_buf_addr2.ret_code, r);			return -1;		}				nStrmSize = NextFrameMpeg4(pFrameExCtx2, &file_strm2, (unsigned char *)pStrmBuf, VIDEO_BUFFER_SIZE, NULL);		if (nStrmSize < 4) {			break;		}		//printf("nStrmSize = %d\n", nStrmSize);				if(nStrmSize == 5) {			printf("nStrmSize == 0\n");			file_strm2.p_start 	= file_strm2.p_cur = (unsigned char *)in_addr2;			file_strm2.p_end	= (unsigned char *)(in_addr2 + file_size2);			FrameExtractorFirst(pFrameExCtx2, &file_strm2);			nStrmSize = ExtractConfigStreamMpeg4(pFrameExCtx2, &file_strm2, (unsigned char *)pStrmBuf, VIDEO_BUFFER_SIZE, NULL);			continue;					}		//////////////////////////////////		//		(MFC ioctl)				//		//	IOCTL_MFC_GET_LINE_BUF_ADDR	//		//////////////////////////////////		get_buf_addr2.in_usr_data = (int)addr2;		r = ioctl(mfc_fd2, IOCTL_MFC_GET_LINE_BUF_ADDR, &get_buf_addr2);		if ( (r < 0) || (get_buf_addr2.ret_code < 0) ) {			if (get_buf_addr2.ret_code == MFCDRV_RET_ERR_HANDLE_INVALIDATED) {				printf("The Handle of MFC Instance was invalidated!!!\n"); 			}			printf("IOCTL_MFC_GET_LINE_BUF_ADDR failure...\n");			return -1;		}				memcpy((char *)get_buf_addr2.out_buf_addr, pStrmBuf, nStrmSize);						//////////////////////////////////		//		(MFC ioctl				//		//	IOCTL_MFC_GET_FRAM_BUF_ADDR	//		//////////////////////////////////		ioctl(mfc_fd2, IOCTL_MFC_GET_PHY_FRAM_BUF_ADDR, &get_buf_addr2);				// Post processing		// pp_param.SrcFrmSt俊绰 MFC狼 output buffer狼 physical address啊		// pp_param.DstFrmSt俊绰 LCD frame buffer狼 physical address啊 涝仿栏肺 持绢具 茄促.		pp_param2.SrcFrmSt		= get_buf_addr2.out_buf_addr;	// MFC output buffer		ioctl(fb_fd2, FBIOGET_FSCREENINFO, &lcd_info2);		pp_param2.DstFrmSt		= lcd_info2.smem_start;			// LCD frame buffer		ioctl(pp_fd, PPROC_SET_PARAMS, &pp_param2);		ioctl(pp_fd, PPROC_START);		///////////////////////////////////////////////////////////////////////////////////////////////		dec_exe3.in_strmSize = nStrmSize3;		r3 = ioctl(mfc_fd3, IOCTL_MFC_MPEG4_DEC_EXE, &dec_exe3);		if ( (r3 < 0) || (dec_exe3.ret_code < 0) ) {			if (get_buf_addr3.ret_code == MFCDRV_RET_ERR_HANDLE_INVALIDATED) {				printf("The Handle of MFC Instance was invalidated!!!\n"); 			}			printf("IOCTL_MFC_MPEG4_DEC_EXE failure...\n");			printf("ret_code : %d, r : %d\n", get_buf_addr3.ret_code, r3);			return -1;		}				nStrmSize3 = NextFrameMpeg4(pFrameExCtx3, &file_strm3, (unsigned char *)pStrmBuf3, VIDEO_BUFFER_SIZE, NULL);		if (nStrmSize3 < 4) {			break;		}		//printf("nStrmSize3 = %d\n", nStrmSize3);				if(nStrmSize3 == 72) {			printf("nStrmSize == 0\n");			file_strm3.p_start 	= file_strm3.p_cur = (unsigned char *)in_addr3;			file_strm3.p_end	= (unsigned char *)(in_addr3 + file_size3);			FrameExtractorFirst(pFrameExCtx3, &file_strm3);			nStrmSize3 = ExtractConfigStreamMpeg4(pFrameExCtx3, &file_strm3, (unsigned char *)pStrmBuf3, VIDEO_BUFFER_SIZE, NULL);			continue;					}		//////////////////////////////////		//		(MFC ioctl)				//		//	IOCTL_MFC_GET_LINE_BUF_ADDR	//		//////////////////////////////////		get_buf_addr3.in_usr_data = (int)addr3;		r3 = ioctl(mfc_fd3, IOCTL_MFC_GET_LINE_BUF_ADDR, &get_buf_addr3);		if ( (r3 < 0) || (get_buf_addr3.ret_code < 0) ) {			if (get_buf_addr3.ret_code == MFCDRV_RET_ERR_HANDLE_INVALIDATED) {				printf("The Handle of MFC Instance was invalidated!!!\n"); 			}			printf("IOCTL_MFC_GET_LINE_BUF_ADDR failure...\n");			return -1;		}				memcpy((char *)get_buf_addr3.out_buf_addr, pStrmBuf3, nStrmSize3);						//////////////////////////////////		//		(MFC ioctl				//		//	IOCTL_MFC_GET_FRAM_BUF_ADDR	//		//////////////////////////////////		ioctl(mfc_fd3, IOCTL_MFC_GET_PHY_FRAM_BUF_ADDR, &get_buf_addr3);				// Post processing		// pp_param.SrcFrmSt俊绰 MFC狼 output buffer狼 physical address啊		// pp_param.DstFrmSt俊绰 LCD frame buffer狼 physical address啊 涝仿栏肺 持绢具 茄促.		pp_param3.SrcFrmSt		= get_buf_addr3.out_buf_addr;	// MFC output buffer		ioctl(fb_fd3, FBIOGET_FSCREENINFO, &lcd_info3);		pp_param3.DstFrmSt		= lcd_info3.smem_start;			// LCD frame buffer		ioctl(pp_fd, PPROC_SET_PARAMS, &pp_param3);		ioctl(pp_fd, PPROC_START);			////////////////////////////////////////////////////////////////////////		dec_exe4.in_strmSize = nStrmSize4;		r4 = ioctl(mfc_fd4, IOCTL_MFC_H264_DEC_EXE, &dec_exe4);		if ( (r4 < 0) || (dec_exe4.ret_code < 0) ) {			if (get_buf_addr4.ret_code == MFCDRV_RET_ERR_HANDLE_INVALIDATED) {				printf("The Handle of MFC Instance was invalidated!!!\n"); 			}			printf("IOCTL_MFC_H264_DEC_EXE failure...\n");			printf("ret_code : %d, r : %d\n", get_buf_addr4.ret_code, r4);			return -1;		}				nStrmSize4 = NextFrameH264(pFrameExCtx4, &file_strm4, (unsigned char *)pStrmBuf4, VIDEO_BUFFER_SIZE, NULL);		if (nStrmSize4 < 4) {			break;		}		//printf("nStrmSize4 = %d\n", nStrmSize4);				if(nStrmSize4 == 142) {			printf("nStrmSize == 0\n");			file_strm4.p_start 	= file_strm4.p_cur = (unsigned char *)in_addr4;			file_strm4.p_end	= (unsigned char *)(in_addr4 + file_size4);			FrameExtractorFirst(pFrameExCtx4, &file_strm4);			nStrmSize4 = ExtractConfigStreamH264(pFrameExCtx4, &file_strm4, (unsigned char *)pStrmBuf4, VIDEO_BUFFER_SIZE, NULL);			continue;					}		//////////////////////////////////		//		(MFC ioctl)				//		//	IOCTL_MFC_GET_LINE_BUF_ADDR	//		//////////////////////////////////		get_buf_addr4.in_usr_data = (int)addr4;		r4 = ioctl(mfc_fd4, IOCTL_MFC_GET_LINE_BUF_ADDR, &get_buf_addr4);		if ( (r4 < 0) || (get_buf_addr4.ret_code < 0) ) {			if (get_buf_addr4.ret_code == MFCDRV_RET_ERR_HANDLE_INVALIDATED) {				printf("The Handle of MFC Instance was invalidated!!!\n"); 			}			printf("IOCTL_MFC_GET_LINE_BUF_ADDR failure...\n");			return -1;		}				memcpy((char *)get_buf_addr4.out_buf_addr, pStrmBuf4, nStrmSize4);						//////////////////////////////////		//		(MFC ioctl				//		//	IOCTL_MFC_GET_FRAM_BUF_ADDR	//		//////////////////////////////////		ioctl(mfc_fd4, IOCTL_MFC_GET_PHY_FRAM_BUF_ADDR, &get_buf_addr4);				// Post processing		// pp_param.SrcFrmSt俊绰 MFC狼 output buffer狼 physical address啊		// pp_param.DstFrmSt俊绰 LCD frame buffer狼 physical address啊 涝仿栏肺 持绢具 茄促.		pp_param4.SrcFrmSt		= get_buf_addr4.out_buf_addr;	// MFC output buffer		ioctl(fb_fd4, FBIOGET_FSCREENINFO, &lcd_info4);		pp_param4.DstFrmSt		= lcd_info4.smem_start;			// LCD frame buffer		ioctl(pp_fd, PPROC_SET_PARAMS, &pp_param4);		ioctl(pp_fd, PPROC_START);			////////////////////////////////////////////////////////////////////////				// if input stream		get_buf_addr.in_usr_data = (int)addr;		ioctl(mfc_fd, IOCTL_MFC_GET_RING_BUF_ADDR, &get_buf_addr);		if(get_buf_addr.out_buf_size > 0) {			if((file_pos_end - file_pos_cur) >= get_buf_addr.out_buf_size) {				memcpy((char *)get_buf_addr.out_buf_addr, file_pos_cur, get_buf_addr.out_buf_size);				file_pos_cur += get_buf_addr.out_buf_size;				dec_exe.in_strmSize = get_buf_addr.out_buf_size;			} else {	// if last unit				last_unit_size = in_addr + file_size - file_pos_cur;				memcpy((char *)get_buf_addr.out_buf_addr, file_pos_cur, last_unit_size);				memcpy((char *)get_buf_addr.out_buf_addr + last_unit_size, in_addr, get_buf_addr.out_buf_size - last_unit_size);				file_pos_cur = in_addr + get_buf_addr.out_buf_size - last_unit_size;				dec_exe.in_strmSize = get_buf_addr.out_buf_size;			}		}		else {			dec_exe.in_strmSize = 0;		}	#ifdef FPS		gettimeofday(&start, NULL);	#endif		// MFC decoding		ioctl(mfc_fd, IOCTL_MFC_H264_DEC_EXE, &dec_exe);		if(dec_exe.ret_code < 0) {			printf("ret code : %d\n", dec_exe.ret_code);			break;		}	#ifdef FPS		gettimeofday(&stop, NULL);		time += measureTime(&start, &stop);		frame_cnt++;	#endif		// get output buffer address		ioctl(mfc_fd, IOCTL_MFC_GET_PHY_FRAM_BUF_ADDR, &get_buf_addr);				// Post processing		// pp_param.SrcFrmSt俊绰 MFC狼 output buffer狼 physical address啊		// pp_param.DstFrmSt俊绰 LCD frame buffer狼 physical address啊 涝仿栏肺 持绢具 茄促.		pp_param.SrcFrmSt		= get_buf_addr.out_buf_addr;	// MFC output buffer		ioctl(fb_fd, FBIOGET_FSCREENINFO, &lcd_info);		pp_param.DstFrmSt		= lcd_info.smem_start;			// LCD frame buffer		ioctl(pp_fd, PPROC_SET_PARAMS, &pp_param);		ioctl(pp_fd, PPROC_START);				//printf("LCD1 ADDR : 0x%X,  LCD2 ADDR : 0x%X\n", lcd_info.smem_start, lcd_info2.smem_start);			}#ifdef FPS	printf("Decoding Time : %u, Frame Count : %d, FPS : %f\n", time, frame_cnt, (float)frame_cnt*1000/time);#endif	munmap(in_addr, file_size);	munmap(in_addr2, file_size2);	munmap(in_addr3, file_size3);	munmap(in_addr4, file_size4);	munmap(addr, BUF_SIZE);	munmap(addr2, BUF_SIZE);	munmap(addr3, BUF_SIZE);	munmap(addr4, BUF_SIZE);	munmap(fb_addr, fb_size);	munmap(fb_addr2, fb_size2);	munmap(fb_addr3, fb_size3);	munmap(fb_addr4, fb_size4);			close(mfc_fd);	close(mfc_fd2);	close(mfc_fd3);	close(mfc_fd4);	close(pp_fd);	close(fb_fd);	close(fb_fd2);	close(fb_fd3);	close(fb_fd4);	close(in_fd);	close(in_fd2);	close(in_fd3);	close(in_fd4);	return 0;}

⌨️ 快捷键说明

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