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.

dm6467 failed to creat video decoder

hi

        I am studying at dm6467, i changed encodedecode example for ImageBinary, the algorithm name is filecoy_dec, and the server name is file_copy.x64p, in video.c  I write these code:

  hVd2 = Vdec2_create(hEngine, "filecopy_dec", &decParams, &decDynParams);

        if (hVd2 == NULL) {
            ERR("Failed to create filecopy_dec video decoder\n");
            cleanup(THREAD_FAILURE);
        }

image_colorbinary is app name , when i run it , "Failed to create filecopy_dec video decoder", why? image_colorbinary .cfg is :

var FILECOPYDEC = xdc.useModule('codecs.filecopy_dec.FILECOPYDEC');

/*
 *  ======== Engine Configuration ========
 */
var Engine = xdc.useModule('ti.sdo.ce.Engine');
var myEngine = Engine.createFromServer("file_copy", [
    {name: "filecopy_dec", mod: FILECOPYDEC, local: false, groupId: 0},
],
"./ImageColorBinary.x64P",
"servers.file_copy");

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

/* Load support for the 'Davinci Multimedia Application Interface' module */
var DMAI = xdc.loadPackage('ti.sdo.dmai');

/* Load support for SimpleWidget */
var SW = xdc.loadPackage('ti.sdo.simplewidget');

Program.main = Program.system = null;

and the file_copy.cfg is

/* set up OSAL */
var osalGlobal = xdc.useModule('ti.sdo.ce.osal.Global');
osalGlobal.runtimeEnv = osalGlobal.DSPLINK_BIOS;


environment['xdc.cfg.check.fatal'] = 'false';

osalGlobal.defaultMemSegId = "DDR2";


/* activate BIOS logging module */
var LogServer = xdc.useModule('ti.sdo.ce.bioslog.LogServer');

/* get various codec modules; i.e., implementation of codecs */
var FILECOPYDEC = xdc.useModule('codecs.filecopy_dec.FILECOPYDEC');

var Server = xdc.useModule('ti.sdo.ce.Server');
Server.threadAttrs.stackSize = 4096;
Server.threadAttrs.priority = Server.MINPRI;
Server.autoGenScratchSizeArrays = true;

Server.algs = [
    {name: "filecopy_dec", mod: FILECOPYDEC, threadAttrs:
 {
        stackMemId: 0,
 priority: Server.MINPRI + 1
 },groupId :  0,
 },
   ];


/* we can use DMA in certain codecs! */
/*FILECOPYENC.useDMA = true;*/

/*
 *  ======== DSKT2 (XDAIS Alg. memory alocation ) configuration ========
 */


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

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

var DMAN3 = xdc.useModule('ti.sdo.fc.dman3.DMAN3');
DMAN3.heapInternal    = "L1DHEAP";       /* L1DHEAP is an internal segment */
// DMAN3.heapInternal = "DDRALGHEAP";    /* DDRALGHEAP is an external segment */
DMAN3.heapExternal    = "DDRALGHEAP";
DMAN3.idma3Internal   = false;
DMAN3.scratchAllocFxn = "DSKT2_allocScratch";
DMAN3.scratchFreeFxn  = "DSKT2_freeScratch";

DMAN3.paRamBaseIndex     = 80;  // 1st EDMA3 PaRAM set available for DMAN3
DMAN3.numQdmaChannels    = 8;   // number of device's QDMA channels to use
DMAN3.qdmaChannels       = [0,1,2,3,4,5,6,7]; // choice of QDMA channels to use
DMAN3.numPaRamEntries    = 48;  // number of PaRAM sets exclusively used by DMAN
DMAN3.numPaRamGroup[0]   = 48;  // number of PaRAM sets for scratch group 0
DMAN3.numTccGroup[0]     = 32;  // number of TCCs assigned to scratch group 0
DMAN3.tccAllocationMaskL = 0;   // bit mask indicating which TCCs 0..31 to use
DMAN3.tccAllocationMaskH = 0xffffffff; // assign all TCCs 32..63 for DMAN

 

Program.main = Program.system = null;

anyone can help me ? thank you very much!

 

 

  • Hi,

    Which DVSDK are you using. All the DVSDK demo app should work out of box (just following the instructions).  You should use that as reference for your implementation.

    regards

    Yashwant

  • dvsdk_1_40_02_33

  • I am sorry to reply you at right time, I am using dvsdk_1_40_02_33, and i just don't understand "All the DVSDK demo app should work out of box " because of my poor english, i am dubuging the program,but i am also in the trouble of  "dm6467 failed to creat video decoder" ,thank you

  • Hi,

    The codec creation fails most of the time because the creation params are not correct

    Please check decParams in the call below and make sure that the value of these params is valid for the decoder you are using

    hVd2 = Vdec2_create(hEngine, "filecopy_dec", &decParams, &decDynParams);

     

    Thanks

    Cesar

  • Hi

                thank you , the params are as following:

     Void *videoThrFxn(Void *arg)
    {
        VideoEnv               *envp            = (VideoEnv *) arg;
        Void                   *status          = THREAD_SUCCESS;
        VIDDEC2_Params          decParams       = Vdec2_Params_DEFAULT;
        VIDDEC2_DynamicParams   decDynParams    = Vdec2_DynamicParams_DEFAULT;
     //   VIDENC1_Params          encParams       = Venc1_Params_DEFAULT;
        BufferGfx_Attrs         gfxAttrs        = BufferGfx_Attrs_DEFAULT;
        Buffer_Attrs            bAttrs          = Buffer_Attrs_DEFAULT;
        Vdec2_Handle            hVd2            = NULL;
        BufTab_Handle           hBufTab         = NULL;
        Engine_Handle           hEngine         = NULL;
        Buffer_Handle           hEncBuf         = NULL;
        Int                     ret             = Dmai_EOK;
        Int                     numBufs         = 0;
        Buffer_Handle           hVidBuf, hDispBuf, hDstBuf;
        Int32                   bufSize;
        Int                     fifoRet;
        Int                     bufIdx;

        /* Use extended dynamic parameters to allow tweaking of the QP value */

        gfxAttrs.colorSpace = ColorSpace_YUV420PSEMI;
        gfxAttrs.dim.width = envp->imageWidth;
        gfxAttrs.dim.height = envp->imageHeight;
        gfxAttrs.dim.lineLength = BufferGfx_calcLineLength(gfxAttrs.dim.width,
                                                           gfxAttrs.colorSpace);

        if (envp->passThrough) {
            /*
             * Calculate buffer size needed of a video resolution for 420P.
             * This shouldn't be done if codecs are being used, since
             * the buffers  may require additional space due to padding.
             */
            bufSize = gfxAttrs.dim.lineLength * gfxAttrs.dim.height * 3 / 2;

            /* Only the display thread can own a buffer since no codecs are used */
            gfxAttrs.bAttrs.useMask = DISPLAY_FREE;
        }
        else {
            /* Open the codec engine */
            hEngine = Engine_open(envp->engineName, NULL, NULL);

            if (hEngine == NULL) {
                ERR("Failed to open codec engine %s\n", envp->engineName);
                cleanup(THREAD_FAILURE);
            }

            decParams.maxWidth   = envp->imageWidth;
            decParams.maxHeight  = envp->imageHeight;

            /* Create the video decoder */
            hVd2 = Vdec2_create(hEngine, "filecopy_dec", &decParams, &decDynParams);

            if (hVd2 == NULL) {
                ERR("Failed to create filecopy_dec video decoder\n");
                cleanup(THREAD_FAILURE);

     

    and the filecopy_dec is ImageBinary algrithm, i  will try to change the params,and can you give me some suggestion ,thank you

  • Hi,

    I am not sure what the filecopy_dec algorithm is. If you have the source code you should check what are the valid values for the decParams

    Thanks

    cesar

  • Hi

    I am still solve the problem, my algorithm is added in the viddec_copy and changed, can you help me check the source:

    filecopy.c

    #include <xdc/std.h>
    #include <string.h>

    #include <ti/xdais/dm/ividdec.h>
    #include <ti/sdo/ce/trace/gt.h>

    #include "filecopy_dec_ysq.h"
    #include "filecopy_dec_ysq_priv.h"

    /* buffer definitions */
    #define MININBUFS       1
    #define MINOUTBUFS      1
    #define MININBUFSIZE    1
    #define MINOUTBUFSIZE   1

    extern IALG_Fxns FILECOPYDEC_YSQ_IALG;

    #define IALGFXNS  \
        &FILECOPYDEC_YSQ_IALG, /* module ID */                         \
        NULL,                /* activate */                          \
        FILECOPYDEC_YSQ_alloc, /* alloc */                             \
        NULL,                /* control (NULL => no control ops) */  \
        NULL,                /* deactivate */                        \
        FILECOPYDEC_YSQ_free,  /* free */                              \
        FILECOPYDEC_YSQ_initObj,  /* init */                           \
        NULL,                /* moved */                             \
        NULL                 /* numAlloc (NULL => IALG_MAXMEMRECS) */


    IVIDDEC_Fxns FILECOPYDEC_YSQ_FILECOPYDEC = {    /* module_vendor_interface */
        {IALGFXNS},
        FILECOPYDEC_YSQ_process,
        FILECOPYDEC_YSQ_control,
    };

    #ifdef _TI_

    asm("_FILECOPYDEC_YSQ_IALG .set _FILECOPYDEC_YSQ_FILECOPYDEC");

    #else
     

    IALG_Fxns FILECOPYDEC_YSQ_IALG = {     
        IALGFXNS
    };

    #endif

    /* tracing information */
    #define GTNAME "codecs.filecopy_dec"
    static GT_Mask curTrace = {NULL,NULL};


    Int FILECOPYDEC_YSQ_alloc(const IALG_Params *algParams,
        IALG_Fxns **pf, IALG_MemRec memTab[])
    {
        if (curTrace.modName == NULL) {   /* initialize GT (tracing) */
            GT_create(&curTrace, GTNAME);
        }

        GT_3trace(curTrace, GT_ENTER, "FILECOPYDEC_YSQ_alloc(0x%lx, 0x%lx, 0x%lx)\n",
            algParams, pf, memTab);

        /* Request memory for my object */
        memTab[0].size = sizeof(FILECOPYDEC_YSQ_Obj);
        memTab[0].alignment = 0;
        memTab[0].space = IALG_EXTERNAL;
        memTab[0].attrs = IALG_PERSIST;

        return (1);
    }


    Int FILECOPYDEC_YSQ_free(IALG_Handle handle, IALG_MemRec memTab[])
    {
        GT_2trace(curTrace, GT_ENTER, "FILECOPYDEC_YSQ_free(0x%lx, 0x%lx)\n",
            handle, memTab);

        FILECOPYDEC_YSQ_alloc(NULL, NULL, memTab);
        return (1);
    }


    Int FILECOPYDEC_YSQ_initObj(IALG_Handle handle,
        const IALG_MemRec memTab[], IALG_Handle p,
        const IALG_Params *algParams)
    {
        GT_4trace(curTrace, GT_ENTER, "FILECOPYDEC_YSQ_initObj(0x%lx, 0x%lx, 0x%lx, "
            "0x%lx)\n", handle, memTab, p, algParams);

        return (IALG_EOK);
    }

    static void PictureBlackWhite(void *pInbuf,void *pOutbuf,unsigned int len);

    XDAS_Int32 FILECOPYDEC_YSQ_process(IVIDDEC_Handle h, XDM_BufDesc *inBufs,
        XDM_BufDesc *outBufs, IVIDDEC_InArgs *inArgs, IVIDDEC_OutArgs *outArgs)
    {
        XDAS_Int32 curBuf;
        XDAS_Int32 minSamples;

        GT_5trace(curTrace, GT_ENTER, "FILECOPYDEC_YSQ_process(0x%lx, 0x%lx, 0x%lx, "
            "0x%lx, 0x%lx)\n", h, inBufs, outBufs, inArgs, outArgs);

        /* validate arguments - this codec only supports "base" xDM. */
        if ((inArgs->size != sizeof(*inArgs)) ||
            (outArgs->size != sizeof(*outArgs))) {

            GT_2trace(curTrace, GT_ENTER, "FILECOPYDEC_YSQ_process, unsupported size "
                "(0x%lx, 0x%lx)\n", inArgs->size, outArgs->size);

            return (IVIDDEC_EFAIL);
        }
        /* outArgs->bytesConsumed reports the total number of bytes consumed */
        outArgs->bytesConsumed = 0;

        for (curBuf = 0; (curBuf < inBufs->numBufs)&&(curBuf < outBufs->numBufs); curBuf++)
        {
            //* there's an available in and out buffer, how many samples?
            minSamples = inBufs->bufSizes[curBuf] < outBufs->bufSizes[curBuf] ?
                      inBufs->bufSizes[curBuf] : outBufs->bufSizes[curBuf];

            //* process the data: read input, produce output
          //memcpy(outBufs->bufs[curBuf], inBufs->bufs[curBuf], minSamples);
    PictureBlackWhite(inBufs->bufs[curBuf],outBufs->bufs[curBuf],minSamples);
            GT_1trace( curTrace, GT_2CLASS, "FILECOPYDEC_YSQ_process> "
                   "Processed %d bytes.\n", minSamples );
            outArgs->bytesConsumed += minSamples;
        }

        /* Fill out the rest of the outArgs struct */
        outArgs->extendedError = 0;
        outArgs->decodedFrameType = 0;     /* TODO */
        outArgs->outputID = inArgs->inputID;
        outArgs->displayBufs.numBufs = 0;  /* important: indicate no displayBufs */

        return (IVIDDEC_EOK);
    }


    XDAS_Int32 FILECOPYDEC_YSQ_control(IVIDDEC_Handle handle, IVIDDEC_Cmd id,
        IVIDDEC_DynamicParams *params, IVIDDEC_Status *status)
    {
        XDAS_Int32 retVal;

        GT_4trace(curTrace, GT_ENTER, "FILECOPYDEC_YSQ_control(0x%lx, 0x%lx, 0x%lx, "
            "0x%lx)\n", handle, id, params, status);

        /* validate arguments - this codec only supports "base" xDM. */
        if ((params->size != sizeof(*params)) ||
            (status->size != sizeof(*status))) {

            GT_2trace(curTrace, GT_ENTER, "FILECOPYDEC_YSQ_control, unsupported size "
                "(0x%lx, 0x%lx)\n", params->size, status->size);

            return (IVIDDEC_EFAIL);
        }

        switch (id) {
            case XDM_GETSTATUS:
                status->extendedError = 0;
                status->outputHeight = 0;  /* TODO */
                status->outputWidth = 0;  /* TODO */
                status->frameRate = 0;  /* TODO */
                status->bitRate = 0;  /* TODO */
                status->contentType = 0;  /* TODO */
                status->outputChromaFormat = 0;  /* TODO */
                status->bufInfo.minNumInBufs = MININBUFS;
                status->bufInfo.minNumOutBufs = MINOUTBUFS;
                status->bufInfo.minInBufSize[0] = MININBUFSIZE;
                status->bufInfo.minOutBufSize[0] = MINOUTBUFSIZE;

                retVal = IVIDDEC_EOK;

                break;

            default:
                /* unsupported cmd */
                retVal = IVIDDEC_EFAIL;

                break;
        }

        return (retVal);
    }

    static void PictureBlackWhite(void *pInbuf,void *pOutbuf,unsigned int len)
    {
        unsigned int yh,yl;//cr,cb;
        unsigned int i,temp;
        unsigned int * pIn = (unsigned int*)pInbuf;
        unsigned int * pOut= (unsigned int*)pOutbuf;

        len >>= 2;
        for(i=0;i<len;i++)
        {
     temp = *pIn;
     yh = (temp >> 24)&0xff;
     yl = (temp >>  8)&0xff;
     yh = ((yh > 0x80) ? 0xff : 0x00);
     yl = ((yl > 0x80) ? 0xff : 0x00);

     *pOut = (yh<<24) | (yl << 8) | (temp & 0x00ff00ff);
     pIn ++;
     pOut ++;
        }
    }

     

    thanks

    Dingguo Peng