SPS - uupaa/H264.js GitHub Wiki

TODO: add description

SPS

SPS (Sequence Parameter Set) は。。。。 TODO:

seq_parameter_set_data() {
    profile_idc                                     u(8)
    constraint_set0_flag                            u(1)
    constraint_set1_flag                            u(1)
    constraint_set2_flag                            u(1)
    constraint_set3_flag                            u(1)
    constraint_set4_flag                            u(1)
    constraint_set5_flag                            u(1)
    reserved_zero_2bits                             u(2) `00`
    level_idc                                       u(8)
    seq_parameter_set_id                            ue(v)
    if( profile_idc == 100 || profile_idc == 110 ||
        profile_idc == 122 || profile_idc == 244 ||
        profile_idc == 44  || profile_idc == 83  ||
        profile_idc == 86  || profile_idc == 118 ||
        profile_idc == 128 ) {
        chroma_format_idc                           ue(v)
        if( chroma_format_idc == 3 )
            separate_colour_plane_flag              u(1)
            bit_depth_luma_minus8                   ue(v)
            bit_depth_chroma_minus8                 ue(v)
            qpprime_y_zero_transform_bypass_flag    u(1)
            seq_scaling_matrix_present_flag         u(1)
            if( seq_scaling_matrix_present_flag ) {
                for(i=0;i<((chroma_format_idc != 3)?8:12);i++){
                    seq_scaling_list_present_flag[ i ]      u(1)
                    if( seq_scaling_list_present_flag[ i ] ) {
                        if( i < 6 ) {
                            scaling_list( ScalingList4x4[ i ], 16, UseDefaultScalingMatrix4x4Flag[ i ])
                        } else {
                            scaling_list( ScalingList8x8[ i − 6 ], 64, UseDefaultScalingMatrix8x8Flag[ i − 6 ] )
                        }
                    }
                }
            }
        }
    }
    log2_max_frame_num_minus4                       ue(v)
    pic_order_cnt_type                              ue(v)
    if( pic_order_cnt_type == 0 ) {
        log2_max_pic_order_cnt_lsb_minus4           ue(v)
    } else if( pic_order_cnt_type == 1 ) {
        delta_pic_order_always_zero_flag            u(1)
        offset_for_non_ref_pic                      se(v)
        offset_for_top_to_bottom_field              se(v)
        num_ref_frames_in_pic_order_cnt_cycle       ue(v)
        for( i = 0; i < num_ref_frames_in_pic_order_cnt_cycle; i++ ) {
            offset_for_ref_frame[ i ]
        }
        se(v)
    }
    max_num_ref_frames                              ue(v)
    gaps_in_frame_num_value_allowed_flag            u(1)
    pic_width_in_mbs_minus1                         ue(v)
    pic_height_in_map_units_minus1                  ue(v)
    frame_mbs_only_flag                             u(1)
    if( !frame_mbs_only_flag ) {
        mb_adaptive_frame_field_flag                u(1)
    }
    direct_8x8_inference_flag                       u(1)
    frame_cropping_flag                             u(1)
    if( frame_cropping_flag ) {
        frame_crop_left_offset                      ue(v)
        frame_crop_right_offset                     ue(v)
        frame_crop_top_offset                       ue(v)
        frame_crop_bottom_offset                    ue(v)
    }
    vui_parameters_present_flag                     u(1)
    if( vui_parameters_present_flag ) {
        vui_parameters( )
    }
vui_parameters() {
    aspect_ratio_info_present_flag                      u(1)
    if ( aspect_ratio_info_present_flag ) {
        aspect_ratio_idc                                u(8)
        if ( aspect_ratio_idc == Extended_SAR ) {
            sar_width                                   u(16)
            sar_height                                  u(16)
        }
    }
    overscan_info_present_flag                          u(1)
    if (overscan_info_present_flag) {
        overscan_appropriate_flag                       u(1)
    }
    video_signal_type_present_flag                      u(1)
    if (video_signal_type_present_flag) {
        video_format                                    u(3)
        video_full_range_flag                           u(1)
        colour_description_present_flag                 u(1)

        if (colour_description_present_flag) {
            colour_primaries                            u(8)
            transfer_characteristics                    u(8)
            matrix_coefficients                         u(8)
        }
    }
    chroma_loc_info_present_flag                        u(1)
    if (chroma_loc_info_present_flag) {
        chroma_sample_loc_type_top_field                ue(v)
        chroma_sample_loc_type_bottom_field             ue(v)
    }
    timing_info_present_flag                            u(1)
    if (timing_info_present_flag) {
        num_units_in_tick                               u(32)
        time_scale                                      u(32)
        fixed_frame_rate_flag                           u(1)
    }
    nal_hrd_parameters_present_flag                     u(1)
    if (nal_hrd_parameters_present_flag) {
        hrd_parameters()
    }
    vcl_hrd_parameters_present_flag                     u(1)
    if (vcl_hrd_parameters_present_flag ) {
        hrd_parameters()
    }
    if (nal_hrd_parameters_present_flag ||
        vcl_hrd_parameters_present_flag) {
        low_delay_hrd_flag                              u(1)
    }
    pic_struct_present_flag                             u(1)
    bitstream_restriction_flag                          u(1)
    if (bitstream_restriction_flag) {
        motion_vectors_over_pic_boundaries_flag         u(1)
        max_bytes_per_pic_denom                         ue(v)
        max_bits_per_mb_denom                           ue(v)
        log2_max_mv_length_horizontal                   ue(v)
        log2_max_mv_length_vertical                     ue(v)
        max_num_reorder_frames                          ue(v)
        max_dec_frame_buffering                         ue(v)
    }
}