Ticket #9410: H264Parser-nal-ref-idc.patch

File H264Parser-nal-ref-idc.patch, 4.3 KB (added by jpoet, 9 years ago)

Only test nal_ref_idc for a new AU, if the NAL UNIT is a "slice"

  • mythtv/libs/libmythtv/mpeg/H264Parser.cpp

    diff --git a/mythtv/libs/libmythtv/mpeg/H264Parser.cpp b/mythtv/libs/libmythtv/mpeg/H264Parser.cpp
    index ac805e7..d933858 100644
    a b bool H264Parser::new_AU(void) 
    183183      one or more of the following ways.
    184184
    185185      - frame_num differs in value. The value of frame_num used to
    186       test this condition is the value of frame_num that appears in
    187       the syntax of the slice header, regardless of whether that value
    188       is inferred to have been equal to 0 for subsequent use in the
    189       decoding process due to the presence of
    190       memory_management_control_operation equal to 5.
     186        test this condition is the value of frame_num that appears in
     187        the syntax of the slice header, regardless of whether that value
     188        is inferred to have been equal to 0 for subsequent use in the
     189        decoding process due to the presence of
     190        memory_management_control_operation equal to 5.
    191191          Note: If the current picture is an IDR picture FrameNum and
    192192          PrevRefFrameNum are set equal to 0.
    193193      - pic_parameter_set_id differs in value.
    194194      - field_pic_flag differs in value.
    195195      - bottom_field_flag is present in both and differs in value.
    196       - nal_ref_idc differs in value with one of the nal_ref_idc values
    197       being equal to 0.
     196      - nal_ref_idc differs in value with one of the nal_ref_idc
     197        values being equal to 0.
    198198      - pic_order_cnt_type is equal to 0 for both and either
    199       pic_order_cnt_lsb differs in value, or delta_pic_order_cnt_bottom
    200       differs in value.
     199        pic_order_cnt_lsb differs in value, or delta_pic_order_cnt_bottom
     200        differs in value.
    201201      - pic_order_cnt_type is equal to 1 for both and either
    202       delta_pic_order_cnt[0] differs in value, or
    203       delta_pic_order_cnt[1] differs in value.
     202        delta_pic_order_cnt[0] differs in value, or
     203        delta_pic_order_cnt[1] differs in value.
    204204      - nal_unit_type differs in value with one of the nal_unit_type values
    205       being equal to 5.
     205        being equal to 5.
    206206      - nal_unit_type is equal to 5 for both and idr_pic_id differs in
    207       value.
     207        value.
    208208
    209209      NOTE – Some of the VCL NAL units in redundant coded pictures or some
    210210      non-VCL NAL units (e.g. an access unit delimiter NAL unit) may also
    bool H264Parser::new_AU(void) 
    230230        else if ((bottom_field_flag != -1 && prev_bottom_field_flag != -1) &&
    231231                 bottom_field_flag != prev_bottom_field_flag)
    232232            result = true;
     233        else if ((nal_ref_idc == 0 || prev_nal_ref_idc == 0) &&
     234                 nal_ref_idc != prev_nal_ref_idc)
     235            result = true;
    233236        else if ((pic_order_cnt_type == 0 && prev_pic_order_cnt_type == 0) &&
    234237                 (pic_order_cnt_lsb != prev_pic_order_cnt_lsb ||
    235238                  delta_pic_order_cnt_bottom !=
    bool H264Parser::new_AU(void) 
    253256    prev_pic_parameter_set_id = pic_parameter_set_id;
    254257    prev_field_pic_flag = field_pic_flag;
    255258    prev_bottom_field_flag = bottom_field_flag;
     259    prev_nal_ref_idc = nal_ref_idc;
    256260    prev_pic_order_cnt_lsb = pic_order_cnt_lsb;
    257261    prev_delta_pic_order_cnt_bottom = delta_pic_order_cnt_bottom;
    258262    prev_delta_pic_order_cnt[0] = delta_pic_order_cnt[0];
    uint32_t H264Parser::addBytes(const uint8_t *bytes, 
    348352                    AU_pending = true;
    349353                    AU_offset = stream_offset;
    350354                }
    351                 else if ((nal_ref_idc == 0 || prev_nal_ref_idc == 0) &&
    352                          nal_ref_idc != prev_nal_ref_idc)
    353                 {
    354                     AU_pending = true;
    355                     AU_offset = stream_offset;
    356                 }
    357355            }
    358356
    359357            if (AU_pending && NALisSlice(nal_unit_type))
    uint32_t H264Parser::addBytes(const uint8_t *bytes, 
    378376            else
    379377                on_frame = on_key_frame = false;
    380378
    381             prev_nal_ref_idc = nal_ref_idc;
    382 
    383379            return byteP - bytes;
    384380        }
    385381    }
    void H264Parser::vui_parameters(GetBitContext * gb) 
    10151011
    10161012uint H264Parser::frameRate(void) const
    10171013{
    1018     uint64_t    num;
     1014    uint64_t    num;
    10191015    uint64_t    fps;
    10201016
    10211017    num   = 500 * (uint64_t)timeScale; /* 1000 * 0.5 */