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.

[FAQ] TDA2SX: How do I configure the H.264 Encoder Constant Bit Rate (CBR) and Variable Bit Rate (VBR) on IVAHD?

Part Number: TDA2SX

I have read from the user guide that the IVAHD encoder supports this feature, can you share the steps for the same.

  • This is applicable for the following platforms

    Platform: Jacinto-6/TDA2x/TDA3x/AM57xx/Sitara

    Codec: H.264 Encoder

    Latest Release Version: Can be found here  https://git.ti.com/cgit/ivimm/ipumm/tree/extrel/ti/ivahd_codecs/packages/ti/sdo/codecs/h264enc

     

    You can find all the codec parameter configuration and other details on User Guide (See links below).

    The encoder already supports CBR and VBR. This thread will explain more on how to configure the encoder with CBR and VBR. 

    A brief explanation is provided below.

     

    CBR, Constant BitRate: As the name says, each encoded frame will have almost similar number of bytes in it. There will be be minimum fluctuation in the bytes generated for each encoded frame. Initial few frames might vary and the rate control algorithm will stabilize to keep targetBitrate under control. It is important that the user configures the targetBitrate based on the requirement. 

    A particular use-case might have the these components in pipeline: Camera Capture -> Encode -> Post Process Unit -> Transmit

    Assume, transmission might need equal number of bytes to be sent via a network. If you have constant bits per frames (with minimum fluctuation), the post processing can be done on the encoded frame and get equal number of bytes per frames/packets.

     

    VBR, Variable BitRate: On the other hand, if the encoder is configured for VBR, frames with more complex scene will be encoded with more bytes and the one will less complexity will have lower number of bytes. targetBitrate will be achieved based on the user configuration. The Rate Control algorithm will decide this based on the scene complexity.

    Here we can assume an use case of video surveillance, when there is no motion on video(low complexity) frames can be encoded with lower bytes. When there is motion (complex data) frames can be encoded with more bytes to have more details.

    Along with the other parameter settings, user will have to set these additional parameters to configure the h.264 encoder as:

     1.       CBR – Constant BitRate:

    EncodingPreset              = 3 or XDM_USER_DEFINED
    RateControlPreset           = 5 or IVIDEO_USER_DEFINED
    rateControlParamsPreset     = 1 or IH264_RATECONTROLPARAMS_USERDEFINED
    rcAlgo                      = 1 (CBR) or IH264_RATECONTROL_PRC_LOW_DELAY
    initialBufferLevel          = (0.5 * targetBitRate)
    HRDBufferSize               = (0.5 * targetBitRate)

     

    User can check the bytes generated in each frame to know if CBR has taken effect by using some offline stream analyzer.

     2.       VBR – Variable BitRate:

    EncodingPreset                  = 3 or XDM_USER_DEFINED
    RateControlPreset               = 5 or IVIDEO_USER_DEFINED
    rateControlParamsPreset         = 1 or IH264_RATECONTROLPARAMS_USERDEFINED
    rcAlgo                          = 0 (VBR) or IH264_RATECONTROL_PRC
    initialBufferLevel              = (2 * targetBitRate)
    HRDBufferSize                   = (2 * targetBitRate)

    User should see larger frame size with the complex scene in the video and lower bytes when less complex scene are encoded. This should confirm VBR is working as expected.

    Note: The default behavior of the codec is VBR.

    Additional documentation can be found here for quick reference:

    Release Notes  : https://git.ti.com/cgit/ivimm/ipumm/tree/extrel/ti/ivahd_codecs/packages/ti/sdo/codecs/h264enc/docs/H264_Encoder_HDVICP2_ReleaseNotes.pdf

    Data Sheet       : https://git.ti.com/cgit/ivimm/ipumm/tree/extrel/ti/ivahd_codecs/packages/ti/sdo/codecs/h264enc/docs/H264_Encoder_HDVICP2_DataSheet.pdf

    User Guide       : https://git.ti.com/cgit/ivimm/ipumm/tree/extrel/ti/ivahd_codecs/packages/ti/sdo/codecs/h264enc/docs/H264_Encoder_HDVICP2_UserGuide.pdf