Because of the Thanksgiving holiday in the U.S., TI E2E™ design support forum responses may be delayed from November 25 through December 2. Thank you for your patience.

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.

TDA4VM: Enabling encoding affects the display and capture of camera data

Part Number: TDA4VM

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--;
        }
    }
    ...
}

Current problems
Once appCodecEnqAppSrc(obj->appsrc_push_id) turns on the display, the following code in the display thread will take 10~14ms to complete, so the display thread will not run at 60fps
vxGraphParameterDequeueDoneRef(obj->graph_left, obj->displayObj_csi_tx_vc0_left.output_graph_parameter_index, (vx_reference*)&output_image, 1, &num_refs);
If I comment the following code in the coding thread
appCodecEnqAppSrc(obj->appsrc_push_id);
Then the following code in the display thread takes 6~8ms to complete and the display thread can run to 60fps
vxGraphParameterDequeueDoneRef(obj->graph_left, obj->displayObj_csi_tx_vc0_left.output_graph_parameter_index, (vx_reference*)&output_image, 1, &num_refs);