Tool/software:
Hardware: TDA4VM
SDK: 0806
As shown in the figure, it is the currently designed data flow of Encode and Display. In actual processing,
There are 4 threads in total
One thread is responsible for capturing the data of the left channel and right channel cameras and distributing the images to Display and Encoder. The target frame rate is: 60fps.
One thread is responsible for left channel display, target frame rate: 60fps
One thread is responsible for right channel display, target frame rate: 60fps
One thread responsible for encoding (RTSP, MP4), target frame rate: 10fps
The main code for encoding threads:
static vx_status codec_encode(AppCMS_Codec *obj, vx_int32 frame_id) { vx_status status = VX_SUCCESS; AppGraphParamRefPool *enc_pool = &obj->enc_pool; if (frame_id >= APP_BUFFER_Q_DEPTH) { if (frame_id >= enc_pool->bufq_depth) { if (status == VX_SUCCESS && obj->encode == 1) { status = appCodecDeqAppSrc(obj->fifo_id_output); if (status != VX_SUCCESS) { printf("# ERROR: func:%s Error appCodecDeqAppSrc return err. obj->fifo_id_output [%d]\n", __func__,obj->fifo_id_output); } } if (status == VX_SUCCESS) { status = unmap_vx_object_arr(enc_pool->arr[obj->fifo_id_output], enc_pool->map_id[obj->fifo_id_output], obj->sensorObj_num_cameras_enabled); if (status != VX_SUCCESS) { printf("# ERROR: func:%s Error unmap_vx_object_arr[=][=] status:obj->fifo_id_output [%d] obj->appsrc_push_id [%d]\n", __func__,obj->fifo_id_output,obj->appsrc_push_id); } status = VX_SUCCESS; } } if (status == VX_SUCCESS) { status = map_vx_object_arr(enc_pool->arr[obj->appsrc_push_id], enc_pool->data_ptr[obj->appsrc_push_id], enc_pool->map_id[obj->appsrc_push_id], obj->sensorObj_num_cameras_enabled); if (status != VX_SUCCESS) { printf("# ERROR: func:%s Error map_vx_object_arr[*][*] status:obj->fifo_id_output [%d]\n", __func__,obj->fifo_id_output); } status = VX_SUCCESS; } if (status == VX_SUCCESS && obj->encode == 1) { status = appCodecEnqAppSrc(obj->appsrc_push_id); } if (status == VX_SUCCESS) { obj->appsrc_push_id++; obj->appsrc_push_id = (obj->appsrc_push_id >= enc_pool->bufq_depth) ? 0 : obj->appsrc_push_id; } } }
The main code for Display thread:
if (DD_ENABLE_LEFT_Display) { uint32_t num_refs; static int display_node_wait_loops=3; static int msc_out_node_wait_loops=2; if (status == VX_SUCCESS) { if(msc_out_node_wait_loops==0) { status = vxGraphParameterDequeueDoneRef(obj->graph_left, obj->imgMosaicObj_left.output_graph_parameter_index, (vx_reference*)&output_image, 1, &num_refs); if (status != VX_SUCCESS) { printf("vxGraphParameterDequeueDoneRef L q Out error\n"); } status = vxGraphParameterDequeueDoneRef(obj->graph_left, obj->imgMosaicObj_left.inputs[0].graph_parameter_index, (vx_reference*)&output_image, 1, &num_refs); if (status != VX_SUCCESS) { printf("vxGraphParameterDequeueDoneRef L q In error\n"); } } else { msc_out_node_wait_loops--; } } if (status == VX_SUCCESS) { if(display_node_wait_loops==0) { status = vxGraphParameterDequeueDoneRef(obj->graph_left, obj->displayObj_csi_tx_vc0_left.output_graph_parameter_index, (vx_reference*)&output_image, 1, &num_refs); if (status != VX_SUCCESS) { printf("vxGraphParameterDequeueDoneRef L q error\n"); } } else { display_node_wait_loops--; } } ... }
vxGraphParameterDequeueDoneRef(obj->graph_left, obj->displayObj_csi_tx_vc0_left.output_graph_parameter_index, (vx_reference*)&output_image, 1, &num_refs);
appCodecEnqAppSrc(obj->appsrc_push_id);