This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How can I use two codec engine in one application?

Other Parts Discussed in Thread: SYSBIOS

Dear all, 

I  am now working on one project, and in my case, I would like to use two codec engine in one program.

My program is based on the encode example provided by DVSDK.

The original example uses one codec engine named demoEngine, and I would like to use another codec engine because I have other things to do in DSP besides the original encode job.

I had no idea how to add another engine in my program, so I tried to modify the *.cfg file first, but it didn't work.

The following is the modified *.cfg file, is there anything wrong?

 

The red lines indicate the modified part.

/* Load support for the Codec Engine */

var osalGlobal = xdc.useModule( 'ti.sdo.ce.osal.Global' );

 

/* Configure CE to use it's DSP Link Linux version */

osalGlobal.runtimeEnv = osalGlobal.DSPLINK_LINUX;

 

/* Enable SoCrates tracing in the demo */

var TraceUtil = xdc.useModule('ti.sdo.ce.utils.trace.TraceUtil');

TraceUtil.attrs = TraceUtil.SOCRATES_TRACING;

 

/* Load support for the encoders */

var G711ENC = xdc.useModule('ti.sdo.codecs.g711enc.ce.G711ENC');

var H264ENC = xdc.useModule('ti.sdo.codecs.h264enc.ce.H264ENC');

var MPEG4ENC = xdc.useModule('ti.sdo.codecs.mpeg4enc.ce.MPEG4ENC');

var audioCopy = xdc.useModule('audcp_codec.AUDCP');

/*

 *  ======== Engine Configuration ========

 */

var Engine = xdc.useModule('ti.sdo.ce.Engine');

var demoEngine = Engine.create("encode", [

    {name: "h264enc", mod: H264ENC, local: false},

    {name: "g711enc", mod: G711ENC, local: false},

    {name: "mpeg4enc", mod: MPEG4ENC, local: false},

]);

var myEngine = Engine.create("audcp_engine", [

    {name: "audcp", mod: audioCopy, local: false},

]);

/* Remote server image */

demoEngine.server = "./encodeCombo.x64P";

myEngine.server = "./audcpServer.x64P";

Program.main = Program.system =null;

 

It is obvious that I just add some same lines to open the second codec engine.

The compile work finished successful.

However, the following error  message appear when I ran the program. 

CEapp-> ERROR: can't open engine audcp_engine.

Which meant that the codec engine I added couldn't be opened.

Can anyone help?

 

 

  • Hello!

     

    Your problem seems quite cryptic to me at the moment, so i ask the trivial question: is "audcpServer.x64P" in the same directory as your application?

     And a sidenote:

    You have 2 codec combos:

    -one containing g711enc, h264enc, mpeg4enc

    -and another containing audcp.

     

    If you have the audcp codec library, i think it would be a better idea to put it in the codec server containing the other 3 codecs.

    (codec servers contain the memory layout for the dsp, so using more than 1 opens up nightmarish possibilities for conficts)

  • Dear Pamer, 

             For your question 1. Yes, I did put the audcpServer.x64P in the same directory with my application when I ran it.

    For your sidenote. Yes, your note is right. I have two engines. One contains the g711enc, h264enc, and mpeg4enc, and this one is provided by the DVSDK.

    The other one containing audcp is actually one engine I made for my DSP-side program. 

    So, I do have the audcp library. Is there any tutorial or material for me to read to integrate my own to the server provided by DVSDK?

    THX!

  • I'm sure there are materials on this subject, as it's rather simple:

    I suppose you're using the encode server from the dvsdk, so in order to put your codec in it, you have to edit:

    -server (.x64P): encode.cfg:

    var H264ENC = xdc.useModule('ti.sdo.codecs.h264enc.ce.H264ENC');
    var MPEG4ENC = xdc.useModule('ti.sdo.codecs.mpeg4enc.ce.MPEG4ENC');
    var G711ENC = xdc.useModule('ti.sdo.codecs.g711enc.ce.G711ENC');
    var <your codec variable name> = xdc.useModule('<your codec repo path>');


    Server.algs = [
    {name: "h264enc", mod: H264ENC, groupId: 0, threadAttrs: {stackMemId: 0, priority: Server.MINPRI + 1}},  
    {name: "mpeg4enc", mod: MPEG4ENC, groupId: 0, threadAttrs: {stackMemId: 0, priority: Server.MINPRI + 1}},
    {name: "g711enc", mod: G711ENC, groupId: 1, threadAttrs: {stackMemId: 0, priority: Server.MINPRI + 2}},
    {name: "<your codec name in your arm code>", mod: <your codec variable name>, groupId: 1, threadAttrs: {stackMemId: 0, priority: Server.MINPRI + 2}},
    ];

     -client (application running on arm): encode.cfg?

    (You should be using createfromserver, as it's much simpler)

     var demoEngine = Engine.createFromServer(
    "encode",
    "./encodeCombo.x64P",
    "ti.sdo.servers.encode"
    );

  • Dear Chris Ring,
            Forgive my poor English. I hope you can understand what I mean.
            I encountered some problems. I'm working on creating a codec server, which integrate g723 and g729 codec algorithms. When g723 algorithm working alone, it goes well. And g729 algorithm is the same case. But when integrating two codecs, error comes.
            when g723 codec algorithm working alone,I find that SPHENC1_create() function in my program will call the SPHENC1_create() function's source code in  a sphenc1.c file, where 'MODNAME' is defined as "ti.sdo.ce.speech1.SPHENC1" and 'SPHENC1_VISATYPE' defined as "ti.sdo.ce.speech1.ISPHENC1" in its sphenc1.h.
            when g729 codec algorithm working alone, the SPHENC1_create() function in my program will call the source code in another sphenc1.c, where 'MODNAME' is defined as "ti.sdo.ce.examples.extensions.speech1.SPHENC1" ,and the 'SPHENC1_VISATYPE' is defined as "ti.sdo.ce.examples.extensions.speech1.ISPHENC1" in its sphenc1.h.
            Then I integrate g723 and g729 codec algorithms together.
            The following is the modified *.cfg file:  

         
    ***********************************************************************************************************************************     
    var platformName = Program.platformName;
    var platform = Program.platform;
    var heapConfig = xdc.loadCapsule('ti/sdo/ce/examples/buildutils/heap_config.cfg');
    var internalMemoryName = heapConfig.getInternalHeapName();
    var internalHeapSize = 0xc000;
    var externalMemoryName = heapConfig.getExternalHeapName();
    var externalHeapSize = 0x20000;

    Program.global.EXT_HEAP =
        heapConfig.createHeapMem(externalHeapSize, ".EXT_HEAP", "DDR3_DSP");
    Program.global.INT_HEAP =
        heapConfig.createHeapMem(internalHeapSize, ".INT_HEAP", "IRAM");

    var DDRALGMemoryName = "DDRALGHEAP";
    var DDRALGHeapSize = platform.externalMemoryMap[DDRALGMemoryName].len;

    Program.global.EXTALG_HEAP     = heapConfig.createHeapMem(DDRALGHeapSize, ".EXTALG_HEAP", DDRALGMemoryName);
    Program.sectMap[".text"]      = externalMemoryName;

    var Memory = xdc.useModule('xdc.runtime.Memory');

    Memory.defaultHeapInstance = Program.global.EXTALG_HEAP;

    xdc.useModule('ti.sysbios.xdcruntime.Settings');

    var BIOS = xdc.useModule("ti.sysbios.BIOS");

    BIOS.libType             = BIOS.LibType_Custom;
    BIOS.logsEnabled        = false;
    BIOS.assertsEnabled     = false;

    var Diags = xdc.useModule("xdc.runtime.Diags");
    var Load  = xdc.useModule("ti.sysbios.utils.Load");
    Load.hwiEnabled  = true;
    Load.swiEnabled  = true;
    Load.taskEnabled = true;
    Load.common$.diags_USER4 = Diags.ALWAYS_OFF;

    var Cache = xdc.useModule('ti.sysbios.family.c64p.Cache');
    Cache.MAR0_31    = 0xffffffff;
    Cache.MAR32_63   = 0xffffffff;
    Cache.MAR64_95   = 0xffffffff;
    Cache.MAR96_127  = 0xffffffff;
    Cache.MAR128_159 = 0xffffffff;
    Cache.MAR160_191 = 0xffffffff;
    Cache.MAR192_223 = 0xffffffff;
    Cache.MAR224_255 = 0xffffffff;
    Cache.initSize.l1pSize = Cache.L1Size_32K;
    Cache.initSize.l1dSize = Cache.L1Size_32K;
    Cache.initSize.l2Size  = Cache.L2Size_256K;

    var platformName = Program.platformName;
    var osalGlobal   = xdc.useModule('ti.sdo.ce.osal.Global');

    osalGlobal.runtimeEnv = osalGlobal.DSPLINK_BIOS;

    var myName = "DSP";

    var MultiProc = xdc.useModule('ti.sdo.utils.MultiProc');
    var settings  = xdc.useModule('ti.sdo.ipc.family.Settings');
    var procNames = settings.getDeviceProcNames();

    MultiProc.setConfig(myName, procNames);

    var platformBaseName = platformName.replace(/(\w+)\:.*$/, "$1").replace(/\./g, "_");
    try {
        xdc.loadCapsule(platformBaseName + ".cfg");
    } catch(e) {
        throw "Error: cannot load example's platform capsule '" + platformBaseName + ".cfg' (either it doesn't exist or there's an error inside it)";
    }

    var G729ABDEC =
        xdc.useModule('ti.sdo.ce.examples.codecs.g729abdec.G729ABDEC');
    var G729ABENC =
        xdc.useModule('ti.sdo.ce.examples.codecs.g729abenc.G729ABENC');
    var G7231ADEC =
        xdc.useModule('ti.sdo.ce.examples.codecs.g7231adec.G7231ADEC');
    var G7231AENC =
        xdc.useModule('ti.sdo.ce.examples.codecs.g7231aenc.G7231AENC');

    var Server = xdc.useModule('ti.sdo.ce.Server');

    Server.threadAttrs.stackSize = 2048;

    Server.threadAttrs.priority = Server.MINPRI;

    Server.stackSizePad = 9000;

    Server.algs = [
        {name: "g729abdec", mod: G729ABDEC, groupId: 0, threadAttrs: {
            stackSize: 4096, stackMemId: 0, priority: Server.MAXPRI}
        },
        {name: "g729abenc", mod: G729ABENC, groupId: 0, threadAttrs: {
            stackSize: 4096, stackMemId: 0, priority: Server.MAXPRI}
        },
        {name: "g7231adec", mod: G7231ADEC, groupId: 0, threadAttrs: {
            stackSize: 4096, stackMemId: 0, priority: Server.MAXPRI}
        },
        {name: "g7231aenc", mod: G7231AENC, groupId: 0, threadAttrs: {
            stackSize: 4096, stackMemId: 0, priority: Server.MAXPRI}
        },
    ];

    var DSKT2 = xdc.useModule('ti.sdo.fc.dskt2.DSKT2');
    DSKT2.DARAM0         = "EXTALG_HEAP";
    DSKT2.DARAM1         = "EXTALG_HEAP";
    DSKT2.DARAM2         = "EXTALG_HEAP";
    DSKT2.SARAM0         = "EXTALG_HEAP";
    DSKT2.SARAM1         = "EXTALG_HEAP";
    DSKT2.SARAM2         = "EXTALG_HEAP";
    DSKT2.ESDATA         = "EXTALG_HEAP";
    DSKT2.EPROG          = "EXTALG_HEAP";
    DSKT2.IPROG          = "EXTALG_HEAP";
    DSKT2.DSKT2_HEAP     = "EXT_HEAP";

    DSKT2.ALLOW_EXTERNAL_SCRATCH = true;
    DSKT2.SARAM_SCRATCH_SIZES[0] = 32 * 1024;

    var RMAN = xdc.useModule('ti.sdo.fc.rman.RMAN');
    RMAN.useDSKT2  = true;
    RMAN.tableSize = 10;

    xdc.loadCapsule('ti/sdo/ce/examples/buildutils/server_log.cfg');
    ***********************************************************************************************************************************


            In the above case,g723 codec works well, while g729 codec not. When g729 codec app program running to SPHENC1_create(),it calls the source code of SPHENC1_create() function in sphenc1.c, where 'MODNAME' is defined as "ti.sdo.ce.speech1.SPHENC1" and SPHENC1_VISATYPE defined as "ti.sdo.ce.speech1.ISPHENC1" in the corresponding sphenc1.h.

            Actually, another sphenc1.c, where 'MODNAME' is defined as "ti.sdo.ce.examples.extensions.speech1.SPHENC1", and the corresponding sphenc1.h,where SPHENC1_VISATYPE is defined as "ti.sdo.ce.examples.extensions.speech1.ISPHENC1", are for g729 codec.
            
           And then I make some modifies as follows:


    ***********************************************************************************************************************************
    ...
    var G7231ADEC =
        xdc.useModule('ti.sdo.ce.examples.codecs.g7231adec.G7231ADEC');
    var G7231AENC =
        xdc.useModule('ti.sdo.ce.examples.codecs.g7231aenc.G7231AENC');
    var G729ABDEC =
        xdc.useModule('ti.sdo.ce.examples.codecs.g729abdec.G729ABDEC');
    var G729ABENC =
        xdc.useModule('ti.sdo.ce.examples.codecs.g729abenc.G729ABENC');
    ...

    Server.algs = [
        {name: "g7231adec", mod: G7231ADEC, groupId: 0, threadAttrs: {
            stackSize: 4096, stackMemId: 0, priority: Server.MAXPRI}
        },
        {name: "g7231aenc", mod: G7231AENC, groupId: 0, threadAttrs: {
            stackSize: 4096, stackMemId: 0, priority: Server.MAXPRI}
        },
        {name: "g729abdec", mod: G729ABDEC, groupId: 0, threadAttrs: {
            stackSize: 4096, stackMemId: 0, priority: Server.MAXPRI}
        },
        {name: "g729abenc", mod: G729ABENC, groupId: 0, threadAttrs: {
            stackSize: 4096, stackMemId: 0, priority: Server.MAXPRI}
        },    
    ];
    ...
    ***********************************************************************************************************************************   

          
    Then g729 codec works well, while g723 codec not. It seems like g723 codec's sphenc1.c file and sphenc1.h file are discarded.


    After I modify the *.cfg file as follows:
    ***********************************************************************************************************************************
    ...
    var G729ABDEC =
        xdc.useModule('ti.sdo.ce.examples.codecs.g729abdec.G729ABDEC');
    var G729ABENC =
        xdc.useModule('ti.sdo.ce.examples.codecs.g729abenc.G729ABENC');
    var G7231ADEC =
        xdc.useModule('ti.sdo.ce.examples.codecs.g7231adec.G7231ADEC');
    var G7231AENC =
        xdc.useModule('ti.sdo.ce.examples.codecs.g7231aenc.G7231AENC');
    ...

    Server.algs = [
        {name: "g7231adec", mod: G7231ADEC, groupId: 0, threadAttrs: {
            stackSize: 4096, stackMemId: 0, priority: Server.MAXPRI}
        },
        {name: "g7231aenc", mod: G7231AENC, groupId: 0, threadAttrs: {
            stackSize: 4096, stackMemId: 0, priority: Server.MAXPRI}
        },
        {name: "g729abdec", mod: G729ABDEC, groupId: 0, threadAttrs: {
            stackSize: 4096, stackMemId: 0, priority: Server.MAXPRI}
        },
        {name: "g729abenc", mod: G729ABENC, groupId: 0, threadAttrs: {
            stackSize: 4096, stackMemId: 0, priority: Server.MAXPRI}
        },    
    ];
    ...
    ***********************************************************************************************************************************
    both codec can't work.The log messages in two sphenc1.c files mix together.It seems like two sphenc1.c files mixed together.

    This errors  really stumped me, I need your help.

    THX!



            
           

           
  • Hello buga tti:

       You mention "ti.sdo.ce.examples.extensions.speech1", but I don't see that mentioned in the CFG file, or in any xdc.useModule() statement.   Do you have a package definition in a  ti/sdo/ce/examples/extensions/speech1 directory?

       What does your VISA_create() call look like? 

       Like this:

        visa = VISA_create(engine, name, (IALG_Params *)params,
            sizeof (_SPHENC1_Msg), "ti.sdo.ce.examples.extensions.speech1.ISPHENC1");
    or this?

       
    visa = VISA_create(engine, name, (IALG_Params *)params,
            sizeof (_SPHENC1_Msg), "ti.sdo.ce.speech1.ISPHENC1");

    Does the path in the VISA_create() call point to an ISPHENC1.xdc file that actually exists?

        It might help if you can post your error messages from CE trace.


    - Gil
  • Hi Gil,

    Thank you for your patience.

    I have solved this problem. The package defined in ti/sdo/ce/examples/extensions/speech1 directory is a modified "ti.sdo.ce.speech1" package, which can process two data frames each time. Then I modified the G7231A***.xdc file to make it inherit ti.sdo.ce.examples.extensions.speech1.***, it works well. Thank you anyway.


    With Best Regards,

    Buga