Hi,
After much frustration in attempting to "code from scratch" (eg no DSP/BIOS) some simple video/interrupt based applications I decided to give DSP/BIOS a shot on my EVM6437 kit. I've read the user guide/API guide and went through the tutorials. I'm now at the point where I'd like to implement the silliest of video "processing" algorithms...eg just some algorithm that loops through a frame of video and modifies some or all of the pixels. My current setup is a camera input to the kit and component output to a monitor. In order to avoid wasting too much time in getting setup, I've taken the video_preview example and attempted to modify it. The example ships with a while loop that calls the FVID wrapper function FVID_exchange twice - once for the front end and once on the back end. As I understand it the driver simply modifies the register overlay so that the pointer for the buffer for the VPBE/VPFE is changed to the appropriate memory address. The code reads like this:
while(status == 0){
FVID_exchange(hGioVpfeCcdc, &frameBuffPtr);
FVID_exchange(hGioVpbeVid0, &frameBuffPtr);
}
Since I want to modify every pixel in a frame I inserted a for loop between the two API calls that loops through each pixel and multiplies it by .5:
for(j=0; j<num_pixels; j++){
*((Uint8*)frameBuffPtr->frame.frameBufferPtr + j) *= .5;
}
This certainly resulted in a modified image, but not at all what I expected. First the frame rate appears to have dropped to a near stand still. Second the actual image doesn't look lighter. It's distorted with vertical "lines" (spaced what appears to be every other column) and saturation on the white end. As I understand the diver architecture and API calls what should happen after the first exchange is that frameBuffPtr points to the address of the dequeued frame from the VPFE. I modify that frame with my loop and then queue this frame onto the output frame buffer. The dequeued output frame buffer is queued into the input on the next execution of the loop. Since the VPBE just reads data out memory continuously I expect that if the "algorithm" that resides between the two FVID_exchange calls takes a while that the VPFE will just display the same frame over and over until a queue/dequeue operation. Is that the way the driver is in fact implemented, or does is the driver interrupt based such that it just rolls through the VPBE frame buffer continuously regardless of queue/dequeue operations? Clearly what I'm trying to do is working as hopped. Is this the right approach? What am I missing?
The driver documentation doesn't really explain the inner workings of the driver. It states that it's interrupt based though. I assume that every time a new frame comes in that the driver places it in the tail of the queue. Does it overwrite data automatically? In other words if my algorithm is REALLY slow and I'm processing a frame is it possible for the VPFE to overwrite the frame I'm processing? Eg if I don't dequeue a frame is data overwritten? On the other hand if I repeatedly call FVID_exchange on the VPFE and then the VPBE and a new frame is NOT ready does the driver block for a new frame? Any help/input would be much appreciated. Thanks,
D