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.

in buffer and out buffer in OSD alg

hi ,

I want write my own algorithm refer to OSD link code in  \dvr_rdk\mcfw\src_bios6\links_c6xdsp\alg_link\swosd

and the first i must find the in  buffer  and out buffer in  OSD link .  but in  \dvr_rdk\mcfw\src_bios6\links_c6xdsp\alg_link\swosd\osdLink_alg.c , i don't find the in buffer and out buffer . so my own algorithm can't get the data from in buffer and also can't output the result to the out buffer.

so where is the exact  in buffer and  out buffer??

                                                                        

 

  • SWOSD doesnt have an output buffer . It blends the graphics plane on the input buffer.

    For access to input buffer refer

    /dvr_rdk/mcfw/src_bios6/links_c6xdsp/alg_link/swosd/osdLink_alg.c

    Int32 AlgLink_OsdalgProcessFrame(AlgLink_OsdObj * pObj, FVID2_Frame *pFrame)

    Here FVID2_Frame *pFrame is an input frame sturcture. The input frame buffer can be accessed as

    pFrame->addr[0][0] -- /* YUV422i or YUV420SP - Y-plane processing */

    pFrame->addr[0][1] -- /* YUV420SP - C -plane processing */

  • thank you very much ! as we know that YUV422 format in memory is Y0U0Y1V0 Y2U1Y3V1

       the first pixel YUV     :Y0 U0 V0

       the second pixel YUV   : Y1 U0 V0

       the third  pixel YUV   : Y2 U1 V1

    so now i want change the value of pixel as 0 in AlgLink_OsdalgProcessFrame(AlgLink_OsdObj * pObj, FVID2_Frame *pFrame)

    i do like this :

    set the first and second pixel to be 0      *((Uint 32 *)pFrame->addr[0][0])=0x00000000;

    set the second and third pixel to be 0    *((Uint 32 *)pFrame->addr[0][1)=0x00000000;

    is that right ??

  • No this is wrong.

    Pls refer osd code for reference of how to access YUV422I data.

    In buffer format is YUV422I with pixels in Y0U0Y1V0 order to access the buffer code should be:

    UInt8 *pBufferStart = pFrame->addr[0][0];

    UInt8* y0pixel, *y1pixel, *upixel, *vpixel;

    UInt8 *pBuffer;

     

       for (heightIdx = 0; heightIdx < frameHeight;heightIdx++)

           pBuffer =pBufferStart + (heightIdx * framePitch);     

           for (widthIdx = 0; widthIdx < frameWidth/2; widthIdx++)

           {

               y0pixel = pBuffer + 0;

               upixel  =  pBuffer + 1;

               y1pixel = pBuffer + 2;

               vpixel  =  pBuffer + 3;

              ---process pixels----

                pBuffer  += 4;

          }

  • oh ,you are so nice ! that is great ! thank you very much !  shall i ask you another question ?

    my data stream is

    steps :   capture--->ipcframesoutvpss------(processlink)---->ipcframesinDsp----->osd

                                       ipcframesoutvpss------(nextlink)---------->display

    if i change all pixel value to be 0 in OSD like you have told above, it will change the display? that is to say the data in pFrame (in buffer ) of osd  will all be put to display because of processlink and nextlink, is that right ? or the display data will be same with the captrue data , even we changed OSD , there will no change on display ?

    thanks

  • Yes if you change pixel values of the input buffer it will change in display

  • thank you very much !  ^_^

  • Hi Badri,

        I want to process the data after DMA moved the data to L2 memory.

        But I confused about which address I should set the DMA moved to?

        Could you give me some advices?

        shall we discuss at this:http://e2e.ti.com/support/dsp/davinci_digital_media_processors/f/717/t/254397.aspx

    Thanks !

    Best Regards !

    1. hi Badri Narayanan,

    i have done as you said , all the pixel are set as 0 , but the screen  also displayes what the camera captrues . why ?? 

    i changed OSD alg in AlgLink_OsdalgProcessFrame() , as follow

        for(winId=0; winId<pChObj->numWindows; winId++)
        {
            if(!pChObj->osdWinObj[winId].enableWin)
                continue;
            Vps_printf("$$$$$$$$$$$$$$$$$$$$$  enableWin  $$$$$$$$$$$$$$$$$$$$$\n");
            /* YUV422i or YUV420SP - Y-plane processing */

            int i=0,j=0;
            UInt8 *pBufferStart = pFrame->addr[0][0];

            UInt8 *pBuffer;

             for (i= 0; i < pFrameInfo->rtChInfo.height;i++)

             pBuffer =pBufferStart + (i * pFrameInfo->rtChInfo.width);    

                     for (j = 0; j< pFrameInfo->rtChInfo.width/2; j++)  

                       {     

                              *(pBuffer + 0)=0;     

                              *(pBuffer + 1)=0;     

                              *(pBuffer + 2)=0;     

                              *(pBuffer + 3)=0;     

                               pBuffer  += 4;  

                       }


                      pSwOsdObj->videoWindowAddr = pFrame->addr[0][0];

    ................

    }

    my application code is


    /*******************************************************************************
     *                                                                             *
     * Copyright (c) 2009 Texas Instruments Incorporated - http://www.ti.com/      *
     *                        ALL RIGHTS RESERVED                                  *
     *                                                                             *
     ******************************************************************************/

     
    #include <demos/link_api_demos/common/chains.h>
    #include <mcfw/interfaces/ti_venc.h>
    #include <demos/link_api_demos/common/chains_ipcFrames.h> 

    static SystemVideo_Ivahd2ChMap_Tbl systemVid_encDecIvaChMapTbl =
    {
        .isPopulated = 1,
        .ivaMap[0] =
        {
            .EncNumCh  = 1,
            .EncChList = {0},
            .DecNumCh  = 0,
            .DecChList = {0},
        },
        .ivaMap[1] =
        {
            .EncNumCh  = 0,
            .EncChList = {0},
            .DecNumCh  = 1,
            .DecChList = {0},
        },
        .ivaMap[2] =
        {
            .EncNumCh  = 1,
            .EncChList = {1},
            .DecNumCh  = 1,
            .DecChList = {1},
        },
    };

     
      Void Chains_doubleChCapNsfEncDecSwMsDis(Chains_Ctrl *chainsCfg)
      {
       CaptureLink_CreateParams  capturePrm;
       CaptureLink_VipInstParams  *pCaptureInstPrm;
       CaptureLink_OutParams   *pCaptureOutPrm;
      printf("@@@@@@@@@@@@@@@@@@@@@@@ hehe @@@@@@@@@@@@@@@@@@@@@@@\n");
       /* changed by chen longhu */
     
       IpcFramesInLinkRTOS_CreateParams  ipcFramesInDspPrm;
       IpcFramesOutLinkRTOS_CreateParams ipcFramesOutVpssPrm;
     
       AlgLink_CreateParams      dspAlgPrm;
     
       DisplayLink_CreateParams  displayPrm[CHAINS_SW_MS_MAX_DISPLAYS];
       UInt32 captureId, vipInstId;
       UInt32 ipcFramesOutVpssId,ipcFramesInDspId;
       UInt32 ipcBitsOutDspId,ipcBitsInHostId;
       UInt32 dspAlgId;
       UInt32 displayId[CHAINS_SW_MS_MAX_DISPLAYS];
     
       UInt32 i;
       char ch;
     
       CHAINS_INIT_STRUCT(CaptureLink_CreateParams,capturePrm);
       CHAINS_INIT_STRUCT(IpcFramesOutLinkRTOS_CreateParams,ipcFramesOutVpssPrm);
       CHAINS_INIT_STRUCT(IpcFramesInLinkRTOS_CreateParams,ipcFramesInDspPrm);

       CHAINS_INIT_STRUCT(AlgLink_CreateParams ,dspAlgPrm);
       for (i=0; i<CHAINS_SW_MS_MAX_DISPLAYS; i++) {
        CHAINS_INIT_STRUCT(DisplayLink_CreateParams,displayPrm[i]);
       }
       captureId    = SYSTEM_LINK_ID_CAPTURE;
       ipcFramesOutVpssId  = SYSTEM_VPSS_LINK_ID_IPC_FRAMES_OUT_0;
       ipcFramesInDspId= SYSTEM_DSP_LINK_ID_IPC_FRAMES_IN_0;
     
       dspAlgId= SYSTEM_LINK_ID_ALG_0;
       displayId[0]  = SYSTEM_LINK_ID_DISPLAY_0;
       displayId[1]  = SYSTEM_LINK_ID_DISPLAY_1;
     
       capturePrm.numVipInst     = 2;
       capturePrm.tilerEnable     = FALSE;
       capturePrm.numBufsPerCh    = 16;
       capturePrm.numExtraBufs    = 0;
       capturePrm.maxBlindAreasPerCh   = 0;
       capturePrm.isPalMode     = FALSE;
       capturePrm.enableSdCrop    = FALSE;
       capturePrm.doCropInCapture    = FALSE;
     
       for(i=0; i<capturePrm.numVipInst; i++)
       {
        vipInstId = SYSTEM_CAPTURE_INST_VIP0_PORTA + 2*i;
        pCaptureInstPrm      = &capturePrm.vipInst[i];
        pCaptureInstPrm->vipInstId    = vipInstId%SYSTEM_CAPTURE_INST_MAX;
        pCaptureInstPrm->videoDecoderId  = SYSTEM_DEVICE_VID_DEC_SII9233A_DRV;
        pCaptureInstPrm->inDataFormat   = SYSTEM_DF_YUV422P;
        pCaptureInstPrm->standard    = chainsCfg->displayRes[i];
        pCaptureInstPrm->numOutput    = 1;
        pCaptureInstPrm->numChPerOutput  = 1;
        pCaptureInstPrm->frameCaptureMode  = FALSE;
        pCaptureInstPrm->fieldsMerged   = FALSE;
        pCaptureOutPrm       = &pCaptureInstPrm->outParams[0];
        pCaptureOutPrm->dataFormat    = SYSTEM_DF_YUV422I_YUYV;
        pCaptureOutPrm->scEnable    = FALSE;
        pCaptureOutPrm->scOutWidth    = chainsCfg->channelConf[i].width;
        pCaptureOutPrm->scOutHeight   = chainsCfg->channelConf[i].height;
        pCaptureOutPrm->outQueId    = 0;
       }
     
       capturePrm.outQueParams[0].nextLink  = ipcFramesOutVpssId;
       System_linkCreate(captureId, &capturePrm, sizeof(capturePrm));
       for (i=0; i<gChains_ctrl.channelNum; i++) {
        chainsCfg->displayRes[i] = capturePrm.vipInst[i].standard;
        Vsys_getResSize(chainsCfg->displayRes[i], &chainsCfg->channelConf[i].width, &chainsCfg->channelConf[i].height);
        Vsys_getResRate(chainsCfg->displayRes[i], &chainsCfg->channelConf[i].frameRate);
     
       }
     
      
       ipcFramesOutVpssPrm.baseCreateParams.inQueParams.prevLinkId = captureId;
       ipcFramesOutVpssPrm.baseCreateParams.inQueParams.prevLinkQueId = 0;
       ipcFramesOutVpssPrm.baseCreateParams.outQueParams[0].nextLink = displayId[0];
       ipcFramesOutVpssPrm.baseCreateParams.numOutQue = 1;
       ipcFramesOutVpssPrm.baseCreateParams.processLink = ipcFramesInDspId;
     
       ipcFramesOutVpssPrm.baseCreateParams.notifyProcessLink = TRUE;
       ipcFramesOutVpssPrm.baseCreateParams.notifyNextLink = TRUE;
       ipcFramesOutVpssPrm.baseCreateParams.notifyPrevLink = TRUE;
       ipcFramesOutVpssPrm.baseCreateParams.noNotifyMode = TRUE;
      
       //prevLink->processLink->nextLink
       ipcFramesInDspPrm.baseCreateParams.inQueParams.prevLinkId = ipcFramesOutVpssId;
       ipcFramesInDspPrm.baseCreateParams.inQueParams.prevLinkQueId = 0;
       ipcFramesInDspPrm.baseCreateParams.outQueParams[0].nextLink =dspAlgId;
       ipcFramesInDspPrm.baseCreateParams.numOutQue = 1;
     
       ipcFramesInDspPrm.baseCreateParams.notifyPrevLink = TRUE;
       ipcFramesInDspPrm.baseCreateParams.notifyNextLink = TRUE;
       ipcFramesInDspPrm.baseCreateParams.noNotifyMode  = TRUE;
      
      
       dspAlgPrm.enableOSDAlg = TRUE;
       dspAlgPrm.enableSCDAlg = FALSE;
       dspAlgPrm.inQueParams.prevLinkId =ipcFramesInDspId;
       dspAlgPrm.inQueParams.prevLinkQueId = 0;
       dspAlgPrm.outQueParams[0].nextLink =  SYSTEM_LINK_ID_INVALID;//ipcBitsOutDspId;

       AlgLink_OsdChWinParams * chWinPrm = &dspAlgPrm.osdChCreateParams[0].chDefaultParams;
     
       /* set osd window max width and height */
       dspAlgPrm.osdChCreateParams[0].maxWidth  = 320;
       dspAlgPrm.osdChCreateParams[0].maxHeight = 64;
       chWinPrm->chId = 0;
       chWinPrm->numWindows = 1;
       chWinPrm->winPrm[0].enableWin=1;

       Chains_displayCtrlInit(chainsCfg->displayRes);
       System_linkCreate(ipcFramesOutVpssId, &ipcFramesOutVpssPrm, sizeof(ipcFramesOutVpssPrm));
       System_linkCreate(ipcFramesInDspId, &ipcFramesInDspPrm, sizeof(ipcFramesInDspPrm));
       System_linkCreate(dspAlgId, &dspAlgPrm, sizeof(dspAlgPrm));
     
       displayPrm[0].numInputQueues     = 1;
       displayPrm[0].activeQueue      = 0;
       displayPrm[0].inQueParams[0].prevLinkId  = ipcFramesOutVpssId;
       displayPrm[0].inQueParams[0].prevLinkQueId  = 0;
       displayPrm[0].displayRes     = chainsCfg->displayRes[0];
       displayPrm[0].forceFieldSeparatedInputMode  = FALSE;
       System_linkCreate(displayId[0], &displayPrm[0], sizeof(displayPrm[0]));

     
       Chains_memPrintHeapStatus();
       {
        System_linkStart(displayId[0]);
        System_linkStart(captureId);
        System_linkStart(dspAlgId);
        while(1)
        {
         ch = Chains_menuRunTime();
         if(ch=='0')
          break;
         if(ch=='v')
          System_linkControl(captureId, CAPTURE_LINK_CMD_FORCE_RESET, NULL, 0, TRUE);
         if(ch=='p')
          System_linkControl(captureId, CAPTURE_LINK_CMD_PRINT_ADV_STATISTICS, NULL, 0, TRUE);
        }
     
        System_linkStop(captureId);
        System_linkStop(dspAlgId);
        System_linkStop(displayId[0]);

     
        Chains_ipcBitsStop();
       }
     
       System_linkDelete(captureId);
       System_linkDelete(displayId[0]);
       System_linkDelete(dspAlgId);
       System_linkDelete(ipcFramesOutVpssId);
       System_linkDelete(ipcFramesInDspId);

       Chains_displayCtrlDeInit();
     
      }

    i find that the OSD has run, because the printf() can be executed . what is the problem?

     

     

  • If you overwrite the buffer definitely display will not show .Pls put Vps_prints in your for loop to confirm the bytes are getting overwritten.Try doing Cache_wbInv after your for loop to ensure data is written to DDR

  • thanks a lot . I am sorry,  i am a newer , could you tell me more for details ?

  • hi,Badri Narayanan

    if In buffer format is YUV420sp,how can I  change the value of pixel as 0?

  • char *y_buffer = pFrame->addr[0][0];

    char *cbcr_buffer = pFrame->addr[0][1];

    memset(y_buffer,0,pitch[0] * height); //Set Y pixels to 0x0

    memset(cbcr_buffer,0,pitch[1] * height); //Set CbCr to 0x8080

  • thanks a lot,I have two question

    1、I want to use my own algorithms replace osd in AlgLink_OsdalgProcessFrame inside.

    Incoming video stream is SWOSD_FORMAT_YUV420sp,I want to process y_buffer, cb_buffer and cr_buffer respectively

    but I don't konw how to extract cb_buffer and cr_buffer, respectively.

    Do I need to create two arrays are used to store cb_buffer and cr_buffer?

    like this:

     int i=0,j=0;

    UInt8 *y_buffer = pFrame->addr[0][0];

    UInt8 cbbuffer_arr[pFrameInfo->rtChInfo.height*(pFrameInfo->rtChInfo.width/4)];

    UInt8 crbuffer_arr[pFrameInfo->rtChInfo.height*(pFrameInfo->rtChInfo.width/4)];

    UInt8 *pBufferStart = pFrame->addr[0][1];

     for (i= 0; i<(pFrameInfo->rtChInfo.height*pFrameInfo->rtChInfo.width)>>1; i+=2)

    {

        cbbuffer_arr[j] = *(pBufferStart+i);

        crbuffer_arr[j] = *(pBufferStart+i+1);

        j++;

    }

    /*----my algorithm interface------*/

    YUV420_PROCESS(y_buffer,cbbuffer_arr,crbuffer_arr);

    j=0;

    for (i= 0; i<(pFrameInfo->rtChInfo.height*pFrameInfo->rtChInfo.width)>>1; i+=2)

    {

         *(pBufferStart+i)  = cbbuffer_arr[j];

         *(pBufferStart+i+1)= crbuffer_arr[j];

        j++;

    }

     Is it right?

    2、If I do that in   AlgLink_OsdalgProcessFrame,whether I rewrite

    UInt8 *y_buffer = pFrame->addr[0][0]+0x30000000;

    UInt8 *pBufferStart = pFrame->addr[0][1]+0x30000000;