Beispiel #1
0
def seq_parameter_set_data(d: Table, bs: BitStream):
    d.add_field('profile_idc', bs.read_bits, count=8)
    d.add_field('constraint_set0_flag', bs.read_bits, count=1)
    d.add_field('constraint_set1_flag', bs.read_bits, count=1)
    d.add_field('constraint_set2_flag', bs.read_bits, count=1)
    d.add_field('constraint_set3_flag', bs.read_bits, count=1)
    d.add_field('constraint_set4_flag', bs.read_bits, count=1)
    d.add_field('constraint_set5_flag', bs.read_bits, count=1)
    bs.to_byte_end()  # reserved_zero_2bits
    d.add_field('level_idc', bs.read_bits, count=8)
    d.add_field('seq_parameter_set_id', bs.read_ue_golomb)
    if d.profile_idc in [
            100, 110, 122, 244, 44, 83, 86, 118, 128, 138, 139, 134, 135
    ]:
        d.add_field('chroma_format_idc', bs.read_ue_golomb)
        if d.chroma_format_idc == 3:
            d.add_field('separate_colour_plane_flag', bs.read_bits, count=1)
        d.add_field('bit_depth_luma_minus8', bs.read_ue_golomb)
        d.add_field('bit_depth_chroma_minus', bs.read_ue_golomb)
        d.add_field('qpprime_y_zero_transform_bypass_flag',
                    bs.read_bits,
                    count=1)
        d.add_field('seq_scaling_matrix_present_flag', bs.read_bits, count=1)
        if d.seq_scaling_matrix_present_flag:  # todo test this branch
            d.add_fields(__fields_in_scaling_list,
                         'seq_scaling_list_present_flag', 'ScalingList4x4',
                         'UseDefaultScalingMatrix4x4Flag', 'ScalingList8x8',
                         'UseDefaultScalingMatrix8x8Flag')
    d.add_field('log2_max_frame_num_minus4', bs.read_ue_golomb)
    d.add_field('pic_order_cnt_type', bs.read_ue_golomb)
    if d.pic_order_cnt_type == 0:
        d.add_field('log2_max_pic_order_cnt_lsb_minus4', bs.read_ue_golomb)
    elif d.pic_order_cnt_type == 1:
        d.add_field('delta_pic_order_always_zero_flag', bs.read_bits, count=1)
        d.add_field('offset_for_non_ref_pic', bs.read_se_golomb)
        d.add_field('offset_for_top_to_bottom_field', bs.read_se_golomb)
        d.add_field('num_ref_frames_in_pic_order_cnt_cycle', bs.read_ue_golomb)
        d.add_field('offset_for_ref_fram',
                    bs.read_se_golombs,
                    count=d.num_ref_frames_in_pic_order_cnt_cycle)
    d.add_field('max_num_ref_frames', bs.read_ue_golomb)
    d.add_field('gaps_in_frame_num_value_allowed_flag', bs.read_bits, count=1)
    d.add_field('pic_width_in_mbs_minus1', bs.read_ue_golomb)
    d.add_field('pic_height_in_map_units_minus1', bs.read_ue_golomb)
    d.add_field('frame_mbs_only_flag', bs.read_bits, count=1)
    if d.frame_mbs_only_flag == 0:
        d.add_field('mb_adaptive_frame_field_flag', bs.read_bits, count=1)
    d.add_field('direct_8x8_inference_flag', bs.read_bits, count=1)
    d.add_field('frame_cropping_flag', bs.read_bits, count=1)
    if d.frame_cropping_flag == 1:
        d.add_field('frame_crop_left_offset', bs.read_ue_golomb)
        d.add_field('frame_crop_right_offset', bs.read_ue_golomb)
        d.add_field('frame_crop_top_offset', bs.read_ue_golomb)
        d.add_field('frame_crop_bottom_offset', bs.read_ue_golomb)
    d.add_field('vui_parameters_present_flag', bs.read_bits, count=1)
    if d.vui_parameters_present_flag:
        d.add_table(vui_parameters)
Beispiel #2
0
def rbsp_trailing_bits(d: Table, bs: BitStream):
    d.add_field('rbsp_stop_one_bit', bs.read_bits, count=1)
    bs.to_byte_end()