DSP工程框架和DM642初始化代码

来源:互联网 发布:多益网络线上笔试题 编辑:程序博客网 时间:2024/06/14 09:01
参考工程:mpeg2_loopback4_NEWER


★分析link_dm642.cmd文件:
总得来说,该文件做了一下几点工作:1、定义了工程所使用的lib列表;2、包含了CDB自动生成的配置文件mpeg2_loopbackcfg.cmd(处理BIOS设置);等等
空间的设置是:输入原始yuv缓冲,帧缓冲和输出比特流的缓冲位于SDRAM上。




★分析mpeg2_loopback_main.c文件:
对于的自定义的头文件是appMain.h,内容定义了些宏即引用了些外部函数和变量。该文件定义了两种图像格式(图像大小有区别):NTSC_FULL,PAL_CIF
该文件包含了程序入口main()函数,主要工作是进行所有相关的初始化和相关部件的启动。比如:RF5, Video Input task,Process task,SCOM & message objects。
main()中使用的主要的函数有:
CSL_init(); //系统函数,初始化CSL库
CACHE_clean(CACHE_L2ALL, 0, 0); //系统函数
CACHE_setL2Mode(CACHE_64KCACHE); //系统函数
CACHE_enableCaching(CACHE_EMIFA_CE00); //系统函数
CACHE_enableCaching(CACHE_EMIFA_CE01); //系统函数
int DAT_open(int chaNum, int priority, Uint32 flags); //系统函数
CACHE_setPriL2Req(CACHE_L2PRIHIGH); //<csl_cache.h>
UTL_setLogs( <LOG for errors>, <LOG for warnings>, <LOG for messages>, <LOG for debugging>); //<utl.h>,设置各个log使用的对象
CHAN_init(); //<chan.h>
ICC_init(); //<icc.h>
SCOM_init(); //<scom.h>
CHAN_setup( intHeap, extHeap, intHeap, 1, NULL, NULL); //<chan.h>
tskVideoInputInitX(); //X为数字,"tskVideoInput.c"
EVMDM642_rset(0x10, 0x20); //"evmdm642.c"
tskVideoInputStartX(); //X为数字,"tskVideoInput.c"
tskProcessInit(); //"tskProcess.c"
tskProcessStart(); //"tskProcess.c"


★分析tskVideoInput.c文件:
主要的定义函数:
void tskVideoInputInit() //建立捕获视频的通道并初始化它
void tskVideoInputStart() //开始捕获视频
void tskVideoInput() //处理捕获视频,缩放和重整格式


★分析tskProcess.c文件:
主要的定义函数:
void tskProcessInit() //
void tskProcessStart() //创建通道的实例,细胞算法也被实例化
void tskProcess() //任务主要有:使用输入帧指针来从输入任务中获得信息;运行通道来编码,然后再解码;把解码的帧指针传递给输出任务
void readparamfile(char *fname,IMPEG2VENC_Params *mpeg2veparam) //从输入参数文件中读取编码参数


★所做的修改
根目录比较结果:
----------------------------------------------------------------
文件名                         | 状态     | 来源日期         | 来源大小 | 目标日期        | 目标大小 
-----------------------------------------------------------------------------------------------------
build.bat                      | 内容相同 | 2003/7/8 16:08   | 307      | 2003/7/8 16:08  | 307      
link_dm642.cmd                 | 来源较新 | 2005/12/4 17:09  | 2282     | 2003/8/7 17:50  | 2247     
mpeg2_loopback.cdb             | 来源较新 | 2005/12/11 15:12 | 1042571  | 2003/8/7 17:31  | 1040795  
mpeg2loopback_dm642.pjt        | 来源较新 | 2008/9/10 15:06  | 1900     | 2003/7/8 16:46  | 1738     
_iic.c                         | 仅来源   | 2005/11/27 11:32 | 2972     | 无              | 无     
_iic.h                         | 仅来源   | 2003/7/2 12:05   | 666      | 无              | 无     
_saa7115.c                     | 仅来源   | 2005/12/19 17:07 | 48546    | 无              | 无     
_saa7115.h                     | 仅来源   | 2003/7/2 12:05   | 11651    | 无              | 无     
_vport.h                       | 仅来源   | 2003/7/25 14:46  | 2549     | 无              | 无     
cc_build_Debug.log             | 仅来源   | 2006/6/29 22:55  | 557      | 无              | 无     
Debug.lkf                      | 仅来源   | 2006/6/29 22:55  | 1765     | 无              | 无     
Debug.lkv                      | 仅来源   | 2006/6/29 22:55  | 1765     | 无              | 无     
evmdm642.c                     | 仅来源   | 2005/11/26 10:53 | 6705     | 无              | 无     
evmdm642.c.bak                 | 仅来源   | 2005/10/7 15:43  | 6707     | 无              | 无     
evmdm642.h                     | 仅来源   | 2005/10/6 13:34  | 2039     | 无              | 无     
FOXUSER.DBF                    | 仅来源   | 2006/6/29 22:45  | 857      | 无              | 无     
FOXUSER.FPT                    | 仅来源   | 2006/6/29 22:45  | 4608     | 无              | 无     
InterruptEn.asm                | 仅来源   | 2005/8/4 10:45   | 178      | 无              | 无     
mpeg2_loopbackcfg.cmd          | 仅来源   | 2006/1/13 20:49  | 7606     | 无              | 无     
mpeg2_loopbackcfg.h            | 仅来源   | 2006/1/13 20:49  | 829      | 无              | 无     
mpeg2_loopbackcfg.h62          | 仅来源   | 2006/1/13 20:49  | 4756     | 无              | 无     
mpeg2_loopbackcfg.s62          | 仅来源   | 2006/1/13 20:49  | 35262    | 无              | 无     
mpeg2_loopbackcfg_c.c          | 仅来源   | 2006/1/13 20:49  | 590      | 无              | 无     
mpeg2loopback_dm642.paf        | 仅来源   | 2008/9/10 15:06  | 32522    | 无              | 无     
saa7115.c                      | 仅来源   | 2005/12/20 10:04 | 17426    | 无              | 无     
Vectors.asm                    | 仅来源   | 2005/12/4 14:29  | 414      | 无              | 无     
vportcap.c                     | 仅来源   | 2005/12/7 10:52  | 43080    | 无              | 无     
-----------------------------------------------------------------------------------------------------
include目录比较结果:
------------------------------------------------------------------------
文件名                         | 状态     | 来源日期         | 来源大小 | 目标日期        | 目标大小 
-----------------------------------------------------------------------------------------------------
appThreads.h                   | 内容相同 | 2003/6/1 20:23   | 1308     | 2003/6/1 20:23  | 1308     
cellmpeg2enc.h                 | 内容相同 | 2003/4/3 16:55   | 951      | 2003/4/3 16:55  | 951      
evmdm642_vcapparams.h          | 内容相同 | 2003/6/26 20:09  | 510      | 2003/6/26 20:09 | 510      
evmdm642_vdisparams.h          | 内容相同 | 2003/6/26 20:09  | 510      | 2003/6/26 20:09 | 510      
impeg2vdec.h                   | 内容相同 | 2003/6/18 13:23  | 3478     | 2003/6/18 13:23 | 3478     
impeg2venc.h                   | 内容相同 | 2003/7/4 21:16   | 7801     | 2003/7/4 21:16  | 7801     
mpeg2dma.h                     | 内容相同 | 2003/7/4 21:14   | 6652     | 2003/7/4 21:14  | 6652     
tskVideoInput.h                | 内容相同 | 2003/6/1 20:23   | 1392     | 2003/6/1 20:23  | 1392     
tskVideoOutput.h               | 内容相同 | 2003/6/1 20:23   | 1175     | 2003/6/1 20:23  | 1175     
appMain.h                      | 来源较新 | 2005/10/24 15:42 | 1192     | 2003/7/4 21:14  | 1192     
cellmpeg2dec.h                 | 来源较新 | 2006/1/13 14:28  | 955      | 2003/6/17 20:15 | 953      
tskProcess.h                   | 来源较新 | 2006/1/9 21:11   | 1413     | 2003/6/28 6:08  | 1413     
impeg2venc.h.bak               | 仅来源   | 2005/5/3 19:05   | 7801     | 无              | 无       
-----------------------------------------------------------------------------------------------------
src目录比较结果:
相同的子目录为:output,resampling
新增的子目录为:Input1,Input2,Input3
其他为有差异的子目录。


差异分析:
许多文件中屏蔽掉了对"cellmpeg2dec.h"的引用(不需要解码的功能);
新增了三路视频通道及复制了三份相关的函数;
tskProcess.h
#define PROCESSNUMCELLS    1==>2
tskVideoInput.c
#define LINE_SZ 720==>352
#define NUM_LINES 240==>144
重命名fromProctoInput==>fromOuttoInput
fromOuttoInput = SCOM_open("OUTTOIN");==>fromProctoInput = SCOM_open("PROCTOIN");
新增_IIC_write(EVMDM642_I2C_hI2C,0x5E,0x03,&data,1);
appData.c
SCOM_Handle objSCOMInToProc[NUM_SCOM_OBJS_IN][2==>4]
SCOM_Handle objSCOMProcToOut[NUM_SCOM_OBJS_OUT][2==>4]
mpeg2_loopback_main.c
去掉了tskVideoOutputInit();
去掉了tskVideoOutputStart();
去掉了while(!(EVMDM642_rget(0x13)& 0x40));
tskProcess.c
该文件改动较多,例如有关解码的代码被去掉。
evmdm642_vcapparamsNTSC_EMBEDDED.c
#define LINE_SZ 720==>352
#define NUM_LINES 240==>144
参数结构体VPORTCAP_Params EVMDM642_vCapParamsChan的numFrmBufs设置3==>5
VPORT_PortParams EVMDM642_vCapParamsPort和SAA7115_ConfParams EVMDM642_vCapParamsSAA7115的成员有变化


★mpeg2_loopback工程整体说明,参照mpeg2_loopback.pdf
该工程首先编码所捕获的帧,然后再把生成的MPEG-2比特流进行解码,最后再显示解码的帧。它使用RF-5 framework来整合MPEG-2编码器和解码器库。该MPEG-2库与main profile @ main level档次是一致的。test.par文件包含了部分可以修改的编码参数,具体约束参见mpeg2_loopback.pdf文件。
软件的执行过程分为两大部分,初始化和BIOS调度程序来管理进行的Input Task,Process Task, Output Task。流程框图见mpeg2_loopback.pdf文件。英文原文如下:
Board and processor initialization :
The systems performs BIOS initialization and CSL initialization.
The L2 cache mode is set to 64 K cache.
EMIFA CE0 and EMIF CE1 space are enable for caching.
Sets the DMA priority queue lengths to maximum.
Priority for L2 request is set as high.
RF- 5 modules initialization :
The systems initializes the Channel module of RF -5.
The system initializes ICC and SCOM modules of RF -5 required for Inter cell communication and messaging.
Channel setup is performed with the internal, external and scratch heap buffers.
Creation of capture and display channels:
An instance of capture channel is created and started.
An instance of display channel is created and started.
Creation of the algorithm instances:
The MPEG-2 encoder cell is created and registered in the channel.
The MPEG-2 decoder cell is created and registered in the channel.
The channel is opened, which leads to creation of the instances o f the encoder and decoder cells.
After the initializations, the system enters the three task system managed by BIOS scheduler. The tasks use SCOM module of RF -5 to communicate to each ot her. The three tasks are:
Input Task
The input task is responsible for acquiring the frames from the NTSC input device.
It uses FVID_exchange calls provided by driver to acquire a frame from the NTSC input device.
The acquired frame is in YUV 4:2:2 format. It is resampled to YUV 4:2:0.
It then sends the message to process task with the frame pointer embedded in the message.
The task then waits for the message from output task to continue.
Process Task
The process task is responsible for encoding the frame, passing the bitstream to decoder module, decoding the frame and then passing in on to output task.
The process task achieves the loopback by executing the RF -5 channel.
The RF -5 channel has both encoder and decoder cells registered in it.
The ICC module manages the passing of bitstream generated by encoder cell to decoder cell.
The task waits till it recieves the message, with input frame, from the input task.
The RF-5 channel executes, as a part of which first the encoder cell executes , generates the
bistream.
The generated bitstream is passed to decoder cell and the decoder cell executes producing the
decoded frames.
It then sends the message to output task with the output frame pointer(reconstructed frame)
embedded in the message.
The task then waits for the message from input task to continue further.
Output Task
The output task is responsibl e for displaying the frames on the NTSC output device.
It uses FVID_exchange calls provided by driver to display a frame on the NTSC output device.
The acquired frame is in YUV 4:2:0 format. It is resampled to YUV 4:2:2 format.
It then sends the message to input task to continue.
The task then waits for the message from process task to continue.
此文在论文“基于DM642的压缩系统设计与实现.PDF”中有论述,摘录文字部分如后所示。且有关RF-5的内容在该文中也有详细的介绍。
程序采用RF-5整合H.263的编解码库。程序使用了三个任务模块。在进入DSP/BIOS的调度程序之前,程序初始化多个要使用的模块。包括:
处理器和系统板的初始化
初始化BIOS环境和CSL
设置使用64K的二级高速缓存
设置二级高速缓存可映射到EMIF的CEO和CEI空间
设置EDMA优先级序列长度取最大值
设置二级高速缓存的请求优先级最高
RF-5模块的初始化
系统初始化RF-5的通道模块
系统初始化RF-5框架中用于内部单元通讯和传递消息的ICC和SCOM模块
各通道完成在内部的、扩展的和临时的堆建立
建立捕获和显示通道
建立和启动一个捕获通道的实例
建立和启动一个显示通道的实例
建立编解码运算实例
在通道中建立和注册H.263编码单元
在通道中建立和注册H.263解码单元
打开通道,建立编码和解码单元实例
在完成初始化工作之后,系统进入DSP/BIOS调度程序管理下的三个任务。
三个任务通过RF-5的SCOM模块互相发送消息。三个任务分别为:
输入任务
输入任务从视频捕获驱动程序获得视频图像。它使用驱动程序提供的FVID_exchange调用从输入设备获取一帧最新视频图像·获取的图像
是YUV4:2:2格式的,被重采样成YUV4:2:00输入任务接着发送消息到处理任务,消息中包含图像数据指针。接着等待输出任务发送来的消息以继续处理。
处理任务
处理任务对图像数据进行编码,传送编码码流到解码模块,解码图像后传输到输出模块.处理任务通过RF-5通道实现视频的编码解码和显
示.编码解码单元均注册于RF-5通道中。ICC模块管理编码模块产生的码流传送到解码单元这一过程。处理任务一直等到接收到输入任务
发送来的包含输入图像的消息,才开始激活运行。RF-5通道首先运行编码单元产生编码码流。产生的编码码流传输到解码单元,解码单元
运行并生成图像。处理任务接着发送消息到输出任务,消息中包含解码后生成的图像的指针。处理任务接下来等待输入任务发来的新消息
才能继续运行。
输出任务
输出任务将图像显示在显示设备上.它得到的图像的格式是YUV4:2:0的,需要重新采样成YUV4:2:2格式。接着发送消息到输入任务,然
后任务等待处理任务发来的消息以继续运行。

















原创粉丝点击