H264 Bit Rate / Quality Settings (DM6467)

hello,

I am using the Video Encoding h264enc 720p h264 base profile video encoder version 1.20.02 for the dm6467t.  I am having a problem with bit rate.  I need to keep the bit rate low but I can seem to do that without generating lots of zero frames.

For example, if I have a stream of 720x480 images at a frame rate of 8fps then I need to average about ~12000 bytes for each encoder frame.  However, if ask for a bit rate of something that should be able to handle this like 800000 bits, I often see that a single frame will take up almost the entire bit count and then the rest of the frames in that second will end up being zero frames or skipped.

I can't seem to understand how best to configure my codec to do what I want.  The I frames can take up more of the bit rate, but I can't have this many skipped frames.

I found this link for a different component:

http://processors.wiki.ti.com/index.php/DM36x_Rate_Control_Modes

Is there a similar link for dm6467?  How can I best control the bitrate for the encoder?  What are my options?

Thanks,

Brandy

 

33 Replies

  • Hi Brandy,

    I will come back on this probably on Monday.

    Regards,

    Mahantesh

  • In reply to Mahantesh S Madiwalar:

    ok thanks.  Is there any more information you need?

  • In reply to Mahantesh S Madiwalar:

    Hello again Mahantesh,

    Thanks for your support.  I would like to add another query, is it possible to add HRD sequence to this encoder?  If it cannot support this automatically, how could I do it from the application side?  Is there any information I could use about this SEI (Supplemental Enhancement Information) to manually create this data to send with the SPS/PPS headers?  I am see that the decoders are not able to properly decode becuase my frame rate is much smaller than 30 fps.

    Brandy

  • In reply to BrandyJ:

    Hi Brandy,

    1. To avoid many frame skips can you try with using VBR mode of RC and please check your QP values as well. No similar docs were available for DM6467 codecs.

    2. The encoder generates the bits stream which is conforming to NAL unit stream.

    But, your following query is not clear, can you please put in other words,

    is it possible to add HRD sequence to this encoder?

    Regards,

    Mahantesh

  • In reply to Mahantesh S Madiwalar:

    Hi Mahantesh,

    Thanks for not forgetting about me :)

    First let me comment on your comments, then I will share with you my progress.

    1.  I cannot use VBR becuase then there is not enough compression of image.  What I mean is, the output buffer size is too large and I can not effectively stream the video image.

    2.  I have used a buffer analyzer and can see that the NAL units are correct but they are limited.  There is a SPS/PPS only with IDR frames and slice header with every frame.

    What I need are timing NAL units.  There is someting called the VUI parameters inside the SPS.  If you enable this flag, then a lot of timing options are available, including the NAL_HRD paramters and the VLC_HRD parameters.  Once these are enabled in the SPS then you can use the SEI message pic_timing and buffer_period.

    Since we last chatted, I was able to correctly format my own version of the SPS, PPS and various SEI messages manually.  I am no longer using the headers that are generated by the encoder.  I merely overwrite them with my SPS/PPS and the additional data.

    However, now I am struggle to determine what values to place in these message pic_timing and buffer_period.  I have looked at the H264 specification but it is difficult to decode.  Do you have any expertise in this subject now that I have explained it more?  What should the values be in the cpb_removal_delay and the dpb_output_delay?  Perhaps a collegue from the DM365 codec team could help since they seem to have done this already inside their codec?

    Here what my headers look like right now.  Sorry about the formatting.

    Thanks for your help,

    Brandy

    _________________________________________________________________________________________________________

       [00]seq_parameter_set_rbsp() {
        profile_idc                                    = 66 (Baseline)
        constraint_set0_flag                           = 1 (true)
        constraint_set1_flag                           = 0 (false)
        constraint_set2_flag                           = 0 (false)
        constraint_set3_flag                           = 0 (false)
        reserved_zero_4bits                            = 0 (false)
        level_idc                                      = 40
        seq_parameter_set_id                           = 0
        if (profile_idc == 100 || profile_idc == 110 || profile_idc == 122 || profile_idc == 144) {
        log2_max_frame_num_minus4                      = 0 (4)
        pic_order_cnt_type                             = 0
        if (pic_order_cnt_type == 0)
        else if (pic_order_cnt_type == 1) {
        num_ref_frames                                 = 1
        gaps_in_frame_num_value_allowed_flag           = 0
        pic_width_in_mbs_minus1                        = 44 (720)
        pic_height_in_map_units_minus1                 = 29 (480)
        frame_mbs_only_flag                            = 1
        if (!frame_mbs_only_flag)
        direct_8x8_inference_flag                      = 0 (false)
        frame_cropping_flag                            = 0 (false)
        if (frame_cropping_flag) {
        vui_parameters_present_flag                    = 1 (true)
        if (vui_parameters_present_flag)
          vui_parameters() {
            aspect_ratio_info_present_flag             = 0 (false)
            if (aspect_ratio_info_present_flag) {
            overscan_info_present_flag                 = 0 (false)
            if (overscan_info_present_flag)
            video_signal_type_present_flag             = 1 (true)
            if (video_signal_type_present_flag) {
            chroma_location_info_present_flag          = 0 (false)
            if (chroma_loc_info_present_flag) {
            timing_info_present_flag                   = 0 (false)
            if (timing_info_present_flag) {
            nal_hrd_parameters_present_flag            = 1 (true)
            if (nal_hrd_parameters_present_flag)
              nal_hrd_parameters() {
                cpb_cnt_minus1                         = 0 (1)
                bit_rate_scale                         = 1
                cpb_size_scale                         = 3
                for (SchedSelIdx = 0; SchedSelIdx <= cpb_cnt_minus1; SchedSelIdx++) {
                initial_cpb_removal_delay_length_minus1 = 23
                cpb_removal_delay_length_minus1        = 22
                dpb_output_delay_length_minus1         = 22
                time_offset_length                     = 0
                }
              }
            vcl_hrd_parameters_present_flag            = 1 (true)
            if (vcl_hrd_parameters_present_flag)
            if (nal_hrd_parameters_present_flag || vcl_hrd_parameters_present_flag)
            pic_struct_present_flag                    = 0 (false)
            bitstream_restriction_flag                 = 0 (false)
            if (bitstream_restriction_flag) {
            }
          }
        }
      [00]pic_parameter_set_rbsp() {
      [00]slice_header() {
      [00]sei() {                                      = 35
      [01]sei() {                                      = 20
        buffering_period() {
          seq_parameter_set_id                         = 0
          if (NalHrdBpPresentFlag) {
            for (SchedSelIdx = 0; SchedSelIdx <= cpb_cnt_minus1; SchedSelIdx++) {
              initial_cpb_removal_delay[00]            = 9000
              initial_cpb_removal_delay_offset[00]     = 0
              }
            }
          if (VclHrdBpPresentFlag) {
          }
        }
      [02]sei() {                                      = 14
        pic_timing() {
          if (CpbDpbDelaysPresentFlag) {
            cpb_removal_delay                          = 0
            dpb_output_delay                           = 0
            }
          if (pic_struct_present_flag) {
          }
        }

     

  • In reply to BrandyJ:

    Hi Brandy,

    Can you please, specify your use cases or config parameters used, so that it will be easy to recomend for VUI and SEI messages.

    Regards,

    Mahantesh

     

  • In reply to Mahantesh S Madiwalar:

    Sure.  My video stream is expected to be at 8fps.  The quality values are set to default and I am using CBR set to 800,000.  I need to keep the compressed frame size to around 12000 bits for a 720x480 frame.

    I am currently starting to think about extending the encParams struct to expose the quality parameters to see if I can figure out how to decrease the quality a bit and so that the encoder will produce fewer zero byte frames.

  • In reply to BrandyJ:

    Hello,

    I'm using dm6467 to encode video in h264.

    I have also a similar problem.

    My contraints are:

     

    video CBR, 128000 bps ( very low), with an IDR frame every second ( framerate 30fps ).

    How can I configure the encoder to avoid frame skip?

     

    With dm365 I had not problems, but dm6467 seems to have a poor bitrate control, right?

     

    Thanks

    Claudio

     

  • In reply to Claudio Filipponi:

    Hi Claudio,

    I have had a thought to try to extend the parameters as described with the IH264VENC_DynamicParameters.  I have not yet had a chance.  I hoping with these extended parameters that we could control the quality a bit better and be able to tell the codec to produce less quality in order to share the bits better across the stream.

    If I find that some parameter set is working, I will post it for you.  Perhaps you could also hint if you get to it before me.

    Also, I find that TI tends to ignore older posts - you might be better off starting a new post and I will suscribe to your post to see if they respond with some ideas for you.

    Good luck!

    Brandy

  • In reply to BrandyJ:

    Hi!

    Working on the extended parameters seems to produce some result.

    QPISlice, QPSlice, RateCtrlQpMax and  RateCtrlQpMin are the involved parameters.

    So, depending on the bitrate required ( in CBR mode),  I set different value of these QP params.

     

     

    Good luck!
    Claudio