Codec Engine Application 分析

安装后的目录

cetools.包括CE使用的 dsplink和其他的Ti tool。不同的发行版本该目录不一样,可能是分开独立的包
docs. Contains documentation files.
examples. Contains a number of example applications.
package. 一些包相关的元数据文件。一般不必修改该包。
packages. CE包,包括VISA APIs
The Codec Engine packages. The /ti/sdo/ce subdirectory
(that is, the ti.sdo.ce package) contains the VISA APIs and the stubs
and skeletons that enable remote invocation of the VISA APIs. The
/ti/sdo/ce/osal subdirectory contains the OS abstraction layer.
xdoc. 一些关于 packages 的文件说明。

使用案例

 CE_INSTALL_DIR/examples 包括了很多例子,在例子里面有以下几个包:
 Codecs. 包括了CE的codecs
 Extensions. 包括了 scale example that extends the VISA API.
 Servers. 包括了 two pre-configured and pre-linked Codec Servers
 Applications. Contains example applications. 


     Codec Engine 由两个部分组成 Core Engine APIs 和 VISA APIs .

1、Core Engine APIs 用来打开和关闭 Engine实例,获取内存和内核的状态等  

  • Engine_open() - Open an Engine.
  • Engine_close() - Close an Engine.
  • Engine_getLastError() - Get the error code of the last failed operation.
  • Engine_getUsedMem() - Get Engine memory usage.
  • Engine_getNumAlgs() - Get the number of algorithms in an Engine.
  • Engine_getAlgInfo() Get information about an algorithm.

在打开一个Engine 后,就可以使用VISA APIs 创建算法实例


2、opening an Engine

代码:
Engine_Handle hEngine;
Engine_Error err;
 
hEngine = Engine_open("auddec", NULL, &err);

    执行 Engine_open(),会有以下操作:

     (1)打开dsp

     (2)调用link APIs用于初始化 dsp,并执行dsp与gpp之间的信息传输 (dsplink或syslink)


3、closing an Engine

代码:
Engine_close(ce);

必须在先删除alg实例后,再执行此操作。执行此操作会有以下操作:
     (1)调用link APIs用于停止 dsp与gpp之间的信息传输。
     (2)关闭dsp。

4、adding Engine

 (1)在BIOS 5包中,所有的Engine 都必须配置进入app的.cfg文件。
 (2)在BIOS 6包中,需将Engine 加入到 Engine database。
为了加入一个Engine,使用Engine_add(),如下实例:

#include <ti/sdo/ce/Engine.h>
#include <ti/sdo/ce/CERuntime.h>
 
/* Defines the UNIVERSAL_VISATYPE, the type of alg we are adding */
#include <ti/sdo/ce/universal/universal.h>
 
/* Include this header file for algorithm's IALG function table */
#include <ti/xdais/dm/examples/universal_copy/universal_copy_ti.h> Int main(Int argc, String argv[])
{ Engine_Desc engDesc; Engine_AlgDesc algDesc; Engine_Error status;
 
    /* Initialize Codec Engine */ CERuntime_init();
 
    /* Add the "universal_copy" engine */ Engine_initDesc(&engDesc); engDesc.name = "universal_copy"; status = Engine_add(&engDesc);
 
    /* Add the "universal_copy" alg to the "universal_copy" engine */ Engine_initAlgDesc(&algDesc); /* Set fields to defaults */ algDesc.name = "universal_copy"; algDesc.fxns = (IALG_Fxns *)&UNIVERSALCOPY_TI_IUNIVERSALCOPY; algDesc.idmaFxns = NULL; algDesc.isLocal = TRUE; algDesc.groupId = 0; algDesc.iresFxns = NULL; algDesc.types = UNIVERSAL_VISATYPE; status = Engine_addAlg("universal_copy", NULL, NULL, &algDesc);
 
    ...
}



如果Engine有一个远端的server,server用于查询alg ,这是,我们使用 Engine_addStubFxns(),在上面的例子后添加:
 
  /*
     *  Bring in the UNIVERSAL stub functions so we can create the
     *  universal_copy codec on the remote processor. NOTE: We should
     *  do this before opening the engine.
     */
    Engine_addStubFxns("UNIVERSAL_STUBS", (IALG_Fxns *)&UNIVERSAL_STUBS);


5. Adding Algorithms to Engines (BIOS 6)

(1)本地算法,使用Engine_addAlg()

#include <ti/sdo/ce/Engine.h>
#include <ti/sdo/ce/CERuntime.h>
 
/* Defines the UNIVERSAL_VISATYPE, the type of alg we are adding */
#include <ti/sdo/ce/universal/universal.h>
 
/* Include this header file for algorithm's IALG function table */
#include <ti/xdais/dm/examples/universal_copy/universal_copy_ti.h> Int main(Int argc, String argv[])
{ Engine_Desc engDesc; Engine_AlgDesc algDesc; Engine_Error status;
 
    /* Initialize Codec Engine */ CERuntime_init();
 
    /* Add the "universal_copy" engine */ Engine_initDesc(&engDesc); engDesc.name = "universal_copy"; status = Engine_add(&engDesc);
 
    /* Add the "universal_copy" alg to the "universal_copy" engine */ Engine_initAlgDesc(&algDesc); /* Set fields to defaults */ algDesc.name = "universal_copy"; algDesc.fxns = (IALG_Fxns *)&UNIVERSALCOPY_TI_IUNIVERSALCOPY; algDesc.idmaFxns = NULL; algDesc.isLocal = TRUE; algDesc.groupId = 0; algDesc.iresFxns = NULL; algDesc.types = UNIVERSAL_VISATYPE; status = Engine_addAlg("universal_copy", NULL, NULL, &algDesc);
 
    ...
}


 (2)共享库算法 ,使用   
 Int GetEngineAlgDesc(Engine_DllAlgDesc *algDesc) 
 

   示例库在 ti/sdo/ce/examples/codecs/sphdec1_copy_dll and sphenc1_copy_dll, 

   应用程序在 ti/sdo/ce/examples/apps/speech1_copy_dll.

(Int argc, String argv[])
{ Engine_Desc desc; Engine_AlgDesc attrs; Engine_Error status;
 
    ...
 
    /* Add the engine name to the set of engines that can be opened */ Engine_initDesc(&desc); desc.name = "engine"; status = Engine_add(&desc);
 
    /* Open the engine */ ce = Engine_open("engine", NULL, NULL);
 
    /* * Fill in the alg descriptor. Note: We only need to fill in the * name and groupId since alg functions will be obtained from the * library. */ Engine_initAlgDesc(&attrs); attrs.name = "sphdec1_copy"; attrs.groupId = 1;
 
    /* Add the alg. Pass engine handle, since engine is opened. */ status = Engine_addAlg(NULL, ce, "./libsphdec1_copy_dll.so.1.0.0",
                           &attrs);
 
    ...
}



6、 The VISA Classes: Video, Image, Speech, Audio... and more!

For each of the VISA classes (e.g. VIDDEC, AUDENC, UNIVERSAL, etc.), the following APIs are provided, where MOD is the module prefix:

  • MOD_create() - Create an instance of this type of algorithm.
  • MOD_process() - Execute the "process" method in this instance of the algorithm. Block until complete.
  • MOD_control() - Execute the "control" method in this instance of the algorithm.
  • MOD_delete() - Delete the specified instance of this type of algorithm.


7、Creat an alg 

To create an algorithm instance within an Engine, 使用  *_create() 

Engine_Handle hEngine; AUDDEC_Handle hAuddec;
 
/* allocate and initialize audio decoder on the Engine */ hAuddec = AUDDEC_create(hEngine, "auddec_copy", NULL);

你可能感兴趣的:(Engine,Codec)