📄 display_test.c
字号:
munmap(in_addr, file_size); munmap(fb_addr, fb_size); close(pp_fd); close(fb_fd); close(in_fd); return 0;}int Test_Display_H263(int argc, char **argv){ void *pStrmBuf; int nFrameLeng = 0; unsigned int pYUVBuf[2]; struct stat s; MMAP_STRM_PTR file_strm; SSBSIP_H264_STREAM_INFO stream_info; pp_params pp_param; s3c_win_info_t osd_info_to_driver; struct fb_fix_screeninfo lcd_info; #ifdef FPS struct timeval start, stop; unsigned int time = 0; int frame_cnt = 0;#endif if(signal(SIGINT, sig_del_mpeg4) == SIG_ERR) { printf("Sinal Error\n"); } if (argc != 2) { printf("Usage : mfc <H263 input filename>\n"); return -1; } // in file open in_fd = open(argv[1], O_RDONLY); if(in_fd < 0) { printf("Input file open failed\n"); return -1; } // get input file size fstat(in_fd, &s); file_size = s.st_size; // mapping input file to memory in_addr = (char *)mmap(0, file_size, PROT_READ, MAP_SHARED, in_fd, 0); if(in_addr == NULL) { printf("input file memory mapping failed\n"); return -1; } // Post processor open pp_fd = open(PP_DEV_NAME, O_RDWR|O_NDELAY); if(pp_fd < 0) { printf("Post processor open error\n"); return -1; } // LCD frame buffer open fb_fd = open(FB_DEV_NAME, O_RDWR|O_NDELAY); if(fb_fd < 0) { printf("LCD frame buffer open error\n"); return -1; } ////////////////////////////////////// /// 1. Create new instance /// /// (SsbSipMPEG4DecodeInit) /// ////////////////////////////////////// handle = SsbSipMPEG4DecodeInit(); if (handle == NULL) { printf("H263_Dec_Init Failed.\n"); return -1; } ///////////////////////////////////////////// /// 2. Obtaining the Input Buffer /// /// (SsbSipMPEG4DecodeGetInBuf) /// ///////////////////////////////////////////// pStrmBuf = SsbSipMPEG4DecodeGetInBuf(handle, 200000); if (pStrmBuf == NULL) { printf("SsbSipMPEG4DecodeGetInBuf Failed.\n"); SsbSipMPEG4DecodeDeInit(handle); return -1; } //////////////////////////////////// // MPEG4 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); //////////////////////////////////////////////////////////////// /// 3. Configuring the instance with the config stream /// /// (SsbSipMPEG4DecodeExe) /// //////////////////////////////////////////////////////////////// if (SsbSipMPEG4DecodeExe(handle, nFrameLeng) != SSBSIP_MPEG4_DEC_RET_OK) { printf("H.263 Decoder Configuration Failed.\n"); return -1; } ///////////////////////////////////// /// 4. Get stream information /// ///////////////////////////////////// SsbSipMPEG4DecodeGetConfig(handle, MPEG4_DEC_GETCONF_STREAMINFO, &stream_info); printf("\t<STREAMINFO> width=%d height=%d.\n", stream_info.width, stream_info.height); // set post processor configuration pp_param.SrcFullWidth = stream_info.width; pp_param.SrcFullHeight = stream_info.height; pp_param.SrcCSpace = YC420; pp_param.DstFullWidth = 800; // destination width pp_param.DstFullHeight = 480; // destination height pp_param.DstCSpace = RGB16;#ifdef RGB24BPP pp_param.DstCSpace = RGB24;#endif pp_param.OutPath = POST_DMA; pp_param.Mode = ONE_SHOT; // get LCD frame buffer address fb_size = pp_param.DstFullWidth * pp_param.DstFullHeight * 2; // RGB565#ifdef RGB24BPP fb_size = pp_param.DstFullWidth * pp_param.DstFullHeight * 4; // RGB888#endif 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; } osd_info_to_driver.Bpp = 16; // RGB16#ifdef RGB24BPP osd_info_to_driver.Bpp = 24; // RGB24#endif osd_info_to_driver.LeftTop_x = 0; osd_info_to_driver.LeftTop_y = 0; osd_info_to_driver.Width = 800; // display width osd_info_to_driver.Height = 480; // display height // set OSD's information if(ioctl(fb_fd, SET_OSD_INFO, &osd_info_to_driver)) { printf("Some problem with the ioctl SET_OSD_INFO\n"); return -1; } ioctl(fb_fd, SET_OSD_START); while(1) { #ifdef FPS gettimeofday(&start, NULL); #endif ////////////////////////////////// /// 5. DECODE /// /// (SsbSipMPEG4DecodeExe) /// ////////////////////////////////// if (SsbSipMPEG4DecodeExe(handle, nFrameLeng) != SSBSIP_MPEG4_DEC_RET_OK) break; ////////////////////////////////////////////// /// 6. Obtaining the Output Buffer /// /// (SsbSipMPEG4DecodeGetOutBuf) /// ////////////////////////////////////////////// SsbSipMPEG4DecodeGetConfig(handle, MPEG4_DEC_GETCONF_PHYADDR_FRAM_BUF, pYUVBuf); ///////////////////////////// // Next MPEG4 VIDEO stream // ///////////////////////////// nFrameLeng = NextFrameH263(&file_strm, pStrmBuf, INPUT_BUFFER_SIZE, NULL); if (nFrameLeng < 4) break; // Post processing // pp_param.SrcFrmSt俊绰 MFC狼 output buffer狼 physical address啊 // pp_param.DstFrmSt俊绰 LCD frame buffer狼 physical address啊 涝仿栏肺 持绢具 茄促. pp_param.SrcFrmSt = pYUVBuf[0]; // 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); #ifdef FPS gettimeofday(&stop, NULL); time += measureTime(&start, &stop); frame_cnt++; #endif }#ifdef FPS printf("Display Time : %u, Frame Count : %d, FPS : %f\n", time, frame_cnt, (float)frame_cnt*1000/time);#endif SsbSipMPEG4DecodeDeInit(handle); munmap(in_addr, file_size); munmap(fb_addr, fb_size); close(pp_fd); close(fb_fd); close(in_fd); return 0;}int Test_Display_VC1(int argc, char **argv){ void *pStrmBuf; int nFrameLeng = 0; unsigned int pYUVBuf[2]; struct stat s; MMAP_STRM_PTR file_strm; SSBSIP_H264_STREAM_INFO stream_info; pp_params pp_param; s3c_win_info_t osd_info_to_driver; struct fb_fix_screeninfo lcd_info; #ifdef FPS struct timeval start, stop; unsigned int time = 0; int frame_cnt = 0;#endif int r = 0; if(signal(SIGINT, sig_del_vc1) == SIG_ERR) { printf("Sinal Error\n"); } if (argc != 2) { printf("Usage : mfc <VC-1 input filename>\n"); return -1; } // in file open in_fd = open(argv[1], O_RDONLY); if(in_fd < 0) { printf("Input file open failed\n"); return -1; } // get input file size fstat(in_fd, &s); file_size = s.st_size; // mapping input file to memory in_addr = (char *)mmap(0, file_size, PROT_READ, MAP_SHARED, in_fd, 0); if(in_addr == NULL) { printf("input file memory mapping failed\n"); return -1; } // Post processor open pp_fd = open(PP_DEV_NAME, O_RDWR|O_NDELAY); if(pp_fd < 0) { printf("Post processor open error\n"); return -1; } // LCD frame buffer open fb_fd = open(FB_DEV_NAME, O_RDWR|O_NDELAY); if(fb_fd < 0) { printf("LCD frame buffer open error\n"); return -1; } ////////////////////////////////////// /// 1. Create new instance /// /// (SsbSipMPEG4DecodeInit) /// ////////////////////////////////////// handle = SsbSipVC1DecodeInit(); if (handle == NULL) { printf("VC1_Dec_Init Failed.\n"); return -1; } ///////////////////////////////////////////// /// 2. Obtaining the Input Buffer /// /// (SsbSipMPEG4DecodeGetInBuf) /// ///////////////////////////////////////////// pStrmBuf = SsbSipVC1DecodeGetInBuf(handle, 200000); if (pStrmBuf == NULL) { printf("SsbSipVC1DecodeGetInBuf Failed.\n"); SsbSipVC1DecodeDeInit(handle); return -1; } //////////////////////////////////// // MPEG4 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); //////////////////////////////////////////////////////////////// /// 3. Configuring the instance with the config stream /// /// (SsbSipMPEG4DecodeExe) /// //////////////////////////////////////////////////////////////// r = SsbSipVC1DecodeExe(handle, nFrameLeng); if (r != SSBSIP_VC1_DEC_RET_OK) { printf("VC-1 Decoder Configuration Failed. : %d\n", r); return -1; } ///////////////////////////////////// /// 4. Get stream information /// ///////////////////////////////////// SsbSipVC1DecodeGetConfig(handle, VC1_DEC_GETCONF_STREAMINFO, &stream_info); printf("\t<STREAMINFO> width=%d height=%d.\n", stream_info.width, stream_info.height); // set post processor configuration pp_param.SrcFullWidth = stream_info.width; pp_param.SrcFullHeight = stream_info.height; pp_param.SrcCSpace = YC420; pp_param.DstFullWidth = 800; // destination width pp_param.DstFullHeight = 480; // destination height pp_param.DstCSpace = RGB16;#ifdef RGB24BPP pp_param.DstCSpace = RGB24;#endif pp_param.OutPath = POST_DMA; pp_param.Mode = ONE_SHOT; // get LCD frame buffer address fb_size = pp_param.DstFullWidth * pp_param.DstFullHeight * 2; // RGB565#ifdef RGB24BPP fb_size = pp_param.DstFullWidth * pp_param.DstFullHeight * 4; // RGB888#endif 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; } osd_info_to_driver.Bpp = 16; // RGB16#ifdef RGB24BPP osd_info_to_driver.Bpp = 24; // RGB24#endif osd_info_to_driver.LeftTop_x = 0; osd_info_to_driver.LeftTop_y = 0; osd_info_to_driver.Width = 800; // display width osd_info_to_driver.Height = 480; // display height // set OSD's information if(ioctl(fb_fd, SET_OSD_INFO, &osd_info_to_driver)) { printf("Some problem with the ioctl SET_OSD_INFO\n"); return -1; } ioctl(fb_fd, SET_OSD_START); while(1) { #ifdef FPS gettimeofday(&start, NULL); #endif ////////////////////////////////// /// 5. DECODE /// /// (SsbSipMPEG4DecodeExe) /// ////////////////////////////////// if (SsbSipVC1DecodeExe(handle, nFrameLeng) != SSBSIP_VC1_DEC_RET_OK) break; ////////////////////////////////////////////// /// 6. Obtaining the Output Buffer /// /// (SsbSipMPEG4DecodeGetOutBuf) /// ////////////////////////////////////////////// SsbSipVC1DecodeGetConfig(handle, VC1_DEC_GETCONF_PHYADDR_FRAM_BUF, pYUVBuf); ///////////////////////////// // Next MPEG4 VIDEO stream // ///////////////////////////// nFrameLeng = NextFrameVC1(&file_strm, pStrmBuf, INPUT_BUFFER_SIZE, NULL); if (nFrameLeng < 4) break; // Post processing // pp_param.SrcFrmSt俊绰 MFC狼 output buffer狼 physical address啊 // pp_param.DstFrmSt俊绰 LCD frame buffer狼 physical address啊 涝仿栏肺 持绢具 茄促. pp_param.SrcFrmSt = pYUVBuf[0]; // 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); #ifdef FPS gettimeofday(&stop, NULL); time += measureTime(&start, &stop); frame_cnt++; #endif }#ifdef FPS printf("Display Time : %u, Frame Count : %d, FPS : %f\n", time, frame_cnt, (float)frame_cnt*1000/time);#endif SsbSipVC1DecodeDeInit(handle); munmap(in_addr, file_size); munmap(fb_addr, fb_size); close(pp_fd); close(fb_fd); close(in_fd); return 0;}static void sig_del_h264(void){ printf("signal handling\n"); SsbSipH264DecodeDeInit(handle); munmap(in_addr, file_size); munmap(fb_addr, fb_size); close(pp_fd); close(fb_fd); close(in_fd);}static void sig_del_mpeg4(void){ printf("signal handling\n"); SsbSipMPEG4DecodeDeInit(handle); munmap(in_addr, file_size); munmap(fb_addr, fb_size); close(pp_fd); close(fb_fd); close(in_fd);}static void sig_del_vc1(void){ printf("signal handling\n"); SsbSipVC1DecodeDeInit(handle); munmap(in_addr, file_size); munmap(fb_addr, fb_size); close(pp_fd); close(fb_fd); close(in_fd);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -