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.

Got screen messed up while using DEI link for scaling



Dear all:

We are using DM8168 and DVRRDK_04.00.00.03, and plan to use DEI link for scaling,

The following is my link chain:
Capture (YUV422I 1CH 2464*2048)
        |
NSF (YUV420SP 1CH 2464*2048)
        |
DEI (YUV420SP 1CH 704*480)
        |
    DUP
        |
|---------------|
|                    |
...            IPC Frames Out1 (M3)
                     |
               IPC Frames In0 (A8)
                     |
               write to yuv file, then convert to jpg file

Out of NSF, VideoDataFormat is SYSTEM_DF_YUV420SP_UV, VideoScanFormat is SYSTEM_SF_PROGRESSIVE.

Below is my dei parameters:

DeiLink_CreateParams_Init(&deiPrm);
deiPrm.setVipScYuv422Format = FALSE;
deiPrm.inputDeiFrameRate = 30;
deiPrm.outputDeiFrameRate = 30;
deiPrm.enableDeiForceBypass = TRUE;
deiPrm.enableOut[DEI_LINK_OUT_QUE_VIP_SC] = TRUE;
deiPrm.tilerEnable[DEI_LINK_OUT_QUE_VIP_SC] = FALSE;
for(chId=0; chId<DEI_LINK_MAX_CH; chId++)
{
deiPrm.outScaleFactor[DEI_LINK_OUT_QUE_VIP_SC][chId].scaleMode = DEI_SCALE_MODE_ABSOLUTE;
deiPrm.outScaleFactor[DEI_LINK_OUT_QUE_VIP_SC][chId].absoluteResolution.outWidth = 704;
deiPrm.outScaleFactor[DEI_LINK_OUT_QUE_VIP_SC][chId].absoluteResolution.outHeight = 480;
}
deiPrm.inputFrameRate[DEI_LINK_OUT_QUE_VIP_SC] = 30;
deiPrm.outputFrameRate[DEI_LINK_OUT_QUE_VIP_SC] = 30;
deiPrm.numBufsPerCh[DEI_LINK_OUT_QUE_VIP_SC] = 4;
deiPrm.inQueParams.prevLinkId = nsfId;
deiPrm.inQueParams.prevLinkQueId = 0;
deiPrm.outQueParams[DEI_LINK_OUT_QUE_VIP_SC].nextLink = dupId;

When I run the system, I got screen messed up with no scaling, shows as the following jpg file:

If I remove DEI link, I got correct screen, shows as the following jpg file:

I also tried 1:1 scaling, that is, modify the followning two lines
deiPrm.outScaleFactor[DEI_LINK_OUT_QUE_VIP_SC][chId].absoluteResolution.outWidth = 704;
deiPrm.outScaleFactor[DEI_LINK_OUT_QUE_VIP_SC][chId].absoluteResolution.outHeight = 480;
to
deiPrm.outScaleFactor[DEI_LINK_OUT_QUE_VIP_SC][chId].absoluteResolution.outWidth = 2464;
deiPrm.outScaleFactor[DEI_LINK_OUT_QUE_VIP_SC][chId].absoluteResolution.outHeight = 2048;
and still got screen messed up, shows as the following jpg file:

How can I get correct scaling with DEI? Thanks!

  • Attach your usecase file and the app code which is writing the yuv to file. You are using wrong yuv format for writing or your pitch is wrong.

  • Also your input resolution is greater than 1920x1080.You will have to use MpSclr link to scale resolution greater than 1920x1080.

  • Hi, Badri !

    Thanks for your so quick relay!

    usecase file:

    /*******************************************************************************
     *                                                                             *
     * Copyright (c) 2009 Texas Instruments Incorporated - http://www.ti.com/      *
     *                        ALL RIGHTS RESERVED                                  *
     *                                                                             *
     ******************************************************************************/
    
    /*
                                               Capture (YUV422I 1CH 2464*2048)
                                                   |
                                               NSF (YUV420SP 1CH 2464*2048)
                                                   |
                                                   |
                                                  DEI (YUV420SP 1CH 704*480)
                                                   |
                                                  DUP
                                                   |
                            -----------------------|--------------------------------------------------------------------------------------------------------
                            |                                                                                                                              |
                            |                                                                        NullSrc0          NullSrc1                            |
                       IPC Frames Out0 (M3)--<<process link>>--IPC Frames In(DSP)--ALGLINK          (2464*2048)       (2464*2048)*4                 IPC Frames Out1 (M3)
                            |                                                                             |                |                               |
                            ------------------------------------------------------------------------------|----------------|                        IPC Frames In0 (A8)
                            |                                                                                                                              |
                     Merge(ipcFrameout0, nullSrc0)                                                                                              write to yuv file (then manually convert to jpg file)
                            |                            
                         IPC OUT (M3)                    
                            |                          
                         IPC IN  (M3)                  
                            |                                                             
                  Encode (1CH H264  + 1CH MJPEG  2448*2048)
                            |
                        IPC BITS OUT (M3)
                            |
                        IPC BITS IN  (A8)
    */                 
    
    #include "mcfw/src_linux/mcfw_api/usecases/multich_common.h"
    #include "mcfw/src_linux/mcfw_api/usecases/multich_ipcbits.h"
    #include "mcfw/src_linux/devices/tw2968/src/tw2968_priv.h"
    #include "mcfw/src_linux/devices/tvp5158/src/tvp5158_priv.h"
    #include "mcfw/interfaces/link_api/system_tiler.h"
    
    #define NUM_MERGE_LINK              (3)
    
    #define CAP_DUP_LINK_IDX_0          (0)
    #define CAP_DUP_LINK_IDX_1          (1)
    #define NUM_DUP_LINK                (2)
    
    #define     NUM_CAPTURE_DEVICES     (4)
    
    typedef struct {
    
        UInt32 mergeId[NUM_MERGE_LINK];
        UInt32 dupId[NUM_DUP_LINK];
        UInt32 ipcOutVpssId;
        UInt32 ipcInVideoId;
    
    } MultiCh_VcapVencVdisObj;
    
    MultiCh_VcapVencVdisObj gMultiCh_VcapVencVdisObj;
    
    /* =============================================================================
     * Use case code
     * =============================================================================
     */
    static SystemVideo_Ivahd2ChMap_Tbl systemVid_encDecIvaChMapTbl =
    {
        .isPopulated = 1,
        .ivaMap[0] =
        {
            .EncNumCh  = 3, //24,
            .EncChList = {0,1,2}, //{0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46},
            .DecNumCh  = 0,
            .DecChList = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        },
        .ivaMap[1] =
        {
            .EncNumCh  = 0, //1,//24,
            .EncChList = {1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47},
            .DecNumCh  = 0,
            .DecChList = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        },
        .ivaMap[2] =
        {
            .EncNumCh  = 0,
            .EncChList = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
            .DecNumCh  = 0,
            .DecChList = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        },
    };
    
    UInt32 vcap_venc_trying_dupId;
    
    Void MultiCh_createVcapVencVdis()
    {
        CaptureLink_CreateParams        capturePrm;
        NsfLink_CreateParams            nsfPrm;
    #define ADD_DEI_LINK_TEST
    #ifdef ADD_DEI_LINK_TEST
        DeiLink_CreateParams            deiPrm;
    #endif
        NullSrcLink_CreateParams        nullSrcPrm0;
        NullSrcLink_CreateParams        nullSrcPrm1;
        MergeLink_CreateParams          mergePrm;
        IpcLink_CreateParams            ipcOutVpssPrm;
        IpcLink_CreateParams            ipcInVideoPrm;
        EncLink_CreateParams            encPrm;
        IpcBitsOutLinkRTOS_CreateParams ipcBitsOutVideoPrm;
        IpcBitsInLinkHLOS_CreateParams  ipcBitsInHostPrm;
    
        DupLink_CreateParams dupPrm;
    
        IpcFramesInLinkRTOS_CreateParams  ipcFramesInDspPrm;
        IpcFramesOutLinkRTOS_CreateParams ipcFramesOutVpssPrm;
        IpcFramesOutLinkRTOS_CreateParams ipcFramesOutVpssPrm2;
        IpcFramesInLinkHLOS_CreateParams ipcFramesInHostPrm;
        AlgLink_CreateParams              dspAlgPrm;
    
        CaptureLink_VipInstParams *pCaptureInstPrm;
        CaptureLink_OutParams     *pCaptureOutPrm;
    
        VCAP_VIDEO_SOURCE_STATUS_S vidSourceStatus;
        VCAP_VIDEO_SOURCE_CH_STATUS_S *pVidStatus;
    
        int chId;
    
        MULTICH_INIT_STRUCT(IpcFramesInLinkRTOS_CreateParams,  ipcFramesInDspPrm);
        MULTICH_INIT_STRUCT(IpcFramesOutLinkRTOS_CreateParams, ipcFramesOutVpssPrm);
        MULTICH_INIT_STRUCT(IpcFramesOutLinkRTOS_CreateParams, ipcFramesOutVpssPrm2);
        MULTICH_INIT_STRUCT(IpcFramesInLinkHLOS_CreateParams,  ipcFramesInHostPrm);
        MULTICH_INIT_STRUCT(AlgLink_CreateParams, dspAlgPrm);
    
        MULTICH_INIT_STRUCT(IpcLink_CreateParams ,ipcOutVpssPrm);
        MULTICH_INIT_STRUCT(IpcLink_CreateParams ,ipcInVideoPrm);
        MULTICH_INIT_STRUCT(IpcBitsOutLinkRTOS_CreateParams,ipcBitsOutVideoPrm);
        MULTICH_INIT_STRUCT(IpcBitsInLinkHLOS_CreateParams,ipcBitsInHostPrm);
        MULTICH_INIT_STRUCT(EncLink_CreateParams, encPrm);
    
        MultiCh_detectBoard();
    
        System_linkControl(
            SYSTEM_LINK_ID_M3VPSS,
            SYSTEM_M3VPSS_CMD_RESET_VIDEO_DEVICES,
            NULL,
            0,
            TRUE
            );
    
        System_linkControl(
            SYSTEM_LINK_ID_M3VIDEO,
            SYSTEM_COMMON_CMD_SET_CH2IVAHD_MAP_TBL,
            &systemVid_encDecIvaChMapTbl,
            sizeof(SystemVideo_Ivahd2ChMap_Tbl),
            TRUE
        );
    
        /*Link ID*/
        gVcapModuleContext.captureId    = SYSTEM_LINK_ID_CAPTURE;
        gVcapModuleContext.nsfId[0]     = SYSTEM_LINK_ID_NSF_0;
    #ifdef ADD_DEI_LINK_TEST
        gVcapModuleContext.deiId[0]     = SYSTEM_LINK_ID_DEI_HQ_0;//SYSTEM_LINK_ID_DEI_0; // SYSTEM_LINK_ID_DEI_HQ_0 or SYSTEM_LINK_ID_DEI_0 ? which?
    #endif
        vcap_venc_trying_dupId          = SYSTEM_VPSS_LINK_ID_DUP_0;
    
        //gMultiCh_VcapVencVdisObj.dupId[0]            = SYSTEM_VPSS_LINK_ID_DUP_0;
        gMultiCh_VcapVencVdisObj.ipcOutVpssId   = SYSTEM_VPSS_LINK_ID_IPC_OUT_M3_0;
        gMultiCh_VcapVencVdisObj.ipcInVideoId  = SYSTEM_VIDEO_LINK_ID_IPC_IN_M3_0;
        gVencModuleContext.encId            = SYSTEM_LINK_ID_VENC_0;
        gVencModuleContext.ipcBitsOutRTOSId = SYSTEM_VIDEO_LINK_ID_IPC_BITS_OUT_0;
        gVencModuleContext.ipcBitsInHLOSId  = SYSTEM_HOST_LINK_ID_IPC_BITS_IN_0;
        gVcapModuleContext.nullSrcId0    = SYSTEM_VPSS_LINK_ID_NULL_SRC_0;
        gVcapModuleContext.nullSrcId1    = SYSTEM_VPSS_LINK_ID_NULL_SRC_1;
        gMultiCh_VcapVencVdisObj.mergeId[0] = SYSTEM_VPSS_LINK_ID_MERGE_0;
    
        gVcapModuleContext.dspAlgId[0] = SYSTEM_LINK_ID_ALG_0  ;
        gVcapModuleContext.ipcFramesOutVpssId[0] = SYSTEM_VPSS_LINK_ID_IPC_FRAMES_OUT_0;
        gVcapModuleContext.ipcFramesOutVpssId[1] = SYSTEM_VPSS_LINK_ID_IPC_FRAMES_OUT_1;
        gVcapModuleContext.ipcFramesInHostId = SYSTEM_HOST_LINK_ID_IPC_FRAMES_IN_0;
        gVcapModuleContext.ipcFramesInDspId[0]   = SYSTEM_DSP_LINK_ID_IPC_FRAMES_IN_0;
    
        /*capturePrm*/
        CaptureLink_CreateParams_Init(&capturePrm);
        capturePrm.numVipInst               = 1;
        capturePrm.outQueParams[0].nextLink = gVcapModuleContext.nsfId[0];
        capturePrm.tilerEnable              = FALSE;
        capturePrm.enableSdCrop             = FALSE;
        capturePrm.fakeHdMode               = TRUE;
        capturePrm.isPalMode                = FALSE;
        capturePrm.maxBlindAreasPerCh       = 4;
    
        pCaptureInstPrm                     = &capturePrm.vipInst[0];
        pCaptureInstPrm->vipInstId          = SYSTEM_CAPTURE_INST_VIP0_PORTA;
        pCaptureInstPrm->inDataFormat       = SYSTEM_DF_YUV422P;
        pCaptureInstPrm->standard           = SYSTEM_STD_1080P_60; 
        pCaptureInstPrm->numOutput          = 1;
    
        pCaptureOutPrm                      = &pCaptureInstPrm->outParams[0];
        pCaptureOutPrm->dataFormat          = SYSTEM_DF_YUV422I_YUYV;
        pCaptureOutPrm->scEnable            = FALSE;
        pCaptureOutPrm->scOutWidth          = 0;
        pCaptureOutPrm->scOutHeight         = 0;
        pCaptureOutPrm->outQueId          = 0;
    
        pVidStatus = &(vidSourceStatus.chStatus[0]);
        pVidStatus->isVideoDetect = TRUE;
        pVidStatus->frameWidth    = 2464;
        pVidStatus->frameHeight   = 2048;
        pVidStatus->frameInterval = 110;
        pVidStatus->isInterlaced  = FALSE;
        pVidStatus->vipInstId = 0;
        pVidStatus->chId = 0;
        vidSourceStatus.numChannels = 1;
        Vcap_setVideoSourceStatus(&vidSourceStatus);
    
        /*nsf param*/
        NsfLink_CreateParams_Init(&nsfPrm);
        nsfPrm.bypassNsf                 = TRUE;
        nsfPrm.tilerEnable               = FALSE;
        nsfPrm.inQueParams.prevLinkId    = gVcapModuleContext.captureId;
        nsfPrm.inQueParams.prevLinkQueId = 0;
    #ifdef ADD_DEI_LINK_TEST
        nsfPrm.outQueParams[0].nextLink  = gVcapModuleContext.deiId[0]; // gVcapModuleContext.ipcFramesOutVpssId[0];
    #else
        nsfPrm.outQueParams[0].nextLink  = vcap_venc_trying_dupId; // gVcapModuleContext.ipcFramesOutVpssId[0];
    #endif
    
    #ifdef ADD_DEI_LINK_TEST
        /*dei param*/
        DeiLink_CreateParams_Init(&deiPrm);
        deiPrm.setVipScYuv422Format        = FALSE;
        deiPrm.inputDeiFrameRate           = 30;
        deiPrm.outputDeiFrameRate          = 30;
        deiPrm.enableDeiForceBypass        = TRUE;
        deiPrm.enableOut[DEI_LINK_OUT_QUE_VIP_SC] = TRUE;
        deiPrm.tilerEnable[DEI_LINK_OUT_QUE_VIP_SC] = FALSE;
        for(chId=0; chId<DEI_LINK_MAX_CH; chId++)
        {
                deiPrm.outScaleFactor[DEI_LINK_OUT_QUE_VIP_SC][chId].scaleMode = DEI_SCALE_MODE_ABSOLUTE;
                deiPrm.outScaleFactor[DEI_LINK_OUT_QUE_VIP_SC][chId].absoluteResolution.outWidth  = 704;
                deiPrm.outScaleFactor[DEI_LINK_OUT_QUE_VIP_SC][chId].absoluteResolution.outHeight = 480;
        }
        deiPrm.inputFrameRate[DEI_LINK_OUT_QUE_VIP_SC]   = 30;
        deiPrm.outputFrameRate[DEI_LINK_OUT_QUE_VIP_SC]  = 30;
        deiPrm.numBufsPerCh[DEI_LINK_OUT_QUE_VIP_SC]     = 4;
        deiPrm.inQueParams.prevLinkId    = gVcapModuleContext.nsfId[0];
        deiPrm.inQueParams.prevLinkQueId = 0;
        deiPrm.outQueParams[DEI_LINK_OUT_QUE_VIP_SC].nextLink = vcap_venc_trying_dupId;
    #endif
    
        // dup
        memset(&dupPrm, 0, sizeof(dupPrm));
    #ifdef ADD_DEI_LINK_TEST
        dupPrm.inQueParams.prevLinkId         = gVcapModuleContext.deiId[0];
        dupPrm.inQueParams.prevLinkQueId      = DEI_LINK_OUT_QUE_VIP_SC; // DEI_LINK_OUT_QUE_VIP_SC/DEI_LINK_OUT_QUE_DEI_SC // 0;
    #else
        dupPrm.inQueParams.prevLinkId         = gVcapModuleContext.nsfId[0];
        dupPrm.inQueParams.prevLinkQueId      = 0;
    #endif
        dupPrm.numOutQue                      = 2;
        dupPrm.outQueParams[0].nextLink       = gVcapModuleContext.ipcFramesOutVpssId[0];
        dupPrm.outQueParams[1].nextLink       = gVcapModuleContext.ipcFramesOutVpssId[1];
        dupPrm.notifyNextLink                 = TRUE;
    
        /*frame out vpass*/
        ipcFramesOutVpssPrm.baseCreateParams.noNotifyMode = FALSE;
        ipcFramesOutVpssPrm.baseCreateParams.notifyNextLink = TRUE;
        ipcFramesOutVpssPrm.baseCreateParams.notifyPrevLink = TRUE;
        ipcFramesOutVpssPrm.baseCreateParams.notifyProcessLink = TRUE;
        ipcFramesOutVpssPrm.baseCreateParams.inQueParams.prevLinkId = vcap_venc_trying_dupId; // gVcapModuleContext.nsfId[0];
        ipcFramesOutVpssPrm.baseCreateParams.inQueParams.prevLinkQueId = 0;
        ipcFramesOutVpssPrm.baseCreateParams.outQueParams[0].nextLink = gMultiCh_VcapVencVdisObj.mergeId[0];
        ipcFramesOutVpssPrm.baseCreateParams.numOutQue = 1;
        ipcFramesOutVpssPrm.baseCreateParams.processLink = gVcapModuleContext.ipcFramesInDspId[0];
    
        /*frame out vpass 2 */
        ipcFramesOutVpssPrm2.baseCreateParams.noNotifyMode = FALSE;
        ipcFramesOutVpssPrm2.baseCreateParams.notifyNextLink = TRUE;
        ipcFramesOutVpssPrm2.baseCreateParams.notifyPrevLink = TRUE;
        ipcFramesOutVpssPrm2.baseCreateParams.notifyProcessLink = FALSE;
        ipcFramesOutVpssPrm2.baseCreateParams.inQueParams.prevLinkId = vcap_venc_trying_dupId;
        ipcFramesOutVpssPrm2.baseCreateParams.inQueParams.prevLinkQueId = 1;
        ipcFramesOutVpssPrm2.baseCreateParams.outQueParams[0].nextLink = gVcapModuleContext.ipcFramesInHostId;
        ipcFramesOutVpssPrm2.baseCreateParams.numOutQue = 1;
    
        /*frame in A8*/
        ipcFramesInHostPrm.baseCreateParams.noNotifyMode = FALSE;
        ipcFramesInHostPrm.baseCreateParams.notifyNextLink = TRUE;
        ipcFramesInHostPrm.baseCreateParams.notifyPrevLink = TRUE;
        ipcFramesInHostPrm.baseCreateParams.inQueParams.prevLinkId = gVcapModuleContext.ipcFramesOutVpssId[1];
        ipcFramesInHostPrm.baseCreateParams.inQueParams.prevLinkQueId = 0;
        ipcFramesInHostPrm.baseCreateParams.outQueParams[0].nextLink = SYSTEM_LINK_ID_INVALID;
        ipcFramesInHostPrm.baseCreateParams.numOutQue   = 1;
        ipcFramesInHostPrm.cbCtx = &gVcapModuleContext;
        ipcFramesInHostPrm.cbFxn = Vcap_ipcFramesInCbFxn;
    
        /*frame in dsp */
        ipcFramesInDspPrm.baseCreateParams.noNotifyMode = FALSE;
        ipcFramesInDspPrm.baseCreateParams.notifyNextLink = TRUE;
        ipcFramesInDspPrm.baseCreateParams.notifyPrevLink = TRUE;
        ipcFramesInDspPrm.baseCreateParams.inQueParams.prevLinkId = gVcapModuleContext.ipcFramesOutVpssId[0];
        ipcFramesInDspPrm.baseCreateParams.inQueParams.prevLinkQueId = 0;
        ipcFramesInDspPrm.baseCreateParams.outQueParams[0].nextLink = gVcapModuleContext.dspAlgId[0];
        ipcFramesInDspPrm.baseCreateParams.numOutQue   = 1;
    
        /*dsp*/
        dspAlgPrm.inQueParams.prevLinkId = gVcapModuleContext.ipcFramesInDspId[0];
        dspAlgPrm.inQueParams.prevLinkQueId = 0;
        dspAlgPrm.outQueParams[ALG_LINK_SCD_OUT_QUE].nextLink = SYSTEM_LINK_ID_INVALID;//nullId;
        dspAlgPrm.enableOSDAlg = TRUE;
    //    int chId;
        for(chId = 0; chId < ALG_LINK_OSD_MAX_CH; chId++)
        {
            AlgLink_OsdChWinParams * chWinPrm = &dspAlgPrm.osdChCreateParams[chId].chDefaultParams;
    
            /* set osd window max width and height */
            dspAlgPrm.osdChCreateParams[chId].maxWidth  = EXAMPLE_OSD_WIN_MAX_WIDTH;
            dspAlgPrm.osdChCreateParams[chId].maxHeight = EXAMPLE_OSD_WIN_MAX_HEIGHT;
    
            chWinPrm->chId = chId;
            chWinPrm->numWindows = 0;
        }
    
        /*dup*/
    #if 0
        dupPrm.inQueParams.prevLinkId    =  gVcapModuleContext.ipcFramesOutVpssId[0]; 
        dupPrm.inQueParams.prevLinkQueId = 0;
        dupPrm.notifyNextLink            = TRUE;
        dupPrm.numOutQue                 = 2; 
        dupPrm.outQueParams[0].nextLink  = gMultiCh_VcapVencVdisObj.mergeId[0]; 
        dupPrm.outQueParams[1].nextLink  = gMultiCh_VcapVencVdisObj.mergeId[0]; 
    #endif
    
        /*nullSrc0*/
        nullSrcPrm0.outQueParams.nextLink      = gMultiCh_VcapVencVdisObj.mergeId[0]; //mergeId;
        nullSrcPrm0.timerPeriod                = 200;
        nullSrcPrm0.inputInfo.numCh            = 1;
        int i = 0;
        for(i=0; i<nullSrcPrm0.inputInfo.numCh; i++)
        {
            System_LinkChInfo *pChInfo;
    
            pChInfo = &nullSrcPrm0.inputInfo.chInfo[i];
    
            pChInfo->dataFormat = SYSTEM_DF_YUV420SP_UV;
            pChInfo->memType    = SYSTEM_MT_NONTILEDMEM;
            pChInfo->startX     = 0;
            pChInfo->startY     = 0;
    #ifdef ADD_DEI_LINK_TEST
            pChInfo->width      = 2464; //1920; // 2464; ?
            pChInfo->height     = 2048; //1080; // 2048; ?
    #else
            pChInfo->width      = 2464;
            pChInfo->height     = 2048;
    #endif
            pChInfo->pitch[0]   = SystemUtils_align(pChInfo->width+pChInfo->startX, SYSTEM_BUFFER_ALIGNMENT);
            pChInfo->pitch[1]   = pChInfo->pitch[0];
            pChInfo->pitch[2]   = 0;
            pChInfo->scanFormat = SYSTEM_SF_PROGRESSIVE;
        }
    
        /*nullSrc1*/
        nullSrcPrm1.outQueParams.nextLink      = gMultiCh_VcapVencVdisObj.mergeId[0]; //mergeId;
        nullSrcPrm1.timerPeriod                = 200;
        nullSrcPrm1.inputInfo.numCh            = 1;
    
        for(i=0; i<nullSrcPrm1.inputInfo.numCh; i++)
        {
            System_LinkChInfo *pChInfo;
    
            pChInfo = &nullSrcPrm1.inputInfo.chInfo[i];
    
            pChInfo->dataFormat = SYSTEM_DF_YUV420SP_UV;
            pChInfo->memType    = SYSTEM_MT_NONTILEDMEM;
            pChInfo->startX     = 0;
            pChInfo->startY     = 0;
    #ifdef ADD_DEI_LINK_TEST
            pChInfo->width      = 2464*2; //1920*2; // 2464*2; ?
            pChInfo->height     = 2048*2; //1080*2; // 2048*2; ?
    #else
            pChInfo->width      = 2464*2;
            pChInfo->height     = 2048*2;
    #endif
            pChInfo->pitch[0]   = SystemUtils_align(pChInfo->width+pChInfo->startX, SYSTEM_BUFFER_ALIGNMENT);
            pChInfo->pitch[1]   = pChInfo->pitch[0];
            pChInfo->pitch[2]   = 0;
            pChInfo->scanFormat = SYSTEM_SF_PROGRESSIVE;
        }
    
    
        /*merge*/
        mergePrm.numInQue                     = 3;
        mergePrm.inQueParams[0].prevLinkId    = gVcapModuleContext.ipcFramesOutVpssId[0];
        mergePrm.inQueParams[0].prevLinkQueId = 0;
        mergePrm.inQueParams[1].prevLinkId    = gVcapModuleContext.nullSrcId0; 
        mergePrm.inQueParams[1].prevLinkQueId = 0; 
        mergePrm.inQueParams[2].prevLinkId    = gVcapModuleContext.nullSrcId1; 
        mergePrm.inQueParams[2].prevLinkQueId = 0; 
        mergePrm.notifyNextLink               = TRUE;
        mergePrm.outQueParams.nextLink        = gMultiCh_VcapVencVdisObj.ipcOutVpssId;
    
        /*OutVpss*/
        ipcOutVpssPrm.inQueParams.prevLinkId = gMultiCh_VcapVencVdisObj.mergeId[0]; 
        ipcOutVpssPrm.inQueParams.prevLinkQueId = 0;
        ipcOutVpssPrm.numOutQue                 = 1;
        ipcOutVpssPrm.outQueParams[0].nextLink  = gMultiCh_VcapVencVdisObj.ipcInVideoId;
        ipcOutVpssPrm.notifyNextLink            = TRUE;
        ipcOutVpssPrm.notifyPrevLink            = TRUE;
        ipcOutVpssPrm.noNotifyMode              = FALSE;
    
        /*ipc In Video*/;
        ipcInVideoPrm.inQueParams.prevLinkId    = gMultiCh_VcapVencVdisObj.ipcOutVpssId;
        ipcInVideoPrm.inQueParams.prevLinkQueId = 0;
        ipcInVideoPrm.numOutQue                 = 1;
        ipcInVideoPrm.outQueParams[0].nextLink  = gVencModuleContext.encId;
        ipcInVideoPrm.notifyNextLink            = TRUE;
        ipcInVideoPrm.notifyPrevLink            = TRUE;
        ipcInVideoPrm.noNotifyMode              = FALSE; 
    
        /*bits out Video*/
        ipcBitsOutVideoPrm.baseCreateParams.inQueParams.prevLinkId    = gVencModuleContext.encId;
        ipcBitsOutVideoPrm.baseCreateParams.inQueParams.prevLinkQueId = 0;
        ipcBitsOutVideoPrm.baseCreateParams.numOutQue                 = 1;
        ipcBitsOutVideoPrm.baseCreateParams.outQueParams[0].nextLink  = gVencModuleContext.ipcBitsInHLOSId;
        ipcBitsOutVideoPrm.baseCreateParams.notifyNextLink            = TRUE;
        ipcBitsOutVideoPrm.baseCreateParams.notifyPrevLink            = TRUE; 
        ipcBitsOutVideoPrm.baseCreateParams.noNotifyMode              = FALSE;
    
        /*bits in A8*/
        ipcBitsInHostPrm.baseCreateParams.inQueParams.prevLinkId    = gVencModuleContext.ipcBitsOutRTOSId;
        ipcBitsInHostPrm.baseCreateParams.inQueParams.prevLinkQueId = 0;
        ipcBitsInHostPrm.baseCreateParams.numOutQue                 = 1;
        ipcBitsInHostPrm.baseCreateParams.outQueParams[0].nextLink  = SYSTEM_LINK_ID_INVALID;
        ipcBitsInHostPrm.baseCreateParams.notifyNextLink            = TRUE;
        ipcBitsInHostPrm.baseCreateParams.notifyPrevLink            = TRUE; 
        ipcBitsInHostPrm.baseCreateParams.noNotifyMode              = FALSE; //TRUE;
        ipcBitsInHostPrm.cbCtx = &gVencModuleContext;
        ipcBitsInHostPrm.cbFxn = Venc_ipcBitsInCbFxn; 
    
        /*enc*/
        encPrm.numBufPerCh[0] = 7;
        encPrm.numBufPerCh[1] = 7;
        /* available buffers per channel with CIF and MJPEG encoder support is less*/
        {
            EncLink_ChCreateParams *pLinkChPrm;
            EncLink_ChDynamicParams *pLinkDynPrm;
            VENC_CHN_DYNAMIC_PARAM_S *pDynPrm;
            VENC_CHN_PARAMS_S *pChPrm;
    
            gVencModuleContext.vencConfig.numPrimaryChn = 1;
            gVencModuleContext.vencConfig.numSecondaryChn = 2;
            UInt32 i, j;
    
            /* Primary Stream Params - h264 */
            for (i=0; i<gVencModuleContext.vencConfig.numPrimaryChn; i++)
            {
    
                encPrm.chCreateParams[i].format     = IVIDEO_H264BP;/*BP, MP, HP*/
                encPrm.chCreateParams[i].profile    = IH264_HIGH_PROFILE;/* MAIN/HIGH_PROFILE*/
                encPrm.chCreateParams[i].dataLayout = VCODEC_FIELD_SEPARATED;
                encPrm.chCreateParams[i].fieldMergeEncodeEnable  = FALSE;
                encPrm.chCreateParams[i].maxBitRate = -1;
                encPrm.chCreateParams[i].encodingPreset = 3;
                encPrm.chCreateParams[i].rateControlPreset = 0;
                encPrm.chCreateParams[i].enableHighSpeed = 1;
                encPrm.chCreateParams[i].encodingPreset = XDM_DEFAULT;
                encPrm.chCreateParams[i].enableAnalyticinfo = 0;
                encPrm.chCreateParams[i].enableWaterMarking = 0;
                encPrm.chCreateParams[i].rateControlPreset = IVIDEO_STORAGE;
                encPrm.chCreateParams[i].defaultDynamicParams.intraFrameInterval = 9;
                encPrm.chCreateParams[i].defaultDynamicParams.interFrameInterval = 1;
                encPrm.chCreateParams[i].defaultDynamicParams.inputFrameRate = 9;
                encPrm.chCreateParams[i].defaultDynamicParams.targetBitRate =(2 * 1000 * 1000);
                encPrm.chCreateParams[i].defaultDynamicParams.mvAccuracy = IVIDENC2_MOTIONVECTOR_QUARTERPEL;
                encPrm.chCreateParams[i].defaultDynamicParams.rcAlg = VENC_RATE_CTRL_VBR;
                encPrm.chCreateParams[i].defaultDynamicParams.qpMin = 51;
                encPrm.chCreateParams[i].defaultDynamicParams.qpMax = 51;
                encPrm.chCreateParams[i].defaultDynamicParams.qpInit =51;
                encPrm.chCreateParams[i].defaultDynamicParams.vbrDuration = 8;
                encPrm.chCreateParams[i].defaultDynamicParams.vbrSensitivity = 0;
    
                pLinkChPrm  = &encPrm.chCreateParams[i];
                pLinkDynPrm = &pLinkChPrm->defaultDynamicParams;
                pChPrm      = &gVencModuleContext.vencConfig.encChannelParams[i];
                pDynPrm     = &pChPrm->dynamicParam;
    
                pDynPrm->intraFrameInterval     = pLinkDynPrm->intraFrameInterval;
                pDynPrm->targetBitRate          = pLinkDynPrm->targetBitRate;
                pDynPrm->inputFrameRate         = pLinkDynPrm->inputFrameRate;
                pDynPrm->rcAlg                  = pLinkDynPrm->rcAlg;
                pDynPrm->qpMin                  = pLinkDynPrm->qpMin;
                pDynPrm->qpMax                  = pLinkDynPrm->qpMax;
                pDynPrm->qpInit                 = pLinkDynPrm->qpInit;
                pDynPrm->vbrDuration            = pLinkDynPrm->vbrDuration;
                pDynPrm->vbrSensitivity         = pLinkDynPrm->vbrSensitivity;
            }
    
            if (gVsysModuleContext.vsysConfig.enableSecondaryOut == TRUE)
            {
                /* Secondary Out MJPEG Params */
                for (i=gVencModuleContext.vencConfig.numPrimaryChn, j=VENC_PRIMARY_CHANNELS;
                      i<(gVencModuleContext.vencConfig.numPrimaryChn
                               + gVencModuleContext.vencConfig.numSecondaryChn);
                        i++, j++)
                {
                    pLinkChPrm  = &encPrm.chCreateParams[i];
                    pLinkDynPrm = &pLinkChPrm->defaultDynamicParams;
    
                    pChPrm      = &gVencModuleContext.vencConfig.encChannelParams[j];
                    pDynPrm     = &pChPrm->dynamicParam;
    
                    pChPrm      = &gVencModuleContext.vencConfig.encChannelParams[i];
                    pDynPrm     = &pChPrm->dynamicParam;
    
                    pLinkChPrm->format                 = IVIDEO_MJPEG;
                    pLinkChPrm->profile                = 0;
                    pLinkChPrm->dataLayout             = VCODEC_FIELD_SEPARATED;
                    pLinkChPrm->fieldMergeEncodeEnable = FALSE;
                    pLinkChPrm->enableAnalyticinfo     = 0;
                    pLinkChPrm->enableWaterMarking     = 0;
                    pLinkChPrm->maxBitRate             = 0;
                    pLinkChPrm->encodingPreset         = 0;
                    pLinkChPrm->rateControlPreset      = 0;
                    pLinkChPrm->enableSVCExtensionFlag = 0;
                    pLinkChPrm->numTemporalLayer       = 0;
    
                    pLinkDynPrm->intraFrameInterval    = 0;
                    pLinkDynPrm->targetBitRate         = 2*1000*1000;
                    pLinkDynPrm->interFrameInterval    = 0;
                    pLinkDynPrm->mvAccuracy            = 0;
                    pLinkDynPrm->inputFrameRate        = 1;//pDynPrm->inputFrameRate;
                    pLinkDynPrm->qpMin                 = 0;
                    pLinkDynPrm->qpMax                 = 0;
                    pLinkDynPrm->qpInit                = -1;
                    pLinkDynPrm->vbrDuration           = 0;
                    pLinkDynPrm->vbrSensitivity        = 0;
    
                }
            }
    
            encPrm.inQueParams.prevLinkId   = gMultiCh_VcapVencVdisObj.ipcInVideoId; 
            encPrm.inQueParams.prevLinkQueId= 0;
            encPrm.outQueParams.nextLink    = gVencModuleContext.ipcBitsOutRTOSId;
        }
    
        /*Link Create*/
        System_linkCreate(gVcapModuleContext.captureId, &capturePrm, sizeof(capturePrm));
        System_linkCreate(gVcapModuleContext.nsfId[0], &nsfPrm, sizeof(nsfPrm));
    #ifdef ADD_DEI_LINK_TEST
        System_linkCreate(gVcapModuleContext.deiId[0], &deiPrm, sizeof(deiPrm));
    #endif
        System_linkCreate(vcap_venc_trying_dupId     , &dupPrm    , sizeof(dupPrm));
        System_linkCreate(gVcapModuleContext.ipcFramesOutVpssId[0], &ipcFramesOutVpssPrm, sizeof(ipcFramesOutVpssPrm));
        System_linkCreate(gVcapModuleContext.ipcFramesOutVpssId[1], &ipcFramesOutVpssPrm2, sizeof(ipcFramesOutVpssPrm2));
        System_linkCreate(gVcapModuleContext.ipcFramesInHostId, &ipcFramesInHostPrm, sizeof(ipcFramesInHostPrm));
        System_linkCreate(gVcapModuleContext.ipcFramesInDspId[0], &ipcFramesInDspPrm, sizeof(ipcFramesInDspPrm));
        System_linkCreate(gVcapModuleContext.dspAlgId[0] , &dspAlgPrm, sizeof(dspAlgPrm));
    
        System_linkCreate(gVcapModuleContext.nullSrcId0, &nullSrcPrm0, sizeof(nullSrcPrm0));
        System_linkCreate(gVcapModuleContext.nullSrcId1, &nullSrcPrm1, sizeof(nullSrcPrm1));
        System_linkCreate(gMultiCh_VcapVencVdisObj.mergeId[0], &mergePrm, sizeof(mergePrm ));
        System_linkCreate(gMultiCh_VcapVencVdisObj.ipcOutVpssId , &ipcOutVpssPrm , sizeof(ipcOutVpssPrm) );
        System_linkCreate(gMultiCh_VcapVencVdisObj.ipcInVideoId , &ipcInVideoPrm , sizeof(ipcInVideoPrm) );
        System_linkCreate(gVencModuleContext.encId, &encPrm, sizeof(encPrm));
        System_linkCreate(gVencModuleContext.ipcBitsOutRTOSId, &ipcBitsOutVideoPrm, sizeof(ipcBitsOutVideoPrm));
        System_linkCreate(gVencModuleContext.ipcBitsInHLOSId, &ipcBitsInHostPrm, sizeof(ipcBitsInHostPrm));
    
        MultiCh_memPrintHeapStatus();
    
    }
    
    
    Void MultiCh_deleteVcapVencVdis()
    {
        UInt32 ipcBitsOutDSPId;
    
        /* delete can be done in any order */
        ipcBitsOutDSPId = SYSTEM_DSP_LINK_ID_IPC_BITS_OUT_0;
    
        gVcapModuleContext.nullSrcId0    = SYSTEM_VPSS_LINK_ID_NULL_SRC_0;
        gVcapModuleContext.nullSrcId1    = SYSTEM_VPSS_LINK_ID_NULL_SRC_1;
    
        Vcap_delete();
        Venc_delete();
        //Vdis_delete();
        //System_linkDelete(gMultiCh_VcapVencVdisObj.dupId[0]);
        System_linkDelete(gVcapModuleContext.nullSrcId0);
        System_linkDelete(gVcapModuleContext.nullSrcId1);
        System_linkDelete(gMultiCh_VcapVencVdisObj.mergeId[0]);
        System_linkDelete(gMultiCh_VcapVencVdisObj.ipcOutVpssId);
        System_linkDelete(gMultiCh_VcapVencVdisObj.ipcInVideoId);
    
    
        /* Print the HWI, SWI and all tasks load */
        /* Reset the accumulated timer ticks */
        MultiCh_prfLoadCalcEnable(FALSE, TRUE, FALSE);
    
        /* Reenable tiler allocator taht was disabled by this usecase
         * at delete time.
         */
        SystemTiler_enableAllocator();
    
    }
    

    app code which is writing the yuv to file (just write frame buffer to file, and later use a tool to covert to jpg):

    Void VcapVenc_ipcFrameFileWrite(VIDEO_FRAMEBUF_LIST_S *pFrameBufList)
    {
        UInt32 writeDataSize;
        VIDEO_FRAMEBUF_S *pBuf;
        UInt32 frameSize = 0, frameId;
        FILE *fp = NULL;
        static UInt32 i = 0;
    
        for(frameId=0; frameId<pFrameBufList->numFrames; frameId++)
        {
            pBuf = &pFrameBufList->frames[frameId];
            frameSize = (pBuf->frameWidth * pBuf->frameHeight) << 1;
            {
                UInt32 pMemVirtAddr;
                pMemVirtAddr = 0;
                char fname[24] = {0,};
                sprintf(fname, "/opt/ti8168/__yuv__/%d.yuv", i);
                i++;
    
                VcapVenc_mMap((UInt32)(pBuf->phyAddr[0][0]), frameSize, &pMemVirtAddr);
    
                fp = fopen(fname, "w+b");
                writeDataSize = fwrite((Ptr) pMemVirtAddr, 1, frameSize, fp); //gVcapVenc_ctrl.fp);
                fclose(fp);
                VcapVenc_unmapMem();
            }
        }
    }
    

    Maybe, not necessary to upload app code which is writing the yuv to file, because we can get correct screen without DEI link as the 2nd picture shows.

  • Hi ! Badri !

    I wonder what would happen if I use DEI link with input resolution is greater than 1920x1080, would it will make screen mess up?

    Thanks!

  • None of the HDVPSS input path supports more that 1920 line length.

     

    Rgds,

    Brijesh

  • As Brijesh mentioned your link connection should be

    Capture -> MpSclr -> DEI -> ipcFramesOut -> ipcFramesIn as your capture resolution is greater than 1920x1080