H264解码的一个測试程序
网上看到的一个H264视频格式的解码測试程序,能够用来參考其逻辑流程。

代码例如以下:
Test_Display_H264()
{
in_fd = open(H264_INPUT_FILE, O_RDONLY); //video file open
fstat(in_fd, &s); // get input file size
file_size = s.st_size;
in_addr = (char *)mmap(0, file_size, PROT_READ, MAP_SHARED, in_fd, 0); // mapping input file to memory
pp_fd = open(PP_DEV_NAME, O_RDWR); // Post processor open,不须要它为什么要打开?
fb_fd = open(FB_DEV_NAME, O_RDWR|O_NDELAY); // LCD frame buffer open
//////////////////////////////////////////////
// FrameExtractor Initialization 帧解压初始化//
//////////////////////////////////////////////
pFrameExCtx = FrameExtractorInit(FRAMEX_IN_TYPE_MEM, delimiter_h264, sizeof(delimiter_h264), 1);
file_strm.p_start = file_strm.p_cur = (unsigned char *)in_addr;
file_strm.p_end = (unsigned char *)(in_addr + file_size);
FrameExtractorFirst(pFrameExCtx, &file_strm); //流文件缓冲区起始及结束
//////////////////////////////////////
/// 1. Create new instance ///
/// (SsbSipH264DecodeInit) ///
//////////////////////////////////////
handle = SsbSipH264DecodeInit();
//////////////////////////////
///// 1.1 CreateFile /////
//////////////////////////////
hOpen = open(MFC_DEV_NAME, O_RDWR|O_NDELAY); //打开MFC设备
//////////////////////////////////////////
// 1.2 Mapping the MFC Input/Output Buffer //
//////////////////////////////////////////
// mapping shared in/out buffer between application and MFC device driver
addr = (unsigned char *) mmap(0, BUF_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, hOpen, 0);
pCTX = (_MFCLIB_H264_DEC *) malloc(sizeof(_MFCLIB_H264_DEC)); //定义解码CTX
/////////////////////////////////////////////
/// 2. Obtaining the Input Buffer ///
/// (SsbSipH264DecodeGetInBuf) ///
/////////////////////////////////////////////
pStrmBuf = SsbSipH264DecodeGetInBuf(handle, nFrameLeng);
/////////////////////////////////////////////////
///// 2.1 (DeviceIoControl) /////
///// IOCTL_MFC_GET_STRM_BUF_ADDR 0x0080000F /////
/////////////////////////////////////////////////
mfc_args.get_buf_addr.in_usr_data = (int)pCTX->mapped_addr;
r = ioctl(pCTX->hOpen, IOCTL_MFC_GET_LINE_BUF_ADDR, &mfc_args);
///////////////////////////////////////////////
// 2.2 H264 CONFIG stream extraction 帧解压配置 //
//////////////////////////////////////////////
nFrameLeng = ExtractConfigStreamH264(pFrameExCtx, &file_strm, pStrmBuf, INPUT_BUFFER_SIZE, NULL);
////////////////////////////////////////////////////////////////
/// 3. Configuring the instance with the config stream ///
/// (SsbSipH264DecodeExe) ///
////////////////////////////////////////////////////////////////
SsbSipH264DecodeExe(handle, nFrameLeng);
/////////////////////////////////////////////////
///// 3.1 (DeviceIoControl) /////
///// IOCTL_MFC_H264_DEC_INIT 0x00800005 /////
/////////////////////////////////////////////////
mfc_args.dec_init.in_strmSize = lengthBufFill;
r = ioctl(pCTX->hOpen, IOCTL_MFC_H264_DEC_INIT, &mfc_args);
/////////////////////////////////////
/// 4. Get stream information ///
/////////////////////////////////////
SsbSipH264DecodeGetConfig(handle, H264_DEC_GETCONF_STREAMINFO, &stream_info);
//4.1 case H264_DEC_GETCONF_STREAMINFO
g_stream_info.width = pCTX->width;
g_stream_info.height = pCTX->height;
g_stream_info.buf_width = pCTX->buf_width;
g_stream_info.buf_height = pCTX->buf_height;
// set post processor configuration
// Structure type for IOCTL commands S3C_PP_SET_PARAMS, S3C_PP_SET_INPUT_BUF_START_ADDR_PHY,
// S3C_PP_SET_INPUT_BUF_NEXT_START_ADDR_PHY, S3C_PP_SET_OUTPUT_BUF_START_ADDR_PHY.
pp_param.src_full_width = stream_info.buf_width;
pp_param.src_full_height = stream_info.buf_height;
pp_param.src_start_x = 0;
pp_param.src_start_y = 0;
pp_param.src_width = pp_param.src_full_width;
pp_param.src_height = pp_param.src_full_height;
pp_param.src_color_space = YC420; //MFC decode数据为YUV420格式
pp_param.dst_start_x = 0;
pp_param.dst_start_y = 0;
pp_param.dst_full_width = FB0_WIDTH; // destination width
pp_param.dst_full_height = FB0_HEIGHT; // destination height
pp_param.dst_width = pp_param.dst_full_width;
pp_param.dst_height = pp_param.dst_full_height;
pp_param.dst_color_space = FB0_COLOR_SPACE; // RGB565
pp_param.out_path = DMA_ONESHOT;
ioctl(pp_fd, S3C_PP_SET_PARAMS, &pp_param);
// get LCD frame buffer address
fb_size = pp_param.dst_full_width * pp_param.dst_full_height * 2; // RGB565
fb_addr = (char *)mmap(0, fb_size, PROT_READ | PROT_WRITE, MAP_SHARED, fb_fd, 0);
//循环解压每一帧,直到播放完成
while(1)
{
//////////////////////////////////
/// 5. DECODE ///
/// (SsbSipH264DecodeExe) ///
//////////////////////////////////
if (SsbSipH264DecodeExe(handle, nFrameLeng) != SSBSIP_H264_DEC_RET_OK)
break;
/////////////////////////////////////////////////
///// 5.1 (DeviceIoControl) /////
///// IOCTL_MFC_H264_DEC_EXE 0x00800007 /////
/////////////////////////////////////////////////
mfc_args.dec_exe.in_strmSize = lengthBufFill;
r = ioctl(pCTX->hOpen, IOCTL_MFC_H264_DEC_EXE, &mfc_args);
//////////////////////////////////////////////
/// 6. Obtaining the Output Buffer ///
/// (SsbSipH264DecodeGetOutBuf) ///
//////////////////////////////////////////////
SsbSipH264DecodeGetConfig(handle, H264_DEC_GETCONF_PHYADDR_FRAM_BUF, pYUVBuf);
//6.1 IOCTL_MFC_GET_PHY_FRAM_BUF_ADDR 0x00800013
//获取物理地址给pp使用
r = ioctl(pCTX->hOpen, IOCTL_MFC_GET_PHY_FRAM_BUF_ADDR, &mfc_args);
///////////////////////////////////////
// Next H.264 VIDEO stream 获取下一帧//
//////////////////////////////////////
nFrameLeng = NextFrameH264(pFrameExCtx, &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.src_buf_addr_phy = pYUVBuf[0]; // MFC output buffer
ioctl(pp_fd, S3C_PP_SET_SRC_BUF_ADDR_PHY, &pp_param);
ioctl(fb_fd, FBIOGET_FSCREENINFO, &lcd_info);
pp_param.dst_buf_addr_phy = lcd_info.smem_start; // LCD frame buffer
ioctl(pp_fd, S3C_PP_SET_DST_BUF_ADDR_PHY, &pp_param);
ioctl(pp_fd, S3C_PP_START); //pp參数设置完成,启动pp
}
SsbSipH264DecodeDeInit(handle);
munmap(in_addr, file_size);
munmap(fb_addr, fb_size);
close(pp_fd);
close(fb_fd);
close(in_fd);
return 0;
}
H264解码的一个測试程序的更多相关文章
- 自己主动化測试程序之中的一个自己定义键盘的模拟測试程序(C语言)
一.測试程序编写说明 我们做的终端设备上运行的是QT应用程序.使用自己定义的键盘接口.经过測试人员长时间的人机交互測试,来确认系统的功能是否满足需求. 如今须要编写一个自己主动化的測试程序,能够依照预 ...
- DLL程序的创建步骤和測试程序
首先,创建DLL程序 然后,加入一个导出类 比如: //Test.h #pragma once class AFX_EXT_CLASS Test { public: Test(void); ~Te ...
- DM8168 GPIO驱动与測试程序
本次測试针对GPIO1进行,挑选了GP1[31],引脚的复用默认的就是GPIO 还是老规矩,贴上driver.c,Makefile,test.c: dm8168_gpio.c: #include &l ...
- DM8168 PWM驱动与測试程序
昨天把DM8168的Timer设置给摸了一遍,为写PWM的底层驱动做好了准备,如今就要进入主题了. dm8168_pwm.c: #include <linux/module.h> #inc ...
- spark0.9.1集群模式执行graphx測试程序(LiveJournalPageRank,新增Connected Components)
spark最新版公布了.之前的版本号就已经集成了graphx,这个版本号还改了一些bug. 我做了简单測试,只是网上关于集群模式执行spark资料太少了,仅仅有关于EC2(见參考资料1)的.可是还非常 ...
- 一个Nodejs的简单计算測试程序
測试目的: 1 測试二维数组的使用 2 输出函数的使用 代码: var util = require('util'); a = 3; b = 4; c = a + b; a = []; for(i = ...
- Android Gradle Plugin指南(四)——測试
原文地址:http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Testing 5.Testing(測试) 构建一个測试 ...
- Mali GPU OpenGL ES 应用性能优化--測试+定位+优化流程
1. 使用DS-5 Streamline定位瓶颈 DS-5 Streamline要求GPU驱动启用性能測试,在Mali GPU驱动中激活性能測试对性能影响微不足道. 1.1 DS-5 Streamli ...
- H264编码器性能測试
版本号:0.1.0-beta 作者:石硕 更新:2014-04-13 15:54:08 ======================================================== ...
随机推荐
- spring 加载配置文件的相关配置总结
PropertyPlaceholderConfigurer 注意: Spring容器仅允许最多定义一个PropertyPlaceholderConfigurer(或<context:p ...
- 解决 Tomcat reload WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesJdbc The web application [] registered the JDBC driver [com.mysql.jdbc.Driver] but fail
转自:http://www.cnblogs.com/interdrp/p/5632529.html 我的错误如下: 06-Sep-2016 18:57:10.595 WARNING [localhos ...
- Product(大数相乘)
Description The problem is to multiply two integers X, Y. (0<=X,Y<10250) Input The input will ...
- JS学习之事件冒泡
(1)什么是事件起泡 首先你要明白一点,当一个事件发生的时候,该事件总是有一个事件源,即引发这个事件的对象,一个事件不能凭空产生,这就是事件的发生. 当事件发生后,这个事件就要开始传播.为什 ...
- c# 迭代器 与 集合 IEnumerable.GetEnumerator 方法
示例来源 :msdn 参考:https://msdn.microsoft.com/zh-cn/library/dscyy5s0(v=vs.110).aspx 使用匿名方法.迭代器和部分选件类创建简洁的 ...
- 01_什么是Elasticsearch
Logstash是一个开源的用于收集,分析和存储日志的工具. Kibana4用来搜索和查看Logstash已索引的日志的web接口.这两个工具都基于 Elasticsearch. Logstash: ...
- Three Swaps DFS
E. Three Swaps time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- Linux vsftpd服务配置具体解释
[背景] 近日.一朋友dominoserver要进行升级.迁移,搭建了linux測试系统,也开启vsftpd服务,但是配置的ftp账号,程序无法正常下载附件. [问题跟踪] 通过ftpclient连接 ...
- poj1201 Intervals【差分约束+SPFA】
转载请注明出处,谢谢:http://www.cnblogs.com/KirisameMarisa/p/4303365.html ---by 墨染之樱花 题目链接:http://poj.org/pr ...
- #, about:blank,javascript:路径比较
试了一下在<a>,<img>,<iframe>中用#,about:blank和javascript: 代码如下: <!Doctype html> < ...