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.

TDA4VH-Q1: Live LDC testing without using DCC tool

Part Number: TDA4VH-Q1

Hello Team,

I referred below link for doing LDC tunning,  

https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1058565/faq-tda4vm-how-to-create-a-ldc-mesh-lut-for-fisheye-distortion-correction-on-tda4?keyMatch=LDC%20FAQ

but we want to remove DCC tool dependency that's why I referred multi_cam_codec_ldc_module application logic at [ti-processor-sdk-rtos-j784s4-evm-09_02_00_05/vision_apps/apps/basic_demos/app_multi_cam_codec/multi_cam_codec_ldc_module.c] path

where they are using ldc_lut_1920x1080.h for lut and we want to use same logic 

in multi_cam_codec_ldc_module file they are using mesh table width and height calculation formula as follow:

   ldcObj->table_width = (((ldcObj->image_width / (1 << ldcObj->ds_factor)) + 1u) + 15u) & (~15u);

   ldcObj->table_height = (ldcObj->image_height / (1 << ldcObj->ds_factor)) + 1u;

in which image_width = 1920, height =1080, ds_factor(downsampling) = 2

so the output of the

ldcObj->table_width = 1920/4  +16= 496

ldcObj->table_height = 1080/4 +1 = 271

 

Total size of the table = 496*271 = 134416

And have unint 32 i.e. multiplied with 4 bytes

Then

Mesh_img = 134416* 4 = 537664 which is matching with ldc_lut_1920x1080.h bytes size.

 

That’s why we are getting correct output.

So, question is

1.how to create ldc_lut_1920x1080.h -> for image 1920x1280 without using DCC tool?

2. how to get the formula for getting mesh width and height for mesh_image that we remove the dcc tool dependency 

so Can you please guide me

Thank you 

  • Hi Vaishnavi,

    where they are using ldc_lut_1920x1080.h for lut and we want to use same logic 

    Yes, this can work, but it requires you to handle all the H/W details in your own code.

    in multi_cam_codec_ldc_module file they are using mesh table width and height calculation formula as follow:

    That is OK as the LUT is created separately and not by tuning tool.

    1.how to create ldc_lut_1920x1080.h -> for image 1920x1280 without using DCC tool?

    This H/W LUT is the same as the included LUT inside the xml output of tuning tool.
    You may just copy that the LUT from tuning tool output for your C header file.

    If you don't want to use the tuning tool at all for calculating the H/W LUT, then you will have to follow the TRM and the LDC FAQ page to do everything on your own.
    The FAQ page explains the padding needed at the end of the each row and you will have to calculation and padding in your own code.
    https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1058565/faq-tda4vm-how-to-create-a-ldc-mesh-lut-for-fisheye-distortion-correction-on-tda4?keyMatch=LDC%20FAQ

    You will have to follow the steps in FAQ carefully and do everything correctly.

    2. how to get the formula for getting mesh width and height for mesh_image that we remove the dcc tool dependency 

    This depends on the H/W padding at the end of each row you would have to add.
    Please go through the LDC FAQ page for H/W row alignment details.

  • Hello Gang,

    Thanks for reply,

    I generated the LUT file from DCC tool and saved as header file and called from node_ldc.c file as follow:

    AR0233_mesh_lut_2.h -> LUT file from DCC tool

    node_ldc.c : add LUT header file, then updated the configure_mesh_params function , in which

    given block width, height and pixelpad values from DCC tool output at left side(from best 5 selected  block size)
    #define LDC_BLOCK_WIDTH     (168)
    #define LDC_BLOCK_HEIGHT    (48)
    #define LDC_PIXEL_PAD       (1)
    #define LDC_DOWN_SAMPLING       (4u)

    #include "AR0233_mesh_lut_2.h"
    static vx_status configure_mesh_params(vx_context context, LDCObj *ldcObj)
    {
     vx_status status = VX_SUCCESS;
     vx_uint32 table_width_ds, table_height_ds;
     vx_imagepatch_addressing_t image_addr;
     vx_rectangle_t rect;
     uint16_t ldc_lut[] = GEN3_LDC_LUT_1920_1280;

     ldcObj->ds_factor = 4u;

     GEN3_DBG_PRINTF("ldc img w [%d]\n", ldcObj->image_width);
     GEN3_DBG_PRINTF("ldc img h [%d]\n", ldcObj->image_height);

     table_width_ds = (((ldcObj->image_width / (1 << ldcObj->ds_factor)) + 1u));//121
     table_height_ds = (ldcObj->image_height / (1 << ldcObj->ds_factor)) + 1u;//81

     GEN3_DBG_PRINTF("ldc table w [%d]\n", table_width_ds);
     GEN3_DBG_PRINTF("ldc table h [%d]\n", table_height_ds);

     /* Mesh Image */
     ldcObj->mesh_img = vxCreateImage(context, table_width_ds, table_height_ds, VX_DF_IMAGE_U32);
     GEN3_DBG_PRINTF("ldcObj->mesh_img = vxCreateImage working\n");

     
     status = vxGetStatus((vx_reference)ldcObj->mesh_img);

     if (status == VX_SUCCESS)
     {
     vxSetReferenceName((vx_reference)ldcObj->mesh_img, "ldc_node_mesh_img");
     GEN3_DBG_PRINTF("vxSetReferenceName working \n");
     /* Copy Mesh table */
     rect.start_x = 0;
     rect.start_y = 0;
     rect.end_x = table_width_ds;
     rect.end_y = table_height_ds;

     image_addr.dim_x = table_width_ds;
     image_addr.dim_y = table_height_ds;
     image_addr.stride_x = LDC_DOWN_SAMPLING;
     image_addr.stride_y = table_width_ds * LDC_DOWN_SAMPLING;

     status = vxCopyImagePatch(ldcObj->mesh_img,
     &rect,
     0,
     &image_addr,
     ldc_lut,
     VX_WRITE_ONLY,
     VX_MEMORY_TYPE_HOST);

     GEN3_DBG_PRINTF("vxCopyImagePatch working \n");

     if (status == VX_SUCCESS)
     {
     /* Mesh Parameters */
     memset(&ldcObj->mesh_params, 0, sizeof(tivx_vpac_ldc_mesh_params_t));

     tivx_vpac_ldc_mesh_params_init(&ldcObj->mesh_params);
     // this vaules changed
     ldcObj->mesh_params.mesh_frame_width = ldcObj->table_width;
     ldcObj->mesh_params.mesh_frame_height = ldcObj->table_height;
     ldcObj->mesh_params.subsample_factor = ldcObj->ds_factor;

     ldcObj->mesh_config = vxCreateUserDataObject(context, "tivx_vpac_ldc_mesh_params_t", sizeof(tivx_vpac_ldc_mesh_params_t), NULL);
     status = vxGetStatus((vx_reference)ldcObj->mesh_config);

     if (status == VX_SUCCESS)
     {
     vxSetReferenceName((vx_reference)ldcObj->mesh_config, "ldc_node_mesh_config");

     status = vxCopyUserDataObject(ldcObj->mesh_config, 0,
     sizeof(tivx_vpac_ldc_mesh_params_t),
     &ldcObj->mesh_params,
     VX_WRITE_ONLY,
     VX_MEMORY_TYPE_HOST);
     if (status != VX_SUCCESS)
     {
     GEN3_DBG_PRINTF_ERR("Unable to copy mesh params into buffer! \n");
     }
     }
     else
     {
     GEN3_DBG_PRINTF_ERR("Unable to create mesh config object! \n");
     }
     }
     else
     {
     GEN3_DBG_PRINTF_ERR("Unable to copy mesh image! \n");
     }
     }
     else
     {
     GEN3_DBG_PRINTF_ERR("Unable to create mesh image! \n");
     }


     return status;
    }

    then updated app_iss_common.c file for the data

     and final output look like:

    Can you please check each step where I am doing wrong ?

    1. size of the LUT header file?

    2. code node_ldc.c?

    3. app_iss_common.c file change?

  • 1. size of the LUT header file?

    Could you please share your xml file from tuning tool and "AR0233_mesh_lut_2.h"?

  • Do you have the xml file from tuning tool as well?

  • AR0233_mesh_lut_2.h

    In this file, your LUT is 81 rows and 248 16-bit entries per row.

     table_width_ds = (((ldcObj->image_width / (1 << ldcObj->ds_factor)) + 1u));//121
     table_height_ds = (ldcObj->image_height / (1 << ldcObj->ds_factor)) + 1u;//81

    That corresponds to a table width of 124 (including 16x down sampling and 0 padding).

  • #define LDC_BLOCK_WIDTH     (168)

    This value shall be limited to a factor of your output image width because of a driver limitation.

    For 1920x1280 output, you may try 128 or 64.

  • for LUT rows = 81 is in file, How 248?-> can you please explain and 124? as well

    because table_width_ds = 1920/(16) = 120 +1 =121

  • not for same image, I tried with other image for 2MP, so row and columnAR0233_mesh_lut.txt size is same 

  • or LUT rows = 81 is in file, How 248?-> can you please explain and 124? as well

    Please take a look at your xml file.
    That should be one line about how many bytes are on each row.
    Table width is the same as the number of bytes per row divided by 4 (32-bit each element after down sampling).
    Table height is the number of rows.

  • not for same image, I tried with other image for 2MP, so row and columnAR0233_mesh_lut.txt size is same 

    Not sure what you mean here.

    The table width includes both the data entries on each row and the 0 paddings at the end.
    Please refer to the LDC FAQ page for details.