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