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

📄 actionsfb_output.c

📁 h263解码程序.。。。。。。。。。。。
💻 C
字号:
/*
  Test h264 decoder from Northen Acts

  by	John
  since 2006.7.7
*/

#include <stdio.h>#include <sys/ioctl.h>#include <unistd.h>#include <fcntl.h>#include <sys/mman.h>   /*mmap*/#include <malloc.h>#include "actionsfb.h"

//#include "test_local.h"

#define MEMIOGET_PHY_ADDR 0x40046d01#define MEMIOGET_DATA_LEN 0x40046d02

int fd_act_mem, len_act_mem, phy_base_act_mem;
unsigned char *vo_buf;
int fd_fb;

frame_info_t frame_info;

int get_FB_MEM()
{
	/*init act mem*/	fd_act_mem=open("/dev/act_mem",O_RDWR);	ioctl(fd_act_mem,MEMIOGET_DATA_LEN,&len_act_mem);	ioctl(fd_act_mem,MEMIOGET_PHY_ADDR,(unsigned long)&phy_base_act_mem);
	vo_buf=(unsigned char *)mmap(0,len_act_mem,PROT_READ|PROT_WRITE,MAP_SHARED,fd_act_mem,0);
	
}
int initDisplay(int i_with, int i_height){

	
	//init frame buffer
	fd_fb=open("/dev/fb", O_RDWR);			if(fd_fb<0){				printf("open framebuffer errror\n");		exit(0);	}
	ioctl (fd_fb,FBIOSET_START_VIDEO,0);	
	frame_info.x=0;	frame_info.y=0;	frame_info.width=i_with;
	frame_info.height=i_height;
	frame_info.length=i_with*i_height*2;
	frame_info.color_mod=1;
	ioctl(fd_fb,FBIOSET_CANVAS_MODE,&frame_info);
	ioctl(fd_fb,FBIOSET_VIDEO_MODE,&frame_info);
	
	return 0;
}



typedef unsigned char U8;
typedef unsigned long U32;
typedef signed char I8;
typedef signed long I32;
int depitch_and_format_YUV12(
	U8 *pYPlane,
	U8 *pVPlane,
	U8 *pUPlane,
	U32 lumaWidth,
	U32 lumaHeight,
	U32 lumaPitch,
	U32 chromaPitch,
	U8 *pOut)
{
	unsigned int *int_dst_1 = (unsigned int*)pOut;
	unsigned int *int_dst_2 = (unsigned int*)(pOut+2*lumaWidth);
	unsigned int i,j;
	unsigned int *src_y1,*src_y2,*src_cb,*src_cr;
	int cb,cr;

	
	src_y1=(unsigned int*)pYPlane;
	src_y2=src_y1+(lumaPitch>>2);
	src_cb = (unsigned int*)pUPlane;
	src_cr = (unsigned int*)pVPlane;
	
	lumaPitch = (lumaPitch+lumaPitch-lumaWidth)>>2;
	chromaPitch = (chromaPitch - (lumaWidth>>1))>>2;
	
	for(i=0;i<lumaHeight;i+=2)
	{
		for(j=0;j<lumaWidth;j+=8)
		{

			*int_dst_1++ = *src_y1++;
			*int_dst_1++ = cb = *src_cb++;			
			*int_dst_1++ = *src_y1++;
			*int_dst_1++ = cr = *src_cr++;			
			
			*int_dst_2++ = *src_y2++;
			*int_dst_2++ = cb;		
			*int_dst_2++ = *src_y2++;
			*int_dst_2++ = cr;
		
		}
		src_y1+=lumaPitch;
		src_y2+=lumaPitch;
		src_cb+=chromaPitch;
		src_cr+=chromaPitch;
		int_dst_1 += lumaWidth>>1;
		int_dst_2 += lumaWidth>>1;
	}
	return 0;

}





int displayImage()
{
					
	ioctl (fd_fb,FBIOSET_UPDATE_VIDEO,(unsigned int)phy_base_act_mem); 
	return 0;
}

int displayOver()
{
		munmap(vo_buf,len_act_mem);
		close(fd_fb);
}

⌨️ 快捷键说明

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