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.

dm365 - h.264 encoder - SPS constraints

Hello,

I've configured the h264 codec for dm365 to baseline profile, level 1.3, obtaining as SPS .. 

profile_idc = 66 (PROFILE_IDC_Baseline)
constraint_set0_flag = 1
constraint_set1_flag = 0
constraint_set2_flag = 0
constraint_set3_flag = 0

Is there a way to have different values of constraint flags? I'd like to obtain ..

profile_idc = 66 (PROFILE_IDC_Baseline)
constraint_set0_flag = 1
constraint_set1_flag = 1
constraint_set2_flag = 1
constraint_set3_flag = 0

Due to ATSC-MH standard: constraint_set0_flag, constraint_set1_flag and constraint_set2_flag shall all be set to 1. constraint_set3_flag shall be set to 0.

Thanks,

Claudio

  • Hi Claudio,

    Unfortunately, current H.264 encoder interface does not support modification of constraint_setx_flag. Hence you cannot get custom value using the encoder. But since the fields before "constraint_setx_flag" are fixed length coded, you can easily write few lines of code(as a workaround) in your application to modify this.

    Step 1: For all the IDR frames, Look for 1st Start code. This will point to SPS

    Step 2: Parse the NAL header (8 bits) to confirm it is SPS NALU

    Step 3: Skip next 8 bits corresponding to profile idc

    Step4; Modify the next 4 bits which corresponds to "constraint_setx_flag"

     

    regards

    Yashwant

  • Hi Yashwant,
    thanks for your reply.

    just a clarification:
    Since the encoder sets these flags to flag0=1, flag1=0, flag2=0, flag3=0, means that certain conditions are "met" or "not met" in the encoded data (NALU) coming from the dm365 chip.
    Simply forcing these bits at the output of the encoder I'm not sure again that constraints of the encoded data are met. Am I missing something?

    Thanks,

    Claudio

     

     

  • Hi Claudio,

    In the encoder, we set flag0 to 1 when profile idc is BP. Also, we set flag 3 when we have to indicate level 1b. Other wise, these flags are always 0.

    Since we give most of the tools control using API parameter(entropy, SM, 8x8 etc ), we feel safer to have it set to 0(may or may not conform to the restriction in Annex A.x.x). Hence, you can set it to your desired value and choose the correct tool set to have a compliant bitstream.

    regards

    Yashwant

  • Hi Yashwant,

    thank you for your support.

    Now I enabled the VUI and SEI generation (EnableVUIParam = 1, EnableBufSEI = 1 and EnablePicTimSEI = 1) and I'm analyzing the SEI and VUI created by the encoder.

    VUI:

    video_format = 2
    low_delay_hrd_flag = 1
    colour description present flag = 0;

    I'd like to obtain (due to ATSC-MH standard):

    video_format = 0
    low_delay_hrd_flag = 0
    colour description present flag = 1, since color_primaries, transfer_characteristics and matrix_coefficients shall be explicitly indicated.

    Do you have any suggestion?

     

    SEI:
    The encoder seems to support only generation of Buffering Period (PayloadType = 0) and Picture Timing (PayloadType = 1) SEI message.

    ATSC_MH requires that Closed Captioning,  Active Format Description and Bar Data shall be carried in the SEI_RBSP and VUI section. These informations are carried in a SEI message of  User_data_registered_itu_t_t35 (PayloadType = 4).

    Can the encoder send this type of information, too?

     

    Thanks a lot,

    Claudio

  • Hi Claudio,

    Unfortunately, the above custom VUI and SEI is NOT supported by the encoder. You would have to add them manually in the bitstream. Since changing VUI and SEI for some custom field would mean re-encoding, I would suggest the below method - This will ensure that the actual encoded VCL NALU does not get disturbed.

    1. Search SPS and SEI NALU

    2. Decode it to get the parameters encoded in those NALU

    3. Re-encode the NALU with proper modification and/or addition of parameters as per your need.

    This would mean implementing a small header decoding and encoding functionlity in your application.

    regards

    Yashwant 

  • Hi Yashwant,
    So, re-encoding the SPS and SEI NALU with the proper modification (forcing/adding some custom value) doesn't affect the VCL NALU?
    SPS and SEI NALU are not reflecting some choice taken on the encoder side? 

    Thanks,
    Claudio

  • The parameters which you mentioned in your above post will not effect VCL NALU. But there might be others parameters of SPS which if you change can effect the VCL NALU, viz  log2_max_frame_num_minus4,  pic_order_cnt_type etc.

    regards...Yashwant

  • Hello Yashwant,

    thank you.

    Regarding ASO/FMO, It seems (from the codec documentation) that it is supported in standard quality mode.

    Working in high-quality mode, can I be sure that the ASO/FMO is not used?

    Thanks for you support.

    Claudio 

  • ER tools like ASO/FMO/RS is not supported in any mode of encoding. Which documentation gave you hint that it is supported in STD mode ?

    regards

    Yashwant

  • H.264 High Profile Encoder on DM365 - User’s Guide. (Literature Number: SPRUEU9 June 2009) .

    page 1-8 says:

      Baseline Profile:
     - Only I and P type slices are present
     -  Only frame mode (progressive) picture types are present
     -  Only CAVLC is supported
    -   ASO/FMO and redundant slices for error concealment is supported

    then, page 1-11 says:

    Supported features in standard quality mode:
    -  Supports TI’s proprietary motion estimation supported (Low power ME)
    -  Supports all 16x16, 8x8 and 4x4 intra-prediction modes supported in I-
    -  Frame and INTRA16x16 DC is supported in P-frames
    -  Supports only single slice per frame
    -  Supports only single motion vector per macroblock
    -  This version of the encoder does not support the following features as
        per the Baseline Profile feature set:
    Error Resilience features such as ASO/FMO and redundant slices
    -  Adaptive Reference Picture Marking
    -  Reference Picture List Reordering

    I have not clear when ASO/FMO is used.

     

    Regards,
    Claudio

     

     

     

  • Page 1-8 - > This is general statement about the profile as per H.264 specification. Does not talk aspecific about the encoder implementation.

    Page 1-11 -> As you see, ASO/FMO and RS is mentioned in list of NOT supported features.

    regards

    Yashwant

  • Thanks Yashwant.

    I have few open points at the moment.

    1) From the H264 standard, The value of log2_max_mv_length_horizontal shall be in the range of 0 to 16, inclusive. The value of log2_max_mv_length_vertical shall be in the range of 0 to 16, inclusive.

    The dm365 encoder set these values to 16.

    Is it possible to reduce the range (0 - 9 instead of 0-16) ?

     

    I suppose It is not possible to force them, since can effect the VCL NALU ...

     2)  time_offset_length of HRD parameters is set to 24 from the encoder. Is it possible to change/force it to 0 ?

    Thanks again

    Claudio

     

  • Hi Claudio,

    Regarding your first question.

    log2_max_mv_length_horizontal and log2_max_mv_length_vertical indicate  maximum absolute value of a decoded horizontal and vertical motion vector component in quarter-pel resolution.

    So we set it as 16 so that max MV in quarter pel will be in range -65536 to +65535. However if you set it as 9, then the MV range reduces to -512 to +511.

    Due to presence of GMV in our ME algorithm there are chances of vertical MV exceeding this reduced limit.

    But you may go forward in limiting log2_max_mv_length_horizontal and log2_max_mv_length_vertical values under following two conditions:

    1. If your LevelIdc set is equal to or lesser than 2.

    2. If you are assured that MVs are not exceeding -512 to +511 in quater-pel.

    And regarding your second question,

    You can go ahead with forcing time_offset_length to zero without affecting VCL NALU.

    rgds, mahant