void H264VideoStreamParser::analyze_hrd_parameters(BitVector& bv) { DEBUG_STR("BEGIN hrd_parameters"); unsigned cpb_cnt_minus1 = bv.get_expGolomb(); DEBUG_PRINT(cpb_cnt_minus1); unsigned bit_rate_scale = bv.getBits(4); DEBUG_PRINT(bit_rate_scale); unsigned cpb_size_scale = bv.getBits(4); DEBUG_PRINT(cpb_size_scale); for (unsigned SchedSelIdx = 0; SchedSelIdx <= cpb_cnt_minus1; ++SchedSelIdx) { DEBUG_TAB; unsigned bit_rate_value_minus1 = bv.get_expGolomb(); DEBUG_PRINT(bit_rate_value_minus1); unsigned cpb_size_value_minus1 = bv.get_expGolomb(); DEBUG_PRINT(cpb_size_value_minus1); unsigned cbr_flag = bv.get1Bit(); DEBUG_PRINT(cbr_flag); } unsigned initial_cpb_removal_delay_length_minus1 = bv.getBits(5); DEBUG_PRINT(initial_cpb_removal_delay_length_minus1); unsigned cpb_removal_delay_length_minus1 = bv.getBits(5); DEBUG_PRINT(cpb_removal_delay_length_minus1); unsigned dpb_output_delay_length_minus1 = bv.getBits(5); DEBUG_PRINT(dpb_output_delay_length_minus1); unsigned time_offset_length = bv.getBits(5); DEBUG_PRINT(time_offset_length); DEBUG_STR("END hrd_parameters"); }
void H264VideoStreamParser ::analyze_vui_parameters(BitVector& bv, unsigned& num_units_in_tick, unsigned& time_scale, unsigned& fixed_frame_rate_flag) { DEBUG_STR("BEGIN vui_parameters"); unsigned aspect_ratio_info_present_flag = bv.get1Bit(); DEBUG_PRINT(aspect_ratio_info_present_flag); if (aspect_ratio_info_present_flag) { DEBUG_TAB; unsigned aspect_ratio_idc = bv.getBits(8); DEBUG_PRINT(aspect_ratio_idc); if (aspect_ratio_idc == 255/*Extended_SAR*/) { bv.skipBits(32); // sar_width; sar_height } } unsigned overscan_info_present_flag = bv.get1Bit(); DEBUG_PRINT(overscan_info_present_flag); if (overscan_info_present_flag) { bv.skipBits(1); // overscan_appropriate_flag } unsigned video_signal_type_present_flag = bv.get1Bit(); DEBUG_PRINT(video_signal_type_present_flag); if (video_signal_type_present_flag) { DEBUG_TAB; bv.skipBits(4); // video_format; video_full_range_flag unsigned colour_description_present_flag = bv.get1Bit(); DEBUG_PRINT(colour_description_present_flag); if (colour_description_present_flag) { bv.skipBits(24); // colour_primaries; transfer_characteristics; matrix_coefficients } } unsigned chroma_loc_info_present_flag = bv.get1Bit(); DEBUG_PRINT(chroma_loc_info_present_flag); if (chroma_loc_info_present_flag) { (void)bv.get_expGolomb(); // chroma_sample_loc_type_top_field (void)bv.get_expGolomb(); // chroma_sample_loc_type_bottom_field } unsigned timing_info_present_flag = bv.get1Bit(); DEBUG_PRINT(timing_info_present_flag); if (timing_info_present_flag) { DEBUG_TAB; num_units_in_tick = bv.getBits(32); DEBUG_PRINT(num_units_in_tick); time_scale = bv.getBits(32); DEBUG_PRINT(time_scale); fixed_frame_rate_flag = bv.get1Bit(); DEBUG_PRINT(fixed_frame_rate_flag); } #ifdef DO_FULL_SPS_PARSING unsigned nal_hrd_parameters_present_flag = bv.get1Bit(); DEBUG_PRINT(nal_hrd_parameters_present_flag); if (nal_hrd_parameters_present_flag) { DEBUG_TAB; analyze_hrd_parameters(bv); } unsigned vcl_hrd_parameters_present_flag = bv.get1Bit(); DEBUG_PRINT(vcl_hrd_parameters_present_flag); if (vcl_hrd_parameters_present_flag) { DEBUG_TAB; analyze_hrd_parameters(bv); } if (nal_hrd_parameters_present_flag || vcl_hrd_parameters_present_flag) { bv.skipBits(1); // low_delay_hrd_flag } bv.skipBits(1); // pic_struct_present_flag unsigned bitstream_restriction_flag = bv.get1Bit(); DEBUG_PRINT(bitstream_restriction_flag); if (bitstream_restriction_flag) { bv.skipBits(1); // motion_vectors_over_pic_boundaries_flag (void)bv.get_expGolomb(); // max_bytes_per_pic_denom (void)bv.get_expGolomb(); // max_bits_per_mb_denom (void)bv.get_expGolomb(); // log2_max_mv_length_horizontal (void)bv.get_expGolomb(); // log2_max_mv_length_vertical (void)bv.get_expGolomb(); // num_reorder_frames (void)bv.get_expGolomb(); // max_dec_frame_buffering } DEBUG_STR("END vui_parameters"); #endif }
void H264or5VideoStreamParser ::analyze_vui_parameters(BitVector& bv, unsigned& num_units_in_tick, unsigned& time_scale) { Boolean aspect_ratio_info_present_flag = bv.get1BitBoolean(); DEBUG_PRINT(aspect_ratio_info_present_flag); if (aspect_ratio_info_present_flag) { DEBUG_TAB; unsigned aspect_ratio_idc = bv.getBits(8); DEBUG_PRINT(aspect_ratio_idc); if (aspect_ratio_idc == 255/*Extended_SAR*/) { bv.skipBits(32); // sar_width; sar_height } } Boolean overscan_info_present_flag = bv.get1BitBoolean(); DEBUG_PRINT(overscan_info_present_flag); if (overscan_info_present_flag) { bv.skipBits(1); // overscan_appropriate_flag } Boolean video_signal_type_present_flag = bv.get1BitBoolean(); DEBUG_PRINT(video_signal_type_present_flag); if (video_signal_type_present_flag) { DEBUG_TAB; bv.skipBits(4); // video_format; video_full_range_flag Boolean colour_description_present_flag = bv.get1BitBoolean(); DEBUG_PRINT(colour_description_present_flag); if (colour_description_present_flag) { bv.skipBits(24); // colour_primaries; transfer_characteristics; matrix_coefficients } } Boolean chroma_loc_info_present_flag = bv.get1BitBoolean(); DEBUG_PRINT(chroma_loc_info_present_flag); if (chroma_loc_info_present_flag) { (void)bv.get_expGolomb(); // chroma_sample_loc_type_top_field (void)bv.get_expGolomb(); // chroma_sample_loc_type_bottom_field } if (fHNumber == 265) { bv.skipBits(3); // neutral_chroma_indication_flag, field_seq_flag, frame_field_info_present_flag Boolean default_display_window_flag = bv.get1BitBoolean(); DEBUG_PRINT(default_display_window_flag); if (default_display_window_flag) { (void)bv.get_expGolomb(); // def_disp_win_left_offset (void)bv.get_expGolomb(); // def_disp_win_right_offset (void)bv.get_expGolomb(); // def_disp_win_top_offset (void)bv.get_expGolomb(); // def_disp_win_bottom_offset } } Boolean timing_info_present_flag = bv.get1BitBoolean(); DEBUG_PRINT(timing_info_present_flag); if (timing_info_present_flag) { DEBUG_TAB; num_units_in_tick = bv.getBits(32); DEBUG_PRINT(num_units_in_tick); time_scale = bv.getBits(32); DEBUG_PRINT(time_scale); if (fHNumber == 264) { Boolean fixed_frame_rate_flag = bv.get1BitBoolean(); DEBUG_PRINT(fixed_frame_rate_flag); } else { // 265 Boolean vui_poc_proportional_to_timing_flag = bv.get1BitBoolean(); DEBUG_PRINT(vui_poc_proportional_to_timing_flag); if (vui_poc_proportional_to_timing_flag) { unsigned vui_num_ticks_poc_diff_one_minus1 = bv.get_expGolomb(); DEBUG_PRINT(vui_num_ticks_poc_diff_one_minus1); } } } }
void H264or5VideoStreamParser ::analyze_vui_parameters(BitVector& bv, unsigned& num_units_in_tick, unsigned& time_scale) { Boolean aspect_ratio_info_present_flag = bv.get1BitBoolean(); DEBUG_PRINT(aspect_ratio_info_present_flag); if (aspect_ratio_info_present_flag) { DEBUG_TAB; unsigned aspect_ratio_idc = bv.getBits(8); DEBUG_PRINT(aspect_ratio_idc); if (aspect_ratio_idc == 255/*Extended_SAR*/) { bv.skipBits(32); // sar_width; sar_height } } Boolean overscan_info_present_flag = bv.get1BitBoolean(); DEBUG_PRINT(overscan_info_present_flag); if (overscan_info_present_flag) { bv.skipBits(1); // overscan_appropriate_flag } Boolean video_signal_type_present_flag = bv.get1BitBoolean(); DEBUG_PRINT(video_signal_type_present_flag); if (video_signal_type_present_flag) { DEBUG_TAB; bv.skipBits(4); // video_format; video_full_range_flag Boolean colour_description_present_flag = bv.get1BitBoolean(); DEBUG_PRINT(colour_description_present_flag); if (colour_description_present_flag) { bv.skipBits(24); // colour_primaries; transfer_characteristics; matrix_coefficients } } Boolean chroma_loc_info_present_flag = bv.get1BitBoolean(); DEBUG_PRINT(chroma_loc_info_present_flag); if (chroma_loc_info_present_flag) { (void)bv.get_expGolomb(); // chroma_sample_loc_type_top_field (void)bv.get_expGolomb(); // chroma_sample_loc_type_bottom_field } if (fHNumber == 265) { bv.skipBits(2); // neutral_chroma_indication_flag, field_seq_flag Boolean frame_field_info_present_flag = bv.get1BitBoolean(); DEBUG_PRINT(frame_field_info_present_flag); pic_struct_present_flag = frame_field_info_present_flag; // hack to make H.265 like H.264 Boolean default_display_window_flag = bv.get1BitBoolean(); DEBUG_PRINT(default_display_window_flag); if (default_display_window_flag) { (void)bv.get_expGolomb(); // def_disp_win_left_offset (void)bv.get_expGolomb(); // def_disp_win_right_offset (void)bv.get_expGolomb(); // def_disp_win_top_offset (void)bv.get_expGolomb(); // def_disp_win_bottom_offset } } Boolean timing_info_present_flag = bv.get1BitBoolean(); DEBUG_PRINT(timing_info_present_flag); if (timing_info_present_flag) { DEBUG_TAB; num_units_in_tick = bv.getBits(32); DEBUG_PRINT(num_units_in_tick); time_scale = bv.getBits(32); DEBUG_PRINT(time_scale); if (fHNumber == 264) { Boolean fixed_frame_rate_flag = bv.get1BitBoolean(); DEBUG_PRINT(fixed_frame_rate_flag); } else { // 265 Boolean vui_poc_proportional_to_timing_flag = bv.get1BitBoolean(); DEBUG_PRINT(vui_poc_proportional_to_timing_flag); if (vui_poc_proportional_to_timing_flag) { unsigned vui_num_ticks_poc_diff_one_minus1 = bv.get_expGolomb(); DEBUG_PRINT(vui_num_ticks_poc_diff_one_minus1); } return; // For H.265, don't bother parsing any more of this ##### } } // The following is H.264 only: ##### Boolean nal_hrd_parameters_present_flag = bv.get1BitBoolean(); DEBUG_PRINT(nal_hrd_parameters_present_flag); if (nal_hrd_parameters_present_flag) analyze_hrd_parameters(bv); Boolean vcl_hrd_parameters_present_flag = bv.get1BitBoolean(); DEBUG_PRINT(vcl_hrd_parameters_present_flag); if (vcl_hrd_parameters_present_flag) analyze_hrd_parameters(bv); CpbDpbDelaysPresentFlag = nal_hrd_parameters_present_flag || vcl_hrd_parameters_present_flag; if (CpbDpbDelaysPresentFlag) { bv.skipBits(1); // low_delay_hrd_flag } pic_struct_present_flag = bv.get1BitBoolean(); DEBUG_PRINT(pic_struct_present_flag); }