private void writeOffsetWeight(SliceHeader sliceHeader, BitWriter writer, int list) { SeqParameterSet sps = sliceHeader.sps; int defaultLW = 1 << sliceHeader.pred_weight_table.luma_log2_weight_denom; int defaultCW = 1 << sliceHeader.pred_weight_table.chroma_log2_weight_denom; for (int i = 0; i < sliceHeader.pred_weight_table.luma_weight[list].Length; i++) { bool flagLuma = sliceHeader.pred_weight_table.luma_weight[list][i] != defaultLW || sliceHeader.pred_weight_table.luma_offset[list][i] != 0; CAVLCWriter.writeBool(writer, flagLuma, "SH: luma_weight_l0_flag"); if (flagLuma) { CAVLCWriter.writeSE(writer, sliceHeader.pred_weight_table.luma_weight[list][i], "SH: luma_weight_l" + list); CAVLCWriter.writeSE(writer, sliceHeader.pred_weight_table.luma_offset[list][i], "SH: luma_offset_l" + list); } if (sps.chroma_format_idc != ColorSpace.MONO) { bool flagChroma = sliceHeader.pred_weight_table.chroma_weight[list][0][i] != defaultCW || sliceHeader.pred_weight_table.chroma_offset[list][0][i] != 0 || sliceHeader.pred_weight_table.chroma_weight[list][1][i] != defaultCW || sliceHeader.pred_weight_table.chroma_offset[list][1][i] != 0; CAVLCWriter.writeBool(writer, flagChroma, "SH: chroma_weight_l0_flag"); if (flagChroma) { for (int j = 0; j < 2; j++) { CAVLCWriter.writeSE(writer, sliceHeader.pred_weight_table.chroma_weight[list][j][i], "SH: chroma_weight_l" + list); CAVLCWriter.writeSE(writer, sliceHeader.pred_weight_table.chroma_offset[list][j][i], "SH: chroma_offset_l" + list); } } } } }
private void writeDecRefPicMarking(SliceHeader sliceHeader, bool idrSlice, BitWriter writer) { if (idrSlice) { RefPicMarkingIDR drpmidr = sliceHeader.refPicMarkingIDR; CAVLCWriter.writeBool(writer, drpmidr.isDiscardDecodedPics(), "SH: no_output_of_prior_pics_flag"); CAVLCWriter.writeBool(writer, drpmidr.isUseForlongTerm(), "SH: long_term_reference_flag"); } else { CAVLCWriter.writeBool(writer, sliceHeader.refPicMarkingNonIDR != null, "SH: adaptive_ref_pic_marking_mode_flag"); if (sliceHeader.refPicMarkingNonIDR != null) { RefPicMarking drpmidr = sliceHeader.refPicMarkingNonIDR; foreach (var mmop in drpmidr.getInstructions()) { switch (mmop.getType()) { case RefPicMarking.InstrType.REMOVE_SHORT: CAVLCWriter.writeUE(writer, 1, "SH: memory_management_control_operation"); CAVLCWriter.writeUE(writer, mmop.getArg1() - 1, "SH: difference_of_pic_nums_minus1"); break; case RefPicMarking.InstrType.REMOVE_LONG: CAVLCWriter.writeUE(writer, 2, "SH: memory_management_control_operation"); CAVLCWriter.writeUE(writer, mmop.getArg1(), "SH: long_term_pic_num"); break; case RefPicMarking.InstrType.CONVERT_INTO_LONG: CAVLCWriter.writeUE(writer, 3, "SH: memory_management_control_operation"); CAVLCWriter.writeUE(writer, mmop.getArg1() - 1, "SH: difference_of_pic_nums_minus1"); CAVLCWriter.writeUE(writer, mmop.getArg2(), "SH: long_term_frame_idx"); break; case RefPicMarking.InstrType.TRUNK_LONG: CAVLCWriter.writeUE(writer, 4, "SH: memory_management_control_operation"); CAVLCWriter.writeUE(writer, mmop.getArg1() + 1, "SH: max_long_term_frame_idx_plus1"); break; case RefPicMarking.InstrType.CLEAR: CAVLCWriter.writeUE(writer, 5, "SH: memory_management_control_operation"); break; case RefPicMarking.InstrType.MARK_LONG: CAVLCWriter.writeUE(writer, 6, "SH: memory_management_control_operation"); CAVLCWriter.writeUE(writer, mmop.getArg1(), "SH: long_term_frame_idx"); break; } } CAVLCWriter.writeUE(writer, 0, "SH: memory_management_control_operation"); } } }
private void writeRefPicListReordering(SliceHeader sliceHeader, BitWriter writer) { if (sliceHeader.slice_type.isInter()) { CAVLCWriter.writeBool(writer, sliceHeader.refPicReordering[0] != null, "SH: ref_pic_list_reordering_flag_l0"); writeReorderingList(sliceHeader.refPicReordering[0], writer); } if (sliceHeader.slice_type == SliceType.B) { CAVLCWriter.writeBool(writer, sliceHeader.refPicReordering[1] != null, "SH: ref_pic_list_reordering_flag_l1"); writeReorderingList(sliceHeader.refPicReordering[1], writer); } }
private void writeHRDParameters(HRDParameters hrd, BitWriter writer) { CAVLCWriter.writeUE(writer, hrd.cpb_cnt_minus1, "HRD: cpb_cnt_minus1"); CAVLCWriter.writeNBit(writer, hrd.bit_rate_scale, 4, "HRD: bit_rate_scale"); CAVLCWriter.writeNBit(writer, hrd.cpb_size_scale, 4, "HRD: cpb_size_scale"); for (int SchedSelIdx = 0; SchedSelIdx <= hrd.cpb_cnt_minus1; SchedSelIdx++) { CAVLCWriter.writeUE(writer, hrd.bit_rate_value_minus1[SchedSelIdx], "HRD: "); CAVLCWriter.writeUE(writer, hrd.cpb_size_value_minus1[SchedSelIdx], "HRD: "); CAVLCWriter.writeBool(writer, hrd.cbr_flag[SchedSelIdx], "HRD: "); } CAVLCWriter.writeNBit(writer, hrd.initial_cpb_removal_delay_length_minus1, 5, "HRD: initial_cpb_removal_delay_length_minus1"); CAVLCWriter.writeNBit(writer, hrd.cpb_removal_delay_length_minus1, 5, "HRD: cpb_removal_delay_length_minus1"); CAVLCWriter.writeNBit(writer, hrd.dpb_output_delay_length_minus1, 5, "HRD: dpb_output_delay_length_minus1"); CAVLCWriter.writeNBit(writer, hrd.time_offset_length, 5, "HRD: time_offset_length"); }
private void writeVUIParameters(VUIParameters vuip, BitWriter writer) { CAVLCWriter.writeBool(writer, vuip.aspect_ratio_info_present_flag, "VUI: aspect_ratio_info_present_flag"); if (vuip.aspect_ratio_info_present_flag) { CAVLCWriter.writeNBit(writer, vuip.aspect_ratio.getValue(), 8, "VUI: aspect_ratio"); if (vuip.aspect_ratio == AspectRatio.Extended_SAR) { CAVLCWriter.writeNBit(writer, vuip.sar_width, 16, "VUI: sar_width"); CAVLCWriter.writeNBit(writer, vuip.sar_height, 16, "VUI: sar_height"); } } CAVLCWriter.writeBool(writer, vuip.overscan_info_present_flag, "VUI: overscan_info_present_flag"); if (vuip.overscan_info_present_flag) { CAVLCWriter.writeBool(writer, vuip.overscan_appropriate_flag, "VUI: overscan_appropriate_flag"); } CAVLCWriter.writeBool(writer, vuip.video_signal_type_present_flag, "VUI: video_signal_type_present_flag"); if (vuip.video_signal_type_present_flag) { CAVLCWriter.writeNBit(writer, vuip.video_format, 3, "VUI: video_format"); CAVLCWriter.writeBool(writer, vuip.video_full_range_flag, "VUI: video_full_range_flag"); CAVLCWriter.writeBool(writer, vuip.colour_description_present_flag, "VUI: colour_description_present_flag"); if (vuip.colour_description_present_flag) { CAVLCWriter.writeNBit(writer, vuip.colour_primaries, 8, "VUI: colour_primaries"); CAVLCWriter.writeNBit(writer, vuip.transfer_characteristics, 8, "VUI: transfer_characteristics"); CAVLCWriter.writeNBit(writer, vuip.matrix_coefficients, 8, "VUI: matrix_coefficients"); } } CAVLCWriter.writeBool(writer, vuip.chroma_loc_info_present_flag, "VUI: chroma_loc_info_present_flag"); if (vuip.chroma_loc_info_present_flag) { CAVLCWriter.writeUE(writer, vuip.chroma_sample_loc_type_top_field, "VUI: chroma_sample_loc_type_top_field"); CAVLCWriter.writeUE(writer, vuip.chroma_sample_loc_type_bottom_field, "VUI: chroma_sample_loc_type_bottom_field"); } CAVLCWriter.writeBool(writer, vuip.timing_info_present_flag, "VUI: timing_info_present_flag"); if (vuip.timing_info_present_flag) { CAVLCWriter.writeNBit(writer, vuip.num_units_in_tick, 32, "VUI: num_units_in_tick"); CAVLCWriter.writeNBit(writer, vuip.time_scale, 32, "VUI: time_scale"); CAVLCWriter.writeBool(writer, vuip.fixed_frame_rate_flag, "VUI: fixed_frame_rate_flag"); } CAVLCWriter.writeBool(writer, vuip.nalHRDParams != null, "VUI: "); if (vuip.nalHRDParams != null) { writeHRDParameters(vuip.nalHRDParams, writer); } CAVLCWriter.writeBool(writer, vuip.vclHRDParams != null, "VUI: "); if (vuip.vclHRDParams != null) { writeHRDParameters(vuip.vclHRDParams, writer); } if (vuip.nalHRDParams != null || vuip.vclHRDParams != null) { CAVLCWriter.writeBool(writer, vuip.low_delay_hrd_flag, "VUI: low_delay_hrd_flag"); } CAVLCWriter.writeBool(writer, vuip.pic_struct_present_flag, "VUI: pic_struct_present_flag"); CAVLCWriter.writeBool(writer, vuip.bitstreamRestriction != null, "VUI: "); if (vuip.bitstreamRestriction != null) { CAVLCWriter.writeBool(writer, vuip.bitstreamRestriction.motion_vectors_over_pic_boundaries_flag, "VUI: motion_vectors_over_pic_boundaries_flag"); CAVLCWriter.writeUE(writer, vuip.bitstreamRestriction.max_bytes_per_pic_denom, "VUI: max_bytes_per_pic_denom"); CAVLCWriter.writeUE(writer, vuip.bitstreamRestriction.max_bits_per_mb_denom, "VUI: max_bits_per_mb_denom"); CAVLCWriter.writeUE(writer, vuip.bitstreamRestriction.log2_max_mv_length_horizontal, "VUI: log2_max_mv_length_horizontal"); CAVLCWriter.writeUE(writer, vuip.bitstreamRestriction.log2_max_mv_length_vertical, "VUI: log2_max_mv_length_vertical"); CAVLCWriter.writeUE(writer, vuip.bitstreamRestriction.num_reorder_frames, "VUI: num_reorder_frames"); CAVLCWriter.writeUE(writer, vuip.bitstreamRestriction.max_dec_frame_buffering, "VUI: max_dec_frame_buffering"); } }
public void write(MemoryStream outb) { BitWriter writer = new BitWriter(outb); CAVLCWriter.writeNBit(writer, profile_idc, 8, "SPS: profile_idc"); CAVLCWriter.writeBool(writer, constraint_set_0_flag, "SPS: constraint_set_0_flag"); CAVLCWriter.writeBool(writer, constraint_set_1_flag, "SPS: constraint_set_1_flag"); CAVLCWriter.writeBool(writer, constraint_set_2_flag, "SPS: constraint_set_2_flag"); CAVLCWriter.writeBool(writer, constraint_set_3_flag, "SPS: constraint_set_3_flag"); CAVLCWriter.writeNBit(writer, 0, 4, "SPS: reserved"); CAVLCWriter.writeNBit(writer, level_idc, 8, "SPS: level_idc"); CAVLCWriter.writeUE(writer, seq_parameter_set_id, "SPS: seq_parameter_set_id"); if (profile_idc == 100 || profile_idc == 110 || profile_idc == 122 || profile_idc == 144) { CAVLCWriter.writeUE(writer, fromColor(chroma_format_idc), "SPS: chroma_format_idc"); if (chroma_format_idc == ColorSpace.YUV444) { CAVLCWriter.writeBool(writer, residual_color_transform_flag, "SPS: residual_color_transform_flag"); } CAVLCWriter.writeUE(writer, bit_depth_luma_minus8, "SPS: "); CAVLCWriter.writeUE(writer, bit_depth_chroma_minus8, "SPS: "); CAVLCWriter.writeBool(writer, qpprime_y_zero_transform_bypass_flag, "SPS: qpprime_y_zero_transform_bypass_flag"); CAVLCWriter.writeBool(writer, scalingMatrix != null, "SPS: "); if (scalingMatrix != null) { for (int i = 0; i < 8; i++) { if (i < 6) { CAVLCWriter.writeBool(writer, (scalingMatrix.ScalingList4x4[i] != null), "SPS: "); if (scalingMatrix.ScalingList4x4[i] != null) { scalingMatrix.ScalingList4x4[i].write(writer); } } else { CAVLCWriter.writeBool(writer, (scalingMatrix.ScalingList8x8[i - 6] != null), "SPS: "); if (scalingMatrix.ScalingList8x8[i - 6] != null) { scalingMatrix.ScalingList8x8[i - 6].write(writer); } } } } } CAVLCWriter.writeUE(writer, log2_max_frame_num_minus4, "SPS: log2_max_frame_num_minus4"); CAVLCWriter.writeUE(writer, pic_order_cnt_type, "SPS: pic_order_cnt_type"); if (pic_order_cnt_type == 0) { CAVLCWriter.writeUE(writer, log2_max_pic_order_cnt_lsb_minus4, "SPS: log2_max_pic_order_cnt_lsb_minus4"); } else if (pic_order_cnt_type == 1) { CAVLCWriter.writeBool(writer, delta_pic_order_always_zero_flag, "SPS: delta_pic_order_always_zero_flag"); CAVLCWriter.writeSE(writer, offset_for_non_ref_pic, "SPS: offset_for_non_ref_pic"); CAVLCWriter.writeSE(writer, offset_for_top_to_bottom_field, "SPS: offset_for_top_to_bottom_field"); CAVLCWriter.writeUE(writer, offsetForRefFrame.Length, "SPS: "); for (int i = 0; i < offsetForRefFrame.Length; i++) { CAVLCWriter.writeSE(writer, offsetForRefFrame[i], "SPS: "); } } CAVLCWriter.writeUE(writer, num_ref_frames, "SPS: num_ref_frames"); CAVLCWriter.writeBool(writer, gaps_in_frame_num_value_allowed_flag, "SPS: gaps_in_frame_num_value_allowed_flag"); CAVLCWriter.writeUE(writer, pic_width_in_mbs_minus1, "SPS: pic_width_in_mbs_minus1"); CAVLCWriter.writeUE(writer, pic_height_in_map_units_minus1, "SPS: pic_height_in_map_units_minus1"); CAVLCWriter.writeBool(writer, frame_mbs_only_flag, "SPS: frame_mbs_only_flag"); if (!frame_mbs_only_flag) { CAVLCWriter.writeBool(writer, mb_adaptive_frame_field_flag, "SPS: mb_adaptive_frame_field_flag"); } CAVLCWriter.writeBool(writer, direct_8x8_inference_flag, "SPS: direct_8x8_inference_flag"); CAVLCWriter.writeBool(writer, frame_cropping_flag, "SPS: frame_cropping_flag"); if (frame_cropping_flag) { CAVLCWriter.writeUE(writer, frame_crop_left_offset, "SPS: frame_crop_left_offset"); CAVLCWriter.writeUE(writer, frame_crop_right_offset, "SPS: frame_crop_right_offset"); CAVLCWriter.writeUE(writer, frame_crop_top_offset, "SPS: frame_crop_top_offset"); CAVLCWriter.writeUE(writer, frame_crop_bottom_offset, "SPS: frame_crop_bottom_offset"); } CAVLCWriter.writeBool(writer, vuiParams != null, "SPS: "); if (vuiParams != null) { writeVUIParameters(vuiParams, writer); } CAVLCWriter.writeTrailingBits(writer); }
public void write(MemoryStream outb) { BitWriter writer = new BitWriter(outb); CAVLCWriter.writeUE(writer, pic_parameter_set_id, "PPS: pic_parameter_set_id"); CAVLCWriter.writeUE(writer, seq_parameter_set_id, "PPS: seq_parameter_set_id"); CAVLCWriter.writeBool(writer, entropy_coding_mode_flag, "PPS: entropy_coding_mode_flag"); CAVLCWriter.writeBool(writer, pic_order_present_flag, "PPS: pic_order_present_flag"); CAVLCWriter.writeUE(writer, num_slice_groups_minus1, "PPS: num_slice_groups_minus1"); if (num_slice_groups_minus1 > 0) { CAVLCWriter.writeUE(writer, slice_group_map_type, "PPS: slice_group_map_type"); int[] top_left = new int[1]; int[] bottom_right = new int[1]; int[] run_length_minus1 = new int[1]; if (slice_group_map_type == 0) { for (int iGroup = 0; iGroup <= num_slice_groups_minus1; iGroup++) { CAVLCWriter.writeUE(writer, run_length_minus1[iGroup], "PPS: "); } } else if (slice_group_map_type == 2) { for (int iGroup = 0; iGroup < num_slice_groups_minus1; iGroup++) { CAVLCWriter.writeUE(writer, top_left[iGroup], "PPS: "); CAVLCWriter.writeUE(writer, bottom_right[iGroup], "PPS: "); } } else if (slice_group_map_type == 3 || slice_group_map_type == 4 || slice_group_map_type == 5) { CAVLCWriter.writeBool(writer, slice_group_change_direction_flag, "PPS: slice_group_change_direction_flag"); CAVLCWriter.writeUE(writer, slice_group_change_rate_minus1, "PPS: slice_group_change_rate_minus1"); } else if (slice_group_map_type == 6) { int NumberBitsPerSliceGroupId; if (num_slice_groups_minus1 + 1 > 4) { NumberBitsPerSliceGroupId = 3; } else if (num_slice_groups_minus1 + 1 > 2) { NumberBitsPerSliceGroupId = 2; } else { NumberBitsPerSliceGroupId = 1; } CAVLCWriter.writeUE(writer, slice_group_id.Length, "PPS: "); for (int i = 0; i <= slice_group_id.Length; i++) { CAVLCWriter.writeU(writer, slice_group_id[i], NumberBitsPerSliceGroupId); } } } CAVLCWriter.writeUE(writer, num_ref_idx_active_minus1[0], "PPS: num_ref_idx_l0_active_minus1"); CAVLCWriter.writeUE(writer, num_ref_idx_active_minus1[1], "PPS: num_ref_idx_l1_active_minus1"); CAVLCWriter.writeBool(writer, weighted_pred_flag, "PPS: weighted_pred_flag"); CAVLCWriter.writeNBit(writer, weighted_bipred_idc, 2, "PPS: weighted_bipred_idc"); CAVLCWriter.writeSE(writer, pic_init_qp_minus26, "PPS: pic_init_qp_minus26"); CAVLCWriter.writeSE(writer, pic_init_qs_minus26, "PPS: pic_init_qs_minus26"); CAVLCWriter.writeSE(writer, chroma_qp_index_offset, "PPS: chroma_qp_index_offset"); CAVLCWriter.writeBool(writer, deblocking_filter_control_present_flag, "PPS: deblocking_filter_control_present_flag"); CAVLCWriter.writeBool(writer, constrained_intra_pred_flag, "PPS: constrained_intra_pred_flag"); CAVLCWriter.writeBool(writer, redundant_pic_cnt_present_flag, "PPS: redundant_pic_cnt_present_flag"); if (extended != null) { CAVLCWriter.writeBool(writer, extended.transform_8x8_mode_flag, "PPS: transform_8x8_mode_flag"); CAVLCWriter.writeBool(writer, extended.scalindMatrix != null, "PPS: scalindMatrix"); if (extended.scalindMatrix != null) { for (int i = 0; i < 6 + 2 * (extended.transform_8x8_mode_flag ? 1 : 0); i++) { if (i < 6) { CAVLCWriter.writeBool(writer, extended.scalindMatrix.ScalingList4x4[i] != null, "PPS: "); if (extended.scalindMatrix.ScalingList4x4[i] != null) { extended.scalindMatrix.ScalingList4x4[i].write(writer); } } else { CAVLCWriter.writeBool(writer, extended.scalindMatrix.ScalingList8x8[i - 6] != null, "PPS: "); if (extended.scalindMatrix.ScalingList8x8[i - 6] != null) { extended.scalindMatrix.ScalingList8x8[i - 6].write(writer); } } } } CAVLCWriter.writeSE(writer, extended.second_chroma_qp_index_offset, "PPS: "); } CAVLCWriter.writeTrailingBits(writer); }
public void write(SliceHeader sliceHeader, bool idrSlice, int nalRefIdc, BitWriter writer) { SeqParameterSet sps = sliceHeader.sps; PictureParameterSet pps = sliceHeader.pps; CAVLCWriter.writeUE(writer, sliceHeader.first_mb_in_slice, "SH: first_mb_in_slice"); CAVLCWriter.writeUE(writer, (int)sliceHeader.slice_type + (sliceHeader.slice_type_restr ? 5 : 0), "SH: slice_type"); CAVLCWriter.writeUE(writer, sliceHeader.pic_parameter_set_id, "SH: pic_parameter_set_id"); CAVLCWriter.writeU(writer, sliceHeader.frame_num, sps.log2_max_frame_num_minus4 + 4, "SH: frame_num"); if (!sps.frame_mbs_only_flag) { CAVLCWriter.writeBool(writer, sliceHeader.field_pic_flag, "SH: field_pic_flag"); if (sliceHeader.field_pic_flag) { CAVLCWriter.writeBool(writer, sliceHeader.bottom_field_flag, "SH: bottom_field_flag"); } } if (idrSlice) { CAVLCWriter.writeUE(writer, sliceHeader.idr_pic_id, "SH: idr_pic_id"); } if (sps.pic_order_cnt_type == 0) { CAVLCWriter.writeU(writer, sliceHeader.pic_order_cnt_lsb, sps.log2_max_pic_order_cnt_lsb_minus4 + 4); if (pps.pic_order_present_flag && !sps.field_pic_flag) { CAVLCWriter.writeSE(writer, sliceHeader.delta_pic_order_cnt_bottom, "SH: delta_pic_order_cnt_bottom"); } } if (sps.pic_order_cnt_type == 1 && !sps.delta_pic_order_always_zero_flag) { CAVLCWriter.writeSE(writer, sliceHeader.delta_pic_order_cnt[0], "SH: delta_pic_order_cnt"); if (pps.pic_order_present_flag && !sps.field_pic_flag) { CAVLCWriter.writeSE(writer, sliceHeader.delta_pic_order_cnt[1], "SH: delta_pic_order_cnt"); } } if (pps.redundant_pic_cnt_present_flag) { CAVLCWriter.writeUE(writer, sliceHeader.redundant_pic_cnt, "SH: redundant_pic_cnt"); } if (sliceHeader.slice_type == SliceType.B) { CAVLCWriter.writeBool(writer, sliceHeader.direct_spatial_mv_pred_flag, "SH: direct_spatial_mv_pred_flag"); } if (sliceHeader.slice_type == SliceType.P || sliceHeader.slice_type == SliceType.SP || sliceHeader.slice_type == SliceType.B) { CAVLCWriter.writeBool(writer, sliceHeader.num_ref_idx_active_override_flag, "SH: num_ref_idx_active_override_flag"); if (sliceHeader.num_ref_idx_active_override_flag) { CAVLCWriter.writeUE(writer, sliceHeader.num_ref_idx_active_minus1[0], "SH: num_ref_idx_l0_active_minus1"); if (sliceHeader.slice_type == SliceType.B) { CAVLCWriter.writeUE(writer, sliceHeader.num_ref_idx_active_minus1[1], "SH: num_ref_idx_l1_active_minus1"); } } } writeRefPicListReordering(sliceHeader, writer); if ((pps.weighted_pred_flag && (sliceHeader.slice_type == SliceType.P || sliceHeader.slice_type == SliceType.SP)) || (pps.weighted_bipred_idc == 1 && sliceHeader.slice_type == SliceType.B)) { writePredWeightTable(sliceHeader, writer); } if (nalRefIdc != 0) { writeDecRefPicMarking(sliceHeader, idrSlice, writer); } if (pps.entropy_coding_mode_flag && sliceHeader.slice_type.isInter()) { CAVLCWriter.writeUE(writer, sliceHeader.cabac_init_idc, "SH: cabac_init_idc"); } CAVLCWriter.writeSE(writer, sliceHeader.slice_qp_delta, "SH: slice_qp_delta"); if (sliceHeader.slice_type == SliceType.SP || sliceHeader.slice_type == SliceType.SI) { if (sliceHeader.slice_type == SliceType.SP) { CAVLCWriter.writeBool(writer, sliceHeader.sp_for_switch_flag, "SH: sp_for_switch_flag"); } CAVLCWriter.writeSE(writer, sliceHeader.slice_qs_delta, "SH: slice_qs_delta"); } if (pps.deblocking_filter_control_present_flag) { CAVLCWriter.writeUE(writer, sliceHeader.disable_deblocking_filter_idc, "SH: disable_deblocking_filter_idc"); if (sliceHeader.disable_deblocking_filter_idc != 1) { CAVLCWriter.writeSE(writer, sliceHeader.slice_alpha_c0_offset_div2, "SH: slice_alpha_c0_offset_div2"); CAVLCWriter.writeSE(writer, sliceHeader.slice_beta_offset_div2, "SH: slice_beta_offset_div2"); } } if (pps.num_slice_groups_minus1 > 0 && pps.slice_group_map_type >= 3 && pps.slice_group_map_type <= 5) { int len = (sps.pic_height_in_map_units_minus1 + 1) * (sps.pic_width_in_mbs_minus1 + 1) / (pps.slice_group_change_rate_minus1 + 1); if (((sps.pic_height_in_map_units_minus1 + 1) * (sps.pic_width_in_mbs_minus1 + 1)) % (pps.slice_group_change_rate_minus1 + 1) > 0) { len += 1; } len = CeilLog2(len + 1); CAVLCWriter.writeU(writer, sliceHeader.slice_group_change_cycle, len); } }