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.

DVSDK 3.01.00.03 Encode Modification

I'm trying to modify the encode demo to add a call to IUNIVERSAL function I have created.  For a sanity check I made the IUNIVERSAL algorithm simply zero out 100 lines of the buffer (i.e. green in YCbCr color space).  The green lines look "very flickery" on the screen as if there is some kind of race condition and something else "fighting" with me to fill the buffer!  I can't figure out if I have done the modification in the wrong place or what the issue is.  Here is a quick overview of what I've changed.

Here's the main processing loop from capture.c.  My additions are in red (it will ultimately do alphablending but right now does in-place zeroing of the buffer):

 while (!gblGetQuit()) {

        /* Pause processing? */
        Pause_test(envp->hPauseProcess);

        /* Get a buffer from the capture driver to encode */
        if (Capture_get(hCapture, &hCapBuf) < 0) {
            ERR("Failed to get capture buffer\n");
            cleanup(THREAD_FAILURE);
        }

        /* Preview the captured buffer on the display */
        if (Display_get(hDisplay, &hDisBuf) < 0) {
            ERR("Failed to get display buffer\n");
            cleanup(THREAD_FAILURE);
        }

    // BJG - do alphablending on DSP core
    alphablendInOutBuffs.descs[0].buf = Buffer_getUserPtr(hCapBuf);
    UNIVERSAL_process(hAlphablend, &alphablendInBuffs, NULL, &alphablendInOutBuffs, &alphablendInArgs, &alphablendOutArgs);
 
    /* Send captured buffer to video thread for encoding */
        if (Fifo_put(envp->hOutFifo, hCapBuf) < 0) {
            ERR("Failed to send buffer to display thread\n");
            cleanup(THREAD_FAILURE);
        }       

   
        /* Send the preview to the display device driver */
        if (Display_put(hDisplay, hCapBuf) < 0) {
            ERR("Failed to put display buffer\n");
            cleanup(THREAD_FAILURE);
        }
        /* Return a buffer to the capture driver */
        if (Capture_put(hCapture, hDisBuf) < 0) {
            ERR("Failed to put capture buffer\n");
            cleanup(THREAD_FAILURE);
        }

        /* Incremement statistics for the user interface */
        gblIncFrames();

        /* Get a buffer from the video thread */
        fifoRet = Fifo_get(envp->hInFifo, &hCapBuf);
        if (fifoRet < 0) {
            ERR("Failed to get buffer from video thread\n");
            cleanup(THREAD_FAILURE);
        }

        /* Did the video thread flush the fifo? */
        if (fifoRet == Dmai_EFLUSH) {
            cleanup(THREAD_SUCCESS);
        }
    }

 

Also, so you can see what I'm doing in my IUNIVERSAL codec, here is the process function:

Int ALPHABLEND_TI_process(IUNIVERSAL_Handle handle,
        XDM1_BufDesc *inBufs, XDM1_BufDesc *outBufs, XDM1_BufDesc *inOutBufs,
        IUNIVERSAL_InArgs *inArgs, IUNIVERSAL_OutArgs *outArgs)
{


    unsigned int *pVideo = (unsigned int*)inOutBufs->descs[0].buf;

    unsigned int i;

    for (i=0; i<360*100; i++)
        pVideo[i] = 0;

   /* report how we accessed the input buffer */
   inBufs->descs[0].accessMask = 0;
   XDM_SETACCESSMODE_READ(inBufs->descs[0].accessMask);

   /* report how we accessed the output buffer */
   inOutBufs->descs[0].accessMask = 0;
   XDM_SETACCESSMODE_READ(outBufs->descs[0].accessMask);
   XDM_SETACCESSMODE_WRITE(outBufs->descs[0].accessMask);

   return (IUNIVERSAL_EOK);
}

Do you see anything wrong with how I'm writing to the accessMask (maybe it's a cache issue), or anything else?  Please help!  I'm getting on a plane Monday afternoon to demo alpha blending to the customer and need to get this working!

Thanks,
Brad

 

 

 

 

 

 

  • Just to sanity check - can you run a few frames through with CE_DEBUG=2?  I'm kind of curious if the cache calls we expect to happen (writeback of the single inOut buffer and nothing else) are happening as expected.
     
    Maybe (since you're not using it yet), rule out the inBufs by passing NULL into UNIVERSAL_process()'s 2nd [inBufs] argument?
     
    Are you initializing alphablendInOutBuffs.numBufs = 1 (indicating there is only one inOut buffer)?  Are you initializing alphablendInArgs.size and alphablendOutArgs.size?

    It does feel a bit like cache or double-buffering/ping-pong buffering.  Is the capture driver's buffer (hCapBuf) cached from the ARM-side?

    Chris

  • Brad,

    It looks like you've put the alpha blending in the right place. Note however that by putting it in serial with the capture you will have a limited time budget for your alpha blending, but that shouldn't be a problem when you aren't doing any processing.

    I agree with Chris it could be a cache issue since you are doing the operation in-place. The buffers you get from the capture driver are not cached.

    Niclas

  • Brad Griffis said:
       /* report how we accessed the output buffer */
       inOutBufs->descs[0].accessMask = 0;
       XDM_SETACCESSMODE_READ(outBufs->descs[0].accessMask);
       XDM_SETACCESSMODE_WRITE(outBufs->descs[0].accessMask);

    It was a dumb mistake...  I made this algorithm operate "in place" using inOutBufs but made a cut/paste error.  Chris -- thanks, using CE_DEBUG I immediately saw it was not writing back the buffer.  When I double-checked my code it was obvious why not!