To better understand the driver usage, consider the following test case scenario. Suppose the core in the design was configured with memory based mode and eight input streams. Driver should program the input image width, input image height, stride for input image, video format of the input image, sampling rate, and source buffer address registers for all the configured eight input streams. The application should allocate required frame buffer space for each input stream in memory. These addresses can be updated during the interrupt. To integrate and use the Video Scene Change driver in the application, the following steps should be performed:
- Include the driver header file xv_scenechange.h that contains the Video Scene Change Detection IP instance object definition.
- Declare an instance of the Video Scene Change Detection IP type:
- Initialize the Video Scene Change DetectionIP
instance at power on:
XV_scenechange_Initialize(&ScdPtr, DeviceId);. This function accesses the hardware configuration and initializes the core instance structure.
- If the core is operating in an interrupt mode, the application needs to perform the tasks mentioned, that is, register the ISR with the system interrupt controller and set the application callback function. This function is called by the Video Scene Change Detection IP driver when the frame done IRQ is triggered.
- If applicable, write the application level callback function. An example action to be performed here would be to update Source Image buffer addresses, that is, from where to read the next frame data for each output. This allows the application to render the frame updates in memory, on screen.
- Set the number of input streams for memory based mode by the function
- Configure input image width, input image height, input image width, stride for input image, video format of the input image, subsampling rate, and source buffer address registers for all the configured streams.
- Enable the interrupts using the following functions:
- Start the IP using the
XV_scenechange_Start(&ScdPtr)function and wait for the interrupt.
- Resolution changes are not possible on the fly. If the changes are
needed then the application must reset the Video Scene Change Detection, that is toggle
ap_rst_n, and reconfigure the core for the new resolution. After reset, all registers are cleared to 0.
- The application code should check the return status of all APIs to make sure the required action was completed successfully and if not take corrective action.