1. 程式人生 > >達芬奇工具鏈的建立(工程編譯步驟)[轉]

達芬奇工具鏈的建立(工程編譯步驟)[轉]

    工具鏈是指的Linux下對程式的編譯環境。在這裡通過codec_engine_1_02\examples\codecs 下的videnc_copy工程封裝CCS下除錯好的程式並生成videnc_copy.a64P,再通過codec_engine_1_02\examples\servers\video_copy工程把videnc_copy.a64P封裝成all.x64P。最後通過encodedecode工程呼叫all.x64P。
步驟如下:
1、把ccs下編寫好的檔案複製到Linux codec_engine_1_02\examples\codecs 下的videnc_copy工程中。
2、修改該工程中的package.bld檔案,修改var SRCS = ["videnc_copy","blob","cornerdetection","him","imc","morph","objectrecognition"]; 中括號裡只選擇工程下的C檔案。修改該檔案中的
for (var i = 0; i <1 /*Build.targets.length*/; i++) { 選擇DSP端只用cgtool來編譯。
3、修改codec_engine_1_02\examples下的user.bld,把linux86注掉,選擇用C64P,跟第二步中對應。
Build.targets = [
// Linux86,
C64P,
MVArm9
4、修改DSP算法佔用的空間

修改server/all.tcf

var mem_ext = [

{

comment: "DDRALGHEAP: off-chip memory for dynamic algmem allocation",

name:    "DDRALGHEAP",

base:    0x88000000, // 128MB

len:        0x07A00000, // 122MB

space:    "code/data"

},

{

comment: "DDR: off-chip memory for application code and data",

name:    "DDR",

base:    0x8FA00000, // 250MB

len:        0x00400000, // 4MB

space:    "code/data"

},

{

comment: "DSPLINK: off-chip memory reserved for DSPLINK code and data",

name:    "DSPLINKMEM",

base:    0x8FE00000, // 254MB

len:        0x00100000, // 1MB

space:    "code/data"

},

{

comment: "RESET_VECTOR: off-chip memory for the reset vector table",

name:    "RESET_VECTOR",

base:    0x8FF00000,

len:        0x00000080,

space:    "code/data"

},

];

修改為:

var mem_ext = [

{

comment: "DDRALGHEAP: off-chip memory for dynamic algmem allocation",

name:    "DDRALGHEAP",

base:    0x88000000, // 128MB

len:        0x07400000, // 122MB

space:    "code/data"

},

{

comment: "DDR: off-chip memory for application code and data",

name:    "DDR",

base:    0x8F400000, // 250MB

len:        0x00A00000, // 4MB

space:    "code/data"

},

{

comment: "DSPLINK: off-chip memory reserved for DSPLINK code and data",

name:    "DSPLINKMEM",

base:    0x8FE00000, // 254MB

len:        0x00100000, // 1MB

space:    "code/data"

},

{

comment: "RESET_VECTOR: off-chip memory for the reset vector table",

name:    "RESET_VECTOR",

base:    0x8FF00000,

len:        0x00000080,

space:    "code/data"

},

];
5、修改loadmodules.sh:
insmod dsplinkk.ko ddr_start=0x8f400000 ddr_size=0xA00000
6、在編譯codec_engine_1_02\examples\codecs\videnc_copy之前,要修改演算法的主程式main函式

void ObjectRecognition(unsigned char* inbuf, int* flag,unsigned char* outbuf, int* kind, float *inIM)。其中輸入輸出引數是由

XDAS_Int32 VIDENCCOPY_TI_process(IVIDENC_Handle h, XDM_BufDesc *inBufs,XDM_BufDesc *outBufs, IVIDENC_InArgs *inArgs, IVIDENC_OutArgs *outArgs)決定。由於輸入輸出引數由IVIDENC_InArgs,IVIDENC_OutArgs結構體來決定,所以為了增加輸出輸入引數,應該修改這兩個結構體。為此修改xdais_5_00\packages\ti\xdais\dm中的ividdec.h檔案。新增kind和IM[25]。

typedef struct IVIDENC_OutArgs {

XDAS_Int32 size;                                        XDAS_Int32 extendedError;

XDAS_Int32 bytesGenerated;

XDAS_Int32 encodedFrameType;

XDAS_Int32 inputFrameSkip;

XDAS_Int32 kind;             /*what's kind of the target*/

float   IM[25];                   /*return value*/

IVIDEO_BufDesc reconBufs; /**< Reconstruction Frames. */

} IVIDENC_OutArgs;

為了區分輸入幀存的性質(從jpeg讀取的資料還是ccd採集的資料)增加一個flag作為標誌。

typedef struct IVIDENC_InArgs {

XDAS_Int32 size;      

XDAS_Int32 flag;//is picture saved on U or captured from CCD
} IVIDENC_InArgs;
7、在videnc_copy中呼叫演算法:在VIDENCCOPY_TI_process函式中新增:ObjectRecognition(inBufs->bufs[curBuf],&(inArgs->flag),outBufs->bufs[curBuf],&(outArgs->kind),(outArgs->IM));
注意要新增在
for (curBuf = 0; (curBuf < inBufs->numBufs) &&
(curBuf < outBufs->numBufs); curBuf++)
#ifdef USE_ACPY3
......
#else
和#endif之間。
由於使用了#ifdef USE_ACPY3 巨集,故而要選擇是否使用DMA,為了避免Cache和DMA的衝突,選擇不使用DMA。修改codec_engine_1_02\examples\servers\video_copy下的video_copy.cfg檔案或者codec_engine_1_02\examples\servers\all_codecs下的all.cfg檔案來關閉DMA:
/* we can use DMA in certain codecs! */
VIDENC_COPY.useDMA = false
;
8、編譯videnc_copy生成videnc_copy.a64P
9、修改server,編譯生成all.x64P
10、下面就是編譯encodedecode呼叫all.x64P

* 首先修改Encodedecode下的Makefile檔案,讓encodedecode包含server及codec工程。XDC_PATH = $(CODEC_INSTALL_DIR)/packages;$(CE_INSTALL_DIR)/examples;
$(CE_INSTALL_DIR)/packages;$(LINK_INSTALL_DIR)/packages;
$(XDAIS_INSTALL_DIR)/packages;$(CMEM_INSTALL_DIR)/packages
*   其次為了使用新的演算法videnc_copy,要修改encodedecode.cfg檔案把H264演算法替換為videnc_copy演算法:
//var H264ENC =xdc.useModule('ti.sdo.codecs.h264enc.H264ENC');
//var H264DEC = xdc.useModule('ti.sdo.codecs.h264dec.H264DEC');
var VIDDEC_COPY = xdc.useModule('codecs.viddec_copy.VIDDEC_COPY');
var VIDENC_COPY = xdc.useModule('codecs.videnc_copy.VIDENC_COPY');

/* *   ======== Engine Configuration ======== */
var Engine = xdc.useModule('ti.sdo.ce.Engine');
/*var vcr = Engine.create("loopback", [
{name: "h264enc", mod: H264ENC, local: false},
{name: "h264dec", mod: H264DEC, local: false},
]);*/
var demoEngine = Engine.create("encodedecode", [
{name: "videnc_copy", mod: VIDENC_COPY, local: false},
{name: "viddec_copy", mod: VIDDEC_COPY, local: false}
]);

//vcr.server = "./loopbackCombo.x64P";
demoEngine.server = "./all.x64P";
* 修改encodedecode工程中建立演算法函式

static String decoderName   = "viddec_copy";

static String encoderName   = "videnc_copy";

static String engineName = "video_copy";

hDecode = VIDDEC_create(hEngine, decoderName, &params);

hEncode = VIDENC_create(hEngine, encoderName, &params);

在工程裡用到的是hEncode。
*

修改status = VIDENC_process(hEncode, &inBufDesc,&outBufDesc,&inArgs, &outArgs);的輸入輸出引數,使之符合封裝演算法是的函式引數。