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: How to convert YUYV 422 input format into NV12?

Part Number: TDA4VM

Hi Team,

My camera sensor output format is YUYV 422 format, but i check ti sdk code that LDC only support input UYVY, I was wondering how can we convert such YUYV input into NV12?

Is it possible to make LDC support such format or any other way to convert the format in an efficient way?

Thanks.

  • Hi,

    LDC cannot support this format, but you can use DSS WB M2M path for this conversion. This node is supported in the SDK. 

    Regards,

    Brijesh

  • BTW, where can I find the actual ldc operator related codes in SDK, namely those algorithm which convert 422 to nv12?

    Is Ldc can be reprogrammed to support YUYV?

  • Hi,

    No, LDC supports only UYVY YUV422 format. 

    Regards,

    Brijesh

  • OKay, then I'll try with DSS.

  • Hi Brian,

    Please refer to attached patch, i have added DSS M2M path for format conversion from YUV420 to UYVY just before display in multi-camera example. 

    /cfs-file/__key/communityserver-discussions-components-files/791/0001_2D00_Added_2D00_Format_2D00_Conversion_2D00_module_2D00_at_2D00_end_2D00_of_2D00_mosaic_2D00_in_2D00_M.patch

    Regards,

    Brijesh

  • Hi Brian,

    Dataformat YUYV ie VX_DF_IMAGE_YUYV internally used as YUV422 format for DSS. So you can use it.

    Regards,

    Brijesh

  • Thanks Brijesh, it works.

    And there's another question, we also use UYVY sensor and we set capture output format as UYVY then we write down capture output, we see that the output image is indeed UYVY.

    But we also try setting capture format as YUYV,then we got capture output which changing into YUYV format. Does capture node can rearrange data layout according to the setting of capture output format? How does this happen?

  • Hi Brian,

    Yes, CSIRX can support this interleaving of YUV data. But this is supported only for YUV422 interleaved format. 

    Regards,

    Brijesh

  • Hi Brijesh,

    Yes, the sensor format is YUV422 interleaved. I mean why my sensor output is UYVY, but capture node output format is set as YUYV which can also get image data whose format is YUYV instead of sensor's format UYVY?

  • Hi Brian,

    As i said, as per the CSI specs, data type is just YUV422 and typically it is sent out in UYVY format. Now CSIRX module can rearrange the order of Y and UV data based on configuration. This is done inside the CSIRX. 

    In the above case, sensor outputs in UYVY format, but CSIRX module rearranges them into YUYV format and stores them in the memory. 

    Regards,

    Brijesh

  • Thank you Brijesh for your patient anwser.

    As I mentioned in the very beginning, we want convert YUYV format into NV12.  So our camera sensor output now is YUYV, and I set capture format output also as YUYV, but get the output in a strange way like below, I directly use fwrite to dump capture deque output image and decode with an YUV view tool.

    It seems that the format is UYVY instead of YUYV. Because if I decode the image data with UYVY format it seems all right:

    What do you suggest for this?

    And I saw that someone else has a similar problem: https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1190635/tda4x-single-camera-application-supports-the-yuv422-format/4537397#4537397

    Is this same problem as mine?

  • Hi Brian,

    Yes, your input image format does not seem to be YUYV, but instead it is UYVY format. Typically, CSI sends the YUV422 data in UYVY format.

    Btw, DSS M2M supports both YUYV and UYVY formats. 

    Regards,

    Brijesh

  • Hi Brijesh,

    I confirmed with sensor manufacture, they said sensor format is indeed YUYV, do we configure something wrongwhere in CSI?

    Below is what we give createPrms of sensor:

    static IssSensor_CreateParams x1f_t22CreatePrms = {
    T22_X1F_96701, /*sensor name*/
    0x0, /*i2cInstId*/
    {0x36, 0, 0, 0, 0, 0, 0, 0}, /*i2cAddrSensor*/
    {0x40, 0x41, 0x42, 0x43, 0, 0, 0, 0}, /*i2cAddrSer*/
    /*IssSensor_Info*/
    {
    {
    X1F_T22_OUT_WIDTH, /*width*/
    X1F_T22_OUT_HEIGHT, /*height*/
    1, /*num_exposures*/
    vx_false_e, /*line_interleaved*/
    {
    {VX_DF_IMAGE_YUYV, 7}, /*dataFormat and MSB [0]*/
    },
    0, /*meta_height_before*/
    0, /*meta_height_after*/
    },
    ISS_SENSOR_X1F_T22_FEATURES, /*features*/
    ALGORITHMS_ISS_AEWB_MODE_NONE, /*aewbMode*/
    25, /*fps*/
    4, /*numDataLanes*/
    {1, 2, 3, 4}, /*dataLanesMap*/
    {0, 0, 0, 0}, /*dataLanesPolarity*/
    CSIRX_LANE_BAND_SPEED_800_TO_880_MBPS, /*CSI Clock*/
    },
    4, /*numChan*/
    233, /*dccId*/
    };
  • Hi Brian,

    Which application are you using? Because in multi-camera application, i see it checked for only VX_DF_IMAGE_UYVY format. It assumes sensor is in YUV422 format only if format is set to VX_DF_IMAGE_UYVY. 

    Regards,

    Brijesh

  • Also are the above images dumped from CSIRX? and how do you view them?

  • Hi Brijesh,

    Yes, I'm developing based on multi-cam app, do you mean the format check in sensor module here:

    if(sensorObj->sensorParams.sensorInfo.raw_params.format[0].pixel_container == VX_DF_IMAGE_UYVY)
    {
    sensorObj->sensor_out_format = 1;
    }
    else
    {
    sensorObj->sensor_out_format = 0;
    }
    I adjust it into below:
    if (sensorObj->sensorParams.sensorInfo.raw_params.format[0].pixel_container == VX_DF_IMAGE_UYVY)
    {
    sensorObj->sensor_out_format = 1;
    }
    else if(sensorObj->sensorParams.sensorInfo.raw_params.format[0].pixel_container == VX_DF_IMAGE_YUYV)
    {
    sensorObj->sensor_out_format = 2;
    }
    else
    {
    sensorObj->sensor_out_format = 0;
    }
    and set cpature output as:
    vx_image cap_yuv_image = vxCreateImage(
    context,
    sensorParams->sensorInfo.raw_params.width,
    sensorParams->sensorInfo.raw_params.height,
    VX_DF_IMAGE_YUYV);
    And I dump image after
    vxGraphParameterDequeueDoneRef(obj->graph, captureObj->graph_parameter_index, (vx_reference*)&capture_output_arr, 1, &num_refs);
    :
    rect.start_x = 0;
    rect.start_y = 0;
    rect.end_x = img_width;
    rect.end_y = img_height;
    status = vxMapImagePatch(
    out_img, &rect, 0, &map_id, &image_addr, &data_ptr, VX_READ_ONLY, VX_MEMORY_TYPE_HOST, VX_NOGAP_X);

    /* Copy Luma */
    for (j = 0; j < img_height; j++)
    {
    num_bytes += fwrite(data_ptr, 1, img_width*2, fp);
    data_ptr += image_addr.stride_y;
    }
    Then we get a binnary file we use an typical open source YUV image view tool to view them. In this tool we configure data format.
  • Hi,

    Yes, the method looks to be correct. 

    Well, if you are getting correct output, even with UYVY format, you can continue using it. This format is supported in LDC as well as in DSS M2M, so can be converted to NV12 format. 

    Regards,

    Brijesh

  • Hi Brijesh,

    I think we are not in the same page, maybe I miss the point.

    My question is, even sensor format is YUYV, and capture node format parameter is set as YUYV, but the actual data layout form capture is UYVY, however since I set capture output format as YUYV, all following node no mater LDC or DSS will get capture out and set their input format YUYV, but the actual data layout is not UYVY, this will lead to miss behavior.

    And I want to know why the data layout format is not the way I expect.

  • Hi Brian,

    ok, since the actual data format is in UYVY format, i would suggest a small change in the capture node, can you please interchange case values in the below code in ti-processor-sdk-rtos-j721e-evm-08_06_00_12\tiovx\kernels_j7\hwa\capture\vx_capture_target.c file and check it with UYVY format? 

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    /* TODO: Complete this case statement */
    static uint32_t tivxCaptureExtractDataFormat(uint32_t format)
    {
    uint32_t dataFormat = FVID2_DF_BGRX32_8888;
    switch (format)
    {
    case (vx_df_image)VX_DF_IMAGE_UYVY:
    dataFormat = FVID2_DF_YUV422I_UYVY;
    break;
    case (vx_df_image)VX_DF_IMAGE_YUYV:
    dataFormat = FVID2_DF_YUV422I_YUYV;
    break;
    default:
    dataFormat = FVID2_DF_BGRX32_8888;
    break;
    }
    return dataFormat;
    }
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Regards,

    Brijesh

  • Hi Brijesh,

    Yes, if interchange the FVID2 format, then I can get the same format as I set in capture node.

    What's the cause then?

  • Hi Brian,

    The CSIRX, as per the CSI specs, assumes that the input format is UYVY, so when you set YUYV format, it swaps luma and chroma bytes. But in your case, input is in YUYV format, so setting YUYV will also swap luma and chroma bytes, so the output becomes UYVY format. 

    Regards,

    Brijesh

  • OK, then I should swap around when sensor output is YUYV.

    Thanks a lot.