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: encoder driver API - no V4L2 control

Part Number: TDA4VM

Team,

There is a limitation with the encoder API that is an important blocker right now. We need to have a way to switch between encoding profiles (hgih-profile and base-profile mostly). See below.

 

We also see another one issue with H264 encoder driver: there is no V4L2 control to choose the encoding profile. We need to set the base-profile for h264 (and in general we need to have ability to choose profile).

Right now, there is only available by default setting high-profile and V4L2 controls list is limited and doesn't have profile setup option:

 

v4l2-ctl --list-ctrls --device=/dev/video1
gop_size 0x009909cb (int) : min=1 max=7200 step=1 default=1800 value=1800
video_bitrate 0x009909cf (int) : min=50000 max=100000000 step=1 default=500000 value=0
h264_i_period 0x00990a66 (int) : min=1 max=600 step=1 default=30 value=0

  • Hi,

    The following 2 patches enables the user to provide user defined profile for the video encoding using Gstreamer.

    Board: J721e (TDA4VM)

    SDK Version: 8.4

     

    Patch-1: To be applied to Gstreamer plugin.

    Patch file Name: 0001-Added-H264-profiles-support-to-Gstreamer-Plugin-for-.patch

    In order to apply the patch, the user needs to have a Yocto setup and for setting up Yocto, please refer to SDK Documentation. Once the Yocto build is ready, the Gstreamer plugin is found at the location:

    <path-to-J721e-8.4-sdk>/yocto-build/build/arago-tmp-external-arm-glibc/work/j7_evm-linux/gstreamer1.0-plugins-good/1.16.3-r0.0.arago3_psdkla_0/gst-plugins-good-1.16.3

    The patch can be applied from this folder and changes are made to the files:

    ./sys/v4l2/gstv4l2h264enc.c and ./sys/v4l2/gstv4l2h264enc.h

     

    Patch-2: To be applied to Linux Kernel

    Patch file name: 0001-Added-H264-Profiles-support-to-IMG-Video-Encode-driv.patch

    Location of Linux Kernel:

    ./ti-processor-sdk-linux-j7-evm-08_04_00_11/board-support/linux-5.10.120+gitAUTOINC+95b90aa828-g95b90aa828

    Apply the patch from this folder and changes are made to the file:

    ./drivers/media/platform/vxe-vxd/encoder/vxe_v4l2.c

     

    Once both the patches are applied, the driver can be verified by the below command. Use profile=0 for Base, profile=2 for Main, profile=4 for High. For any other value, default Base profile is set.

    $ gst-launch-1.0 videotestsrc pattern=ball do-timestamp=true num-buffers=100  ! video/x-raw, format=NV12, width=852, height=480, framerate=30/1 ! v4l2h264enc profile=2 ! h264parse ! mp4mux ! filesink location=demo_main.mp4

     

    Profile of the file can be verified using ffmpeg and ffmpeg log is also attached for the video created using the above command.

    https://e2e.ti.com/cfs-file/__key/communityserver-discussions-components-files/1045/3223.0001_2D00_Added_2D00_H264_2D00_Profiles_2D00_support_2D00_to_2D00_IMG_2D00_Video_2D00_Encode_2D00_driv.patch 

    https://e2e.ti.com/cfs-file/__key/communityserver-discussions-components-files/1045/0218.0001_2D00_Added_2D00_H264_2D00_profiles_2D00_support_2D00_to_2D00_Gstreamer_2D00_Plugin_2D00_for_2D00_.patch

    5658.ffmpeg_profile_check.log

    Regards

    Nikshith

  • Hi Nikshith,

    For base-profile this doesn't work: stream is high profile still. Can you double-check?

  • The 2 patches shared, works after the base profile is forced. Base profile can be forced by changing

    ctx->vparams.h264_8x8 = FALSE;

    ctx->vparams.cabac_enabled = FALSE;
     

    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;
    

  • Here is the feeback received. 

    "This patch is not valid 0001-Added-H264-Profiles-support-to-IMG-Video-Encode-driv.patch
    
    It provides ioctl control to set encoder properties and forces profile but the profile is still overwritten after VIDIOC_S_FMT is called.
    
    Handler of set format ioctl in driver is vxe_s_fmt() and it calls find_profile() and overwrites profile setting.
    
    When we revert our original hack to force find_h264_profile() to return "base profile" (cabac_enabled = FALSE; h264_8x8 = TRUE) then the patch you shared simply doesn't work for base-profile cases."

    find_h264_profile() called by vxe_s_fmt just returns the profile, based on the variables in struct vxe_enc_ctx *ctx

    **When we revert our original hack to force find_h264_profile() to return "base profile" (cabac_enabled = FALSE; h264_8x8 = TRUE). **

    The hack that was shared makes "cabac_enabled = FALSE; h264_8x8 = FALSE".

    Regards

    Nikshith

  • Closing this as agreed on today's call.