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.

DM6437 . Is it very beneficial to use DMA in video-capture,video-process and video-display?

We have finished a project,called "Vehicle nighttime infrared pedestrian detection system" on DM6437.

the scheme of our  project is based on video_preview, just adding viedo process algorithm between video-capture and video_display, like this

  /* loop forever performing video capture and display */
  while ( status == 0 ) {

    /* grab a fresh video input frame */
    FVID_exchange(hGioVpfeCcdc, &frameBuffPtr);

  /*video process algorithm,  frameBuffPtr->frame.frameBufferPtr contain current frame data*/
   detect_pedestrian(frameBuffPtr->frame.frameBufferPtr);   

    /*observe the index that contains current frame data*/   */
    printf("%x\n", (void*)(frameBuffPtr->frame.frameBufferPtr));
    fflush(stdout);

   /* display the video frame */
    FVID_exchange(hGioVpbeVid0, &frameBuffPtr);
}

Then my task is to optimize this system from DMA and Cache. I have done some experiments, but  still have questions to solve.

1、    the size of one frame image is 720*576*2 bytes, about 829.44Kb, absolutely larger than L1 Memory and L2 Memory.

        So we must  have Video Frame buffers in DDR2 rather than L1 Memory or L2 Memory, though the speed of DDR2 is much slower .

         I had a experiment ,.By enable MAR128-MAR159, as a result ,DDR2 is cacheable. The performance of above loop is proved to be about 8 times improvement .

         I wonder if DMA can be used here to improve further? Maybe DMA and Cache should cooperate with each other, can this mechanism make a difference?

2、The VPFE/ VPBE drivers maintain two circular queues called READY queue and a FREE queue for each
channel of display and capture.

/* prime up the video capture channel */
    if (status == 0) {
        FVID_queue(hGioVpfeCcdc, frameBuffTable[0]);
        FVID_queue(hGioVpfeCcdc, frameBuffTable[1]);
        FVID_queue(hGioVpfeCcdc, frameBuffTable[2]);
    }

    /* prime up the video display channel */
     if (status == 0) {
        FVID_queue(hGioVpbeVid0, frameBuffTable[3]);
        FVID_queue(hGioVpbeVid0, frameBuffTable[4]);
        FVID_queue(hGioVpbeVid0, frameBuffTable[5]);
    }

Above are six frameBuff used in FVID_exchange(hGioVpfeCcdc, &frameBuffPtr); and   FVID_exchange(hGioVpbeCcdc, &frameBuffPtr); 

I observe the frameBuffPtr->frame.frameBufferPtr  that contains current frame data .and the result is in following Stdout window. They are  circluar every six loop. The address and order are stable for  new  loops.

800cac00
80195400
80000380
80195400
8025fc80
8032a480

800cac00
80195400
80000380
80195400
8025fc80
8032a480


I attempted to use DMA to move several lines of the whole frame from DDR2 to L2 SRAM. So  I use  frameBuffPtr->frame.frameBufferPtr as the souce address of DMA  transfer.  And a buffer in L2 SRAM as the destination of DMA tranfer

If I want to  create another  task in bios to accomplish the DMA transfer.  What's the priority of two tasks? 

DMA transfer should start automaticly  as soon as video capture is finished.  How should I know  the moment?

DMA transfer should also start automaticly  as soon as video process is finished. How should I know the moment?

 

  • Hi,

    Thanks for your post.

    As a first step, did you try video preview example from DVSDK package (dvsdk_1_01_00_15)?

    May be, this would help you understand the VPFE, VPBE video capture, video process and video display, I believe so.

    Any way, I am working on this and will update you as soon as possible.

    Thanks & regards,

    Sivaraj K

    -------------------------------------------------------------------------------------------------------

    Please click the Verify Answer button on this post if it answers your question.

    -------------------------------------------------------------------------------------------------------

  • Sivaraj K,

    Thanks for your reply very much.

    According to the video preview example from DVSDK package (dvsdk_1_01_00_15)., I am more familiar with the procedure of video capture and video display. This example can display the image or lookback the video from my camera.

    What's more , using the following example, I can modify the pixels in frame using the frame buffer pointer structure that is provided by the video driver. This example can add a rolling colorbar to the original video frame, just like the '' screen savers".

    processors.wiki.ti.com/.../Accessing_Pixels_in_a_Frame_on_the_DM643x

    To be honest , the above two example are rather useful.

    However, they don't use EDMA3 at all. For a 720*576 YCbCr image, DMA is benefical to improve the performance of video process. maybe it is not related to the performance of video capture and video display.

    In this case, perhaps whole image is too big to use DMA, why not several lines? More detail about the use of DMA would be appreciated.

    Thanks & regards,

    AlenXYP

  • Hi,

    Thanks for your update.

    To start out though, have you tried the example in dvsdk_1_01_00_15\psp_1_00_02_00\pspdrivers\system\dm6437\bios\dm6437_evm\src\video\sample\rawcapture\build? This is probably the best place to start if you are planning on working with a camera sensor

    Likewise, for the previewer to start, please look at the example in \dvsdk_1_01_00_15\psp_1_00_02_00\pspdrivers\system\dm6437\bios\dm6437_evm\src\video\sample\previewer\build\

    The best documentation on the PSP VPFE driver seems to be \dvsdk_1_01_00_15\psp_1_00_02_00\pspdrivers\drivers\vpfe\doc\BIOS_VPFE_Driver_UserGuide.pdf, if you would wish to use the previewer driver there is some documentation in \dvsdk_1_01_00_15\psp_1_00_02_00\pspdrivers\drivers\previewer\docs that would help you better.

    Note that the FVID_exchange call is actually equivalent to sequential calls to FVID_queue and FVID_dequeue, so you could queue a frame and than do some work and than dequeue a frame to block for the next frame being available. The Exchange call will avoid the simultaneous call of Queue and Dequeue Application passes an in/out parameter that points to frame buffer that is to be relinquished by the driver. After the call returns successfully, this function fills with the pointer to the frame buffer that was previously queued in the device driver

    Please refer to example code below to exchange the FrameBuffer using FVID_exchange function:

    FVID_Handle CcdcHandle;

    FVID_Frame *CcdcallocFB = NULL;

    FVID_Frame *FBAddr = NULL;

    /* Allocate memory to Frame Buffer */

    FVID_allocBuffer (CcdcHandle, &CcdcallocFB);

    /* Queue the Frame Buffer after allocation */

    FVID_queue (vpfeCcdcHandle, CcdcallocFB);

    /* Allocate memory to Frame Buffer */

    FVID_allocBuffer (CcdcHandle, & FBAddr);

    /* Exchange the Frame Buffers */

    status = FVID_exchange (CcdcHandle, &FBAddr);

    FVID_exchange returns IOM_COMPLETED when it returns successfully. If an error occurs, a negative value will be returned.

    Please refer section 6.1.3 to know more details on the buffer management in the BIOS_VPFE_Driver_UserGuide.pdf doc

    \dvsdk_1_01_00_15\psp_1_00_02_00\pspdrivers\drivers\vpfe\doc\BIOS_VPFE_Driver_UserGuide.pdf

    May be, you could debug the FVID_exchange API for any CCDC or video exchange failure through debug print message like VPSS_DBG from the code snippet below from VPSS loopback example:

    VPSS_DBG("VPSS :VPSS Loopback Started \r\n");

    FVID_allocBuffer(CcdcHandle, &CcdcallocFB[1]);

    FBAddr = CcdcallocFB[1];

                     for(i = 0; i < NumOfIterations; i++)

                     {

                     if(IOM_COMPLETED != FVID_exchange(CcdcHandle,&FBAddr))

                     {

                     VPSS_DBG("VPSS :CCDC Exchange.......FAILED \r\n");

                     }

                     if(IOM_COMPLETED != FVID_exchange(Vid0Handle,&FBAddr))

                     {

                     VPSS_DBG("VPSS :Video -0 Exchange.......FAILED \r\n");

                    }

    }

    Thanks & regards,

    Sivaraj K

    -------------------------------------------------------------------------------------------------------

    Please click the Verify Answer button on this post if it answers your question

    -------------------------------------------------------------------------------------------------------

  • Hi Sivaraj K,

    Thank you for your suggestions.Now I begin to use these examples in dvsdk that I don't know before.
    \dvsdk_1_01_00_15\psp_1_00_02_00\pspdrivers\system\dm6437\bios\dm6437_evm\src\video\sample\rawcapture\build
    \dvsdk_1_01_00_15\psp_1_00_02_00\pspdrivers\system\dm6437\bios\dm6437_evm\src\video\sample\previewer\build\

    Thanks & regards,

    Sivaraj K