1 使用eXpressDSP Component Wizard生成算法
為了簡化xDAIS算法的開發步驟,我們可以使用eXpressDSP Component Wizard這個工具,在安裝之後,它會出現在CCS的Tool菜單欄中,使用非常友善。eXpressDSPComponent Wizard通過圖形化的配置界面引導使用者一步一步地完成一個xDAIS算法子產品的設計。在配置完成之後,eXpressDSP Component Wizard會生成所有的源檔案、頭檔案以及測試檔案,在使用者添加上自己的算法代碼之後可以很友善地進行測試。
使用eXpressDSPComponent Wizard可以使使用者不用過多關注xDAIS算法标準而專注于自己的算法開發,幾乎所有與算法标準相關的問題都有eXpressDSP Component Wizard自動完成了,是以,使用eXpressDSPComponent Wizard會大大縮短算法開發時間。
1.1 安裝eXpressDSPComponent Wizard
1,首先,需要下載下傳eXpressDSPComponent Wizard這個軟體,下載下傳的位址為https://www-a.ti.com/downloads/sds_support/targetcontent/XDAIS/xdais_4_0/ti_xdais_v4.0d_setup.exe(需要使用TI賬戶)。
2, eXpressDSPComponent Wizard的預設的安裝位址為c:\ xdais\xdais_4.0d,安裝完成之後,需要修改安裝目錄下的config.gmk檔案,将其中的CCS安裝路徑和BIOS安裝路徑修改為自己的安裝路徑。修改時需要注意的是這裡使用左斜杠,而不是windows系統中使用的右斜杠。
# Define the full path of the root directory in which DSP/BIOS was installed. # For BIOS 4.90 users, the CCS installation directory is the value needed # by the build system. For BIOS 5.20 users, the BIOS installation directory # is the required value. # BIOS_INSTALL_DIR = C:/CCStudio_v3.1/ # BIOS_INSTALL_DIR = C:/bios_5_20/ BIOS_INSTALL_DIR = C:/CCStudio_v3.3/bios_5_31_02 # Define the full path of the CCS installation # CCS_INSTALL_DIR = C:/CCStudio_v3.1/ CCS_INSTALL_DIR = C:/CCStudio_v3.3 |
3,如果eXpressDSPComponent Wizard安裝路徑不是使用預設路徑,那麼,還需要修改config.gmk檔案中的XDAIS_INSTALL_DIR變量為自己所使用的安裝路徑。
# Define the full path of the xdais installation directory # XDAIS_INSTALL_DIR = C:/xdais/xdais_4.0d/ XDAIS_INSTALL_DIR = C:/CCStudio_v3.3/xdais_4.0d |
4, 完成以上步驟之後,啟動CCS,就可以在菜單欄中看到相關選項。
1.2 配置eXpressDSPComponent Wizard
1, 在菜單欄中啟動ComponentWizard Control,出現圖形配置界面,我們需要建立xDAIS算法,是以選擇 New。
2,接下來,選擇CPU架構。DM6467的CPU架構是C64x,位元組順序為小端模式。
3,設定算法子產品的名字,提供者以及相關備注資訊。
4,設定算法的輸入輸出參數,暫時我們的算法沒有使用任何參數,設定為0。
5,設定算法的記憶體需求,需要将其中的Space屬性修改為IALG_EXTERNAL。
6,設定使用者函數和相關參數。
7,點選圖中的“Add”按鈕,設定函數名為process,傳回值為XDAS_Int32,參數個數為4,。
8,設定四個參數的名稱依次分别為inBufs,outBufs,inArgs和outArgs,資料類型都為XDAS_Int32 *。
9,下一步點選“next”,然後設定合适路徑并點選圖中的“Generate Code”。
至此,一個xDAIS算法子產品就已經生成了,下一步就是添加自定義的算法,然後進行測試。
2 添加EMCV
接下來,将預先已經修改好的EMCV檔案添加到生成的工程中,并修改process函數,加入自定義的算法。修改過後的process函數為:
XDAS_Int32 VIDENCCOPY_TI_process(IVIDENCCOPY_Handle handle, XDAS_Int32 * inBufs, XDAS_Int32 * outBufs, XDAS_Int32 * inArgs, XDAS_Int32 * outArgs) { VIDENCCOPY_TI_Obj *VIDENCCOPY = (Void *)handle; CvSize size; // pal frame, 422, YUV422 semi-planar CvPoint point1, point2; // draw a rectangle in the middle of an image XDAS_UInt8 * pYUV = (XDAS_UInt8 *) inBufs; XDAS_UInt8 * pRGB = (XDAS_UInt8 *)outBufs; IplImage* img; CvScalar color = CV_RGB(0, 255, 0); // green size.height = 576; size.width = 720; point1.x = 0;//size.width / 2 - 50; point1.y = 0;//size.height / 2 - 50; point2.x = size.width / 2 + 50; point2.y = size.height / 2 + 50; YUV422_C_RGB(pYUV, pRGB, size.height, size.width); img = cvCreateImage(size, IPL_DEPTH_8U, 3); cvSetData(img, pRGB, size.width * 3); cvRectangle(img, point1, point2, color, CV_AA, 8, 0); RGB_C_YUV422((unsigned char *)img->imageData, pYUV, size.height, size.width); pRGB = pYUV; cvReleaseImageHeader(&img); cvReleaseImage(&img); return((XDAS_Int32)0); } |
接下來,修改測試程式的main函數。
#include <std.h> #include <stdio.h> #include "videnccopy.h" #include "videnccopy_ti.h" void main(){ VIDENCCOPY_Handle handle; IVIDENCCOPY_Fxns fxns; VIDENCCOPY_Params params; unsigned char * inBufs, * outBufs; fxns = VIDENCCOPY_TI_IVIDENCCOPY; params = VIDENCCOPY_PARAMS; if((inBufs = (unsigned char *)calloc(720 * 576 * 2, sizeof(unsigned char))) == NULL) printf("No enough memory to allocate buffer.\n"); if((outBufs = (unsigned char *)calloc(720 * 576 * 3, sizeof(unsigned char))) == NULL) printf("No enough memory to allocate buffer.\n"); VIDENCCOPY_init(); if((handle = VIDENCCOPY_create(&fxns, ¶ms)) != NULL){ VIDENCCOPY_process(handle, (XDAS_Int32 *)inBufs, (XDAS_Int32 *)outBufs, NULL, NULL); VIDENCCOPY_delete(handle); } VIDENCCOPY_exit(); } |
添加完成之後,編譯運作,正常。