- UID
- 1029342
- 性别
- 男
|
编译步骤如下:
1、把ccs下编写好的文件复制到Linux codec_engine_1_02\examples\codecs下的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_Int32extendedError;
XDAS_Int32bytesGenerated;
XDAS_Int32encodedFrameType;
XDAS_Int32inputFrameSkip;
IVIDEO_BufDescreconBufs;
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\n");
}
hVen =VIDENC_create(hEngine,"videnc_copy",NULL);
if (hVen == NULL){
ERR("Failed to create video encoder:videnc_copy");
}
XDM_BufDescinBufs;
XDM_BufDescoutBufs;
VIDENC_InArgsinArgs;
VIDENC_OutArgsoutArgs;
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\n");
return -1;
}
FILE*fp1=fopen("out.jpg","wb");
fwrite(JpgBuffer1,1,JpgSize,fp1);
fclose(fp1); |
|