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: Queries Regarding H.264 Encoder

Part Number: TDA4VM

Hi,

Please find thw Queries regarding H.264 Encoder

1. We want to use h264 encoding with following settings:

-- intra refresh period = 5 -- we are using V4L2_CID_MPEG_VIDEO_H264_I_PERIOD, but is it valid? Isn't it IDR period?

-- GOP = 30 -- we use V4L2_CID_MPEG_VIDEO_GOP_SIZE for that, is it correct? In V4L2 driver it maps to "idr_period". On another platform we have separate GOP and IDR period.

-- IDR period = 30 -- we don't see which control to use for that?

-- constant bitrate setting

-- base profile

Right now we see that instead of stream with IDR of 30 and intra-refreshing partially frames every 5th frame (5 period) we got every 5-th frame fully I. This is not what we expect and need help.

2. In Topaz API header there is field:

    unsigned short intra_refresh;

We suspect it is intra refresh period but it doesn't map anywhere.

3. In driver I see that NO_CR Topaz fw is used. Can we use CBR for constant bitrate? What should we do for that?

    ret = topaz_upload_firmware(ctx, IMG_CODEC_H264_NO_RC);

  • Hi Dwarakesh,

    we use V4L2_CID_MPEG_VIDEO_GOP_SIZE for that, is it correct?

    Gop Size is properly tested and you can use that.

    we are using V4L2_CID_MPEG_VIDEO_H264_I_PERIOD, but is it valid?

    I_PERIOD is not tested properly on our side.

    -- base profile

    If you are trying to force the driver to base profile, You can use the below patch. This patch is a part of SDK 8.5, which will be released in the upcoming month.

     

    1 file changed, 2 insertions(+), 2 deletions(-)
    drivers/media/platform/vxe-vxd/encoder/vxe_enc.c | 4 ++--
    
    modified   drivers/media/platform/vxe-vxd/encoder/vxe_enc.c
    @@ -353,10 +353,10 @@ void vxe_fill_default_params(struct vxe_enc_ctx *ctx)
      ctx->vparams.slices_per_picture = 1;
      ctx->vparams.is_interleaved = FALSE;
      ctx->vparams.constrained_intra = FALSE;
    - ctx->vparams.h264_8x8 = TRUE;
    + ctx->vparams.h264_8x8 = FALSE;
      ctx->vparams.bottom_field_first = FALSE;
      ctx->vparams.arbitrary_so = FALSE;
    - ctx->vparams.cabac_enabled = TRUE;
    + ctx->vparams.cabac_enabled = FALSE;
      ctx->vparams.cabac_bin_limit = 2800;
      ctx->vparams.cabac_bin_flex = 2800;
      ctx->vparams.deblock_idc = 0;

       unsigned short intra_refresh;

    I have checked this, and I dont think there is any support in the driver for this.

    3. In driver I see that NO_CR Topaz fw is used. Can we use CBR for constant bitrate? What should we do for that?

        ret = topaz_upload_firmware(ctx, IMG_CODEC_H264_NO_RC);

    I think, I will need some more time to get back to you on this.

    Regards

    Nikshith

  • Hi Dwarakesh,

    Can we use CBR for constant bitrate?

    Yes, it is supported. 

    What should we do for that?

    The value can be passed through the Gstreamer pipeline.

    regards

    Nikshith

  • Hi Nikshith,

    Here two sdp. we want TI encoder to produce same 7875.reference_iccd.txt5148.ti_iccd.txt SPS described in Reference sdp. Currently we have settings presented in ti_iccd.sdp.

    Parsed in readable format fields are applied in txt file.


    Settings same as provided before in ticket

  • Hi Dwarakesh,

    Regarding the questions mailed,

    3) We observe that when we set the bitrate of the stream to 1M or similar we still get an actual bitrate of 2.5M. If bitrate value is set 2.5M then actual is more as well. On another platform we used actual bitrate as requested. I supposed it is due to "no_rc" (no rate control) firmware used in Topaz but I might be wrong.

    On TDA4VM SDK 8.4 Linux, bitrate is working as expected using standalone gstreamer command.

    Can you share more details on how you are encoding the file?

    Are you using a camera input or filesrc?

    If possible can you share the raw files as well?

    We are working on other 2 questions as well with priority. Will update the details soon.

    Regards

    Nikshith

  • Hi Dwarakesh, 

    1. We want to use h264 encoding with following settings:

    - intra refresh period is not supported and using V4L2_CID_MPEG_VIDEO_H264_I_PERIOD for intra refresh is not valid

    - In TDA4VM driver, V4L2_CID_MPEG_VIDEO_GOP_SIZE is used to set IDR_PERIOD.

    - Rate control mode settings are not supported and VBR is enabled by default.

    - In order to use base profile, please use the patch shared in the above comment. High profile is enabled by default in the driver. 

    2. In Topaz API header there is field:

        unsigned short intra_refresh;

    - The variable is just defined but has no implementation in the driver.

     

    Regards

    Nikshith

  • Hi Dwarakesh,

    1. Can you share more details on how you are creating the sdp file using TI encoder like gstreamer command or steps to reproduce the issue

    2. There are many parameters which are different. Are there any parameters with priority?

    Regards

    Nikshith

  • Hi ,

    I have below queries and need your help to answer these -

    1 - Is CBR rate control supported ??

    2 - Any link page or user guide to know all the supported Encoder features ?? E,g Link

    3 - Setting the below parameters, Rate control internally takes cares the parameters based on the input stream ??

        ctx->rc.initial_qp_i = 0;

        ctx->rc.initial_qp_p = 0;

        ctx->rc.initial_qp_b = 0;

        ctx->rc.min_qp = 0;

        ctx->rc.max_qp = 0;

        ctx->rc.rc_enable = TRUE;



    Regards

    Gajanan

  • Hi Gajanan,

    We have raised a request with our partner team. Will update you once we get the response.

    Regards

    Nikshith

  • Hi Nikshith,

    Thanks for raising this query with partner team. I have another following question on the encoding parameters -

    1 - If I change the below parameters, the generated stream is non-compliance and not able to decode properly

    ctx->sh_params.log2_max_pic_order_cnt = 8; //default value is 6

    2 - If I change the below parameters, the generated stream is non-compliance and not able to decode properly

    generate_ue(mtx_header, element_pointers, 4); /* log2_max_frame_num_minus4 = 1, default value is 1


    Can you let me know what changes to be done to get the above parameters reflect and generate decodable streams ???

    Regards

    Gajanan

  • Hi Nikshith,

    When I enabled the CBR mode, we observed the bitrate achieved is not consistent and under achieved for the same video contents.

    ctx->rc.rc_mode =IMG_RCMODE_CBR


    Example, if we set 2.5Mbps, we are getting 1.5Mbps. The bitrate graph is shown below -




    Regards

    Gajanan

  • Hi Gajanan,

    2 - Any link page or user guide to know all the supported Encoder features ??

    All the supported encoder features are mentioned in the documentation. please use the below link.

    https://software-dl.ti.com/jacinto7/esd/processor-sdk-linux-jacinto7/08_04_00_11/exports/docs/linux/Foundational_Components_Multimedia_D5520_VXE384.html#v4l2-video-encoder

    When I enabled the CBR mode, we observed the bitrate achieved is not consistent and under achieved for the same video contents.

    We are already testing by changing the rc_mode to CBR and facing similar kind of inconsistencies as you are facing. We will get back to you.

    Regards

    Nikshith

  • Hi Gajanan,

    Can you give more clarity on the graph attached.

    Example, if we set 2.5Mbps, we are getting 1.5Mbps. The bitrate graph is shown below -

    1. What is X-axis and Y-axis denoting?

    2. What is the tool used to generate the graph. Is it open-source?

    3. You have mentioned a bitrate of 1.5Mbps. Can you let us know, how did you infer that from the graph attached?

    4. The graph seems to have periodic nature. Can you share the raw .yuv file?

  • HI Nikshith,

    1. What is X-axis and Y-axis denoting?

    X-axis ==> Frame Number

    Y-axis ==> Bytes consumed

    2. What is the tool used to generate the graph. Is it open-source?

    github.com/.../releases

    3. You have mentioned a bitrate of 1.5Mbps. Can you let us know, how did you infer that from the graph attached?

    If you open the genrated bit-stream in above shared tool, you will get these details

    4. The graph seems to have periodic nature. Can you share the raw .yuv file?

    This behaviour is observed with real time capture and encoding. So I dont have yuv available. And also encoded stream I cannot share it here due to confidentiality.  Since you are able to reproduce the issue at your end, I don't see any requirement of sharing this.

    Kindly let me know if you need more details.

    Regards

    Gajanan

  • Hi Gajanan,

    The raw file is taken from this location. https://github.com/tianchenghe2017/VTM/blob/master/BasketballPass_416x240_50.yuv

    the above file is encoded both using VBR and CBR. When opened using the above tool you have shared, the graphs are different for VBR and CBR and CBR is working fine.CBR doesn't mean that every frame will be of same bitrate but, every set of frames grouped together have same mean bitrate. 

    if we set 2.5Mbps, we are getting 1.5Mbps. The bitrate graph is shown below -

    But still could not understand how you infered 1.5 mbps bitrate from the tool. please provide more details on how to see bitrate in the tool. When checked using ffprobe, we can see the bitrate.

    Regards

    Nikshith

  • Hi Nikshith,

    the above file is encoded both using VBR and CBR. When opened using the above tool you have shared, the graphs are different for VBR and CBR and CBR is working fine.CBR doesn't mean that every frame will be of same bitrate but, every set of frames grouped together have same mean bitrate. 

     ==> I will share you more details to on this


    But still could not understand how you infered 1.5 mbps bitrate from the tool. please provide more details on how to see bitrate in the tool. When checked using ffprobe, we can see the bitrate.

    ==> You can use H264 Analyser to see the bitrate for the generate stream

  • Hi Nikshith,

    Please use the below attached files -



    8865.txt


    2364.txt

    Rename the above RAW video files from .txt to .yuv (e.g 8865.txt to 1.yuv & 2364.txt to 2.yuv)


    Create the input raw file combination of black and actual raw video -

    cat 1.yuv 2.yuv 1.yuv 2.yuv 1.yuv 2.yuv 1.yuv 2.yuv 1.yuv 2.yuv 1.yuv 2.yuv 1.yuv 2.yuv 1.yuv 2.yuv > input_704x512_nv12.yuv


    Execute the below to generate CBR and VBR streams (Note the driver needs to be changed to change the modes CBR/VBR).
    BITRATE is 2.5mbps, gop is 30, intra interval is 5, nv12 format

    ./tienc_encode -i input_704x512_nv12.yuv -w 704 -h 512 -b 2500000 -p 5 -g 30 -o output_2.5Mbps_cbr.264

    ./tienc_encode -i input_704x512_nv12.yuv -w 704 -h 512 -b 2500000 -p 5 -g 30 -o output_2.5Mbps_vbr.264


    The result summary is below -


    For CBR the encoded files bit-rate is under achieved and VBR bit-rate is overshoot

     CBR - 1.56Mbps (Underachieved)

    VBR - 5.3Mbps (Overshoot)

    Regards

    Gajanan

  • Hi Gajanan,

    CBR and VBR are working fine with the above basket ball video.

    For CBR the encoded files bit-rate is under achieved and VBR bit-rate is overshoot

     CBR - 1.56Mbps (Underachieved)

    VBR - 5.3Mbps (Overshoot)

    We could replicate the issue at our end. Saw under achievement in CBR and Overshoot in VBR. We are debugging the issue.

    Regards

    Nikshith

  • Hi Nikshith,

    Also please reply to this query as well - 

    I have another following question on the encoding parameters -

    1 - If I change the below parameters, the generated stream is non-compliance and not able to decode properly

    ctx->sh_params.log2_max_pic_order_cnt = 8; //default value is 6

    2 - If I change the below parameters, the generated stream is non-compliance and not able to decode properly

    generate_ue(mtx_header, element_pointers, 4); /* log2_max_frame_num_minus4 = 1, default value is 1


    Can you let me know what changes to be done to get the above parameters reflect and generate decodable streams ???

    Regards

    Gajanan

  • Hi Gajanan,

    We have gone back to our patner. And the parameters that you are referring to are hardcoded in the Encoder firmware, and we cannot configure from our driver. Attaching the reply from the vendor.

    The size of those fields are also hard coded in the encoder firmware so we can't change them.

    Regards,

    Prasanth