基于davinci6467的DSP算法移植
工具链是指的Linux下对程序的编译环境。在这里通过 codec_engine_1_02examplescodecs 下的videnc_copy工程封装DSP.com/forum.php?mod=forumdisplay&fid=58" target="_blank" class="relatedlink">CCS下调试好的程序并生成videnc_copy.a64P,再通过codec_engine_1_02examplesserversvideo_copy工程把videnc_copy.a64P封装成all.x64P
编译步骤如下:
1、把ccs下编写好的文件复制到Linux codec_engine_1_02examplescodecs 下的videnc_copy工程中。
2.修改该工程中的package.bld文件
修改var SRCS = ["videnc_copy","test"];括号里只选择工程下的C文件
修改该文件中的for (var i = 0; i <1 ; i++) { 选择DSP端只用cgtool来编译(在config.bld中C64P排第一个)
3. 由于输入输出参数由IVIDENC_InArgs,IVIDENC_OutArgs结构体来决定,所以为了增加输出输入参数,应该修改这两个结构体。为此修改xdais_6_25_02_11/packages/ti/xdais/dm中的ividenc.h。
//要添加在结构体的后头
- typedef struct IVIDENC_InArgs {
- XDAS_Int32 size;
- int num1;
- int num2;
- } IVIDENC_InArgs;
- typedef struct IVIDENC_OutArgs {
- XDAS_Int32 size;
- XDAS_Int32 extendedError;
- XDAS_Int32 bytesGenerated;
- XDAS_Int32 encodedFrameType;
- XDAS_Int32 inputFrameSkip;
- IVIDEO_BufDesc reconBufs;
- int out;
- } IVIDENC_OutArgs;
复制代码
4.在videnc_copy中调用算法:在VIDENCCOPY_TI_process函数中添加(替换原来处理输入输出buf的地方):
- outArgs->out=test(inBufs->bufs[0],outBufs->bufs[0],inBufs->bufSizes[0],inArgs->num1,inArgs->num2);
复制代码
由于使用了#ifdef USE_ACPY3 宏,故而要选择是否使用DMA,为了避免Cache和DMA的冲突,选择不使用DMA。修改- odec_engine_2_25_05_16/examples/ti/sdo/ce/examples/servers/all_codecs下的all.cfg:
- VIDENC_COPY.useDMA = false;
复制代码
5.编译videnc_copy生成videnc_copy.a64P
6.修改server,编译生成all.x64P
使用:
1.修改encode下的Makefile文件,让encode包含server及codec工程:
- XDC_PATH = $(USER_XDC_PATH);../../packages;$(DMAI_INSTALL_DIR)/packages;$(CE_INSTALL_DIR)/packages;$(FC_INSTALL_DIR)/packages;$(LINK_INSTALL_DIR)/packages;$(LINK_INSTALL_DIR);$(XDAIS_INSTALL_DIR)/packages;$(CMEM_INSTALL_DIR)/packages;$(CODEC_INSTALL_DIR)/packages;$(CE_INSTALL_DIR)/examples
复制代码
2.修改encode下的encode.cfg:
- var demoEngine = Engine.createFromServer(
- "test", //引擎句柄
- "./bin/ti_platforms_evmDM6467/all.x64P", //以bin开头
- "ti.sdo.ce.examples.servers.all_codecs" //路径
- );
复制代码
3.文件中调用(例子):
- CERuntime_init();
- Dmai_init();
- VIDENC_Handle hVen = NULL;
- Engine_Handle hEngine = NULL;
- hEngine = Engine_open("test", NULL, NULL);
- if (hEngine == NULL) {
- ERR("Failed to open codec engine:test
");
- }
-
- hVen = VIDENC_create(hEngine,"videnc_copy",NULL);
- if (hVen == NULL) {
- ERR("Failed to create video encoder: videnc_copy");
- }
- XDM_BufDesc inBufs;
- XDM_BufDesc outBufs;
- VIDENC_InArgs inArgs;
- VIDENC_OutArgs outArgs;
- char *JpgBuffer;
- char *JpgBuffer1;
- JpgBuffer=(char *)Memory_contigAlloc(1024*1024,Memory_DEFAULTALIGNMENT); //在loadmoudle.sh脚本里面要添加相应大小的(arm与dsp)共享内存大小块
- JpgBuffer1=(char *)Memory_contigAlloc(1024*1024,Memory_DEFAULTALIGNMENT);
- int JpgSize;
- FILE *fp=fopen("test.jpg","rb");
- fseek(fp,0,SEEK_END);
- JpgSize=ftell(fp);
- fseek(fp,0,SEEK_SET);
- fread(JpgBuffer,1,JpgSize,fp);
- fclose(fp);
- inBufs.numBufs = 1;
- inBufs.bufs = &JpgBuffer;
- inBufs.bufSizes = &JpgSize;
- outBufs.numBufs = 1;
- outBufs.bufs = &JpgBuffer1;
- outBufs.bufSizes = &JpgSize;
-
- int num1=1;
- int num2=1;
- inArgs.num1=num1;
- inArgs.num2=num2;
- inArgs.size=sizeof(VIDENC_InArgs);
- outArgs.size=sizeof(VIDENC_OutArgs);
- VIDENC_process (hVen,&inBufs,&outBufs,&inArgs,&outArgs);
- if(outArgs.out!=0)
- {
- printf("copy failed
");
- return -1;
- }
- FILE *fp1=fopen("out.jpg","wb");
- fwrite(JpgBuffer1,1,JpgSize,fp1);
- fclose(fp1);
复制代码
附录(算法例子(在Dsp完成简单的图片复制):
- int test(char *inbuf,char *outbuf,int size,int num1,int num2)
- {
- int flag1=num1;
- int flag2=num2;
- int flag3=-1;
- int jpgsize=size;
- if(1==flag1&&1==flag2)
- {
- memcpy(outbuf,inbuf,jpgsize);
- flag3=0;
- }
- return flag3;
- }
复制代码
[color=rgb(51, 102, 153) !important]
一周热门 更多>