public void copyTo(PictureParameterSet pps) { pps.sps_id = sps_id; pps.cabac = cabac; ///< entropy_coding_mode_flag pps.pic_order_present = pic_order_present; ///< pic_order_present_flag pps.slice_group_count = slice_group_count; ///< num_slice_groups_minus1 + 1 pps.mb_slice_group_map_type = mb_slice_group_map_type; pps.ref_count = new long[2]; ///< num_ref_idx_l0/1_active_minus1 + 1 pps.ref_count[0] = ref_count[0]; pps.ref_count[1] = ref_count[1]; pps.weighted_pred = weighted_pred; ///< weighted_pred_flag pps.weighted_bipred_idc = weighted_bipred_idc; pps.init_qp = init_qp; ///< pic_init_qp_minus26 + 26 pps.init_qs = init_qs; ///< pic_init_qs_minus26 + 26 pps.chroma_qp_index_offset = new int[2]; pps.chroma_qp_index_offset[0] = chroma_qp_index_offset[0]; pps.chroma_qp_index_offset[1] = chroma_qp_index_offset[1]; pps.deblocking_filter_parameters_present = deblocking_filter_parameters_present; ///< deblocking_filter_parameters_present_flag pps.constrained_intra_pred = constrained_intra_pred; ///< constrained_intra_pred_flag pps.redundant_pic_cnt_present = redundant_pic_cnt_present; ///< redundant_pic_cnt_present_flag pps.transform_8x8_mode = transform_8x8_mode; ///< transform_8x8_mode_flag pps.scaling_matrix4 = (int[][])scaling_matrix4.Clone(); pps.scaling_matrix8 = (int[][])scaling_matrix8.Clone(); pps.chroma_qp_table = (int[][])chroma_qp_table.Clone(); pps.chroma_qp_diff = chroma_qp_diff; }
public int weighted_pred; ///< weighted_pred_flag #endregion Fields #region Methods public void copyTo(PictureParameterSet pps) { pps.sps_id = sps_id; pps.cabac = cabac; ///< entropy_coding_mode_flag pps.pic_order_present = pic_order_present; ///< pic_order_present_flag pps.slice_group_count = slice_group_count; ///< num_slice_groups_minus1 + 1 pps.mb_slice_group_map_type = mb_slice_group_map_type; pps.ref_count = new long[2]; ///< num_ref_idx_l0/1_active_minus1 + 1 pps.ref_count[0] = ref_count[0]; pps.ref_count[1] = ref_count[1]; pps.weighted_pred = weighted_pred; ///< weighted_pred_flag pps.weighted_bipred_idc = weighted_bipred_idc; pps.init_qp = init_qp; ///< pic_init_qp_minus26 + 26 pps.init_qs = init_qs; ///< pic_init_qs_minus26 + 26 pps.chroma_qp_index_offset = new int[2]; pps.chroma_qp_index_offset[0] = chroma_qp_index_offset[0]; pps.chroma_qp_index_offset[1] = chroma_qp_index_offset[1]; pps.deblocking_filter_parameters_present = deblocking_filter_parameters_present; ///< deblocking_filter_parameters_present_flag pps.constrained_intra_pred = constrained_intra_pred; ///< constrained_intra_pred_flag pps.redundant_pic_cnt_present = redundant_pic_cnt_present; ///< redundant_pic_cnt_present_flag pps.transform_8x8_mode = transform_8x8_mode; ///< transform_8x8_mode_flag pps.scaling_matrix4 = (int[][])scaling_matrix4.Clone(); pps.scaling_matrix8 = (int[][])scaling_matrix8.Clone(); pps.chroma_qp_table = (int[][])chroma_qp_table.Clone(); pps.chroma_qp_diff = chroma_qp_diff; }
public static void build_qp_table(PictureParameterSet pps, int t, int index) { int i; for (i = 0; i < 52; i++) pps.chroma_qp_table[t][i] = ff_h264_chroma_qp[av_clip(i + index, 0, 51)]; }
//////////////////////////// // Decode PPS public int ff_h264_decode_picture_parameter_set(int bit_length) { /*unsigned */ int pps_id = s.gb.get_ue_golomb("pps_id"); PictureParameterSet pps; if (pps_id >= MAX_PPS_COUNT) { //av_log(this.s.avctx, AV_LOG_ERROR, "pps_id (%d) out of range\n", pps_id); return -41; } pps = new PictureParameterSet(); if (pps == null) return -42; pps.sps_id = s.gb.get_ue_golomb_31("sps_id"); if (/*(unsigned)*/pps.sps_id >= MAX_SPS_COUNT || this.sps_buffers[(int)pps.sps_id] == null) { //av_log(this.s.avctx, AV_LOG_ERROR, "sps_id out of range\n"); return -43; } pps.cabac = (int)s.gb.get_bits1("cabac"); pps.pic_order_present = (int)s.gb.get_bits1("pic_order_present"); pps.slice_group_count = s.gb.get_ue_golomb("slice_group_count") + 1; if (pps.slice_group_count > 1) { pps.mb_slice_group_map_type = s.gb.get_ue_golomb("mb_slice_group_map_type"); //av_log(this.s.avctx, AV_LOG_ERROR, "FMO not supported\n"); switch (pps.mb_slice_group_map_type) { case 0: break; case 2: break; case 3: case 4: case 5: break; case 6: break; } } pps.ref_count[0] = s.gb.get_ue_golomb("ref_count[0]") + 1; pps.ref_count[1] = s.gb.get_ue_golomb("ref_count[1]") + 1; if (pps.ref_count[0] - 1 > 32 - 1 || pps.ref_count[1] - 1 > 32 - 1) { //av_log(this.s.avctx, AV_LOG_ERROR, "reference overflow (pps)\n"); return -44; } pps.weighted_pred = (int)s.gb.get_bits1("weighted_pred"); pps.weighted_bipred_idc = (int)s.gb.get_bits(2, "weighted_bipred_idc"); pps.init_qp = s.gb.get_se_golomb("init_qp") + 26; pps.init_qs = s.gb.get_se_golomb("init_qs") + 26; pps.chroma_qp_index_offset[0] = s.gb.get_se_golomb("chroma_qp_index_offset[0]"); pps.deblocking_filter_parameters_present = (int)s.gb.get_bits1("deblocking_filter_parameters_present"); pps.constrained_intra_pred = (int)s.gb.get_bits1("constrained_intra_pred"); pps.redundant_pic_cnt_present = (int)s.gb.get_bits1("redundant_pic_cnt_present"); pps.transform_8x8_mode = 0; this.dequant_coeff_pps = -1; //contents of sps/pps can change even if id doesn't, so reinit //memcpy(pps.scaling_matrix4, this.sps_buffers[(int)pps.sps_id].scaling_matrix4, sizeof(pps.scaling_matrix4)); //memcpy(pps.scaling_matrix8, this.sps_buffers[(int)pps.sps_id].scaling_matrix8, sizeof(pps.scaling_matrix8)); for (int k = 0; k < this.sps_buffers[(int)pps.sps_id].scaling_matrix4.Length; k++) Array.Copy(this.sps_buffers[(int)pps.sps_id].scaling_matrix4[k], 0, pps.scaling_matrix4[k], 0, this.sps_buffers[(int)pps.sps_id].scaling_matrix4[k].Length); for (int k = 0; k < this.sps_buffers[(int)pps.sps_id].scaling_matrix8.Length; k++) Array.Copy(this.sps_buffers[(int)pps.sps_id].scaling_matrix8[k], 0, pps.scaling_matrix8[k], 0, this.sps_buffers[(int)pps.sps_id].scaling_matrix8[k].Length); if (s.gb.get_bits_count() < bit_length) { pps.transform_8x8_mode = (int)s.gb.get_bits1("transform_8x8_mode"); decode_scaling_matrices(this.sps_buffers[(int)pps.sps_id], pps, 0, pps.scaling_matrix4, pps.scaling_matrix8); pps.chroma_qp_index_offset[1] = s.gb.get_se_golomb("chroma_qp_index_offset[1]"); //second_chroma_qp_index_offset } else { pps.chroma_qp_index_offset[1] = pps.chroma_qp_index_offset[0]; } build_qp_table(pps, 0, pps.chroma_qp_index_offset[0]); build_qp_table(pps, 1, pps.chroma_qp_index_offset[1]); if (pps.chroma_qp_index_offset[0] != pps.chroma_qp_index_offset[1]) pps.chroma_qp_diff = 1; /* if(s.avctx.debug&FF_DEBUG_PICT_INFO){ av_log(this.s.avctx, AV_LOG_DEBUG, "pps:%u sps:%u %s slice_groups:%d ref:%d/%d %s qp:%d/%d/%d/%d %s %s %s %s\n", pps_id, pps.sps_id, pps.cabac ? "CABAC" : "CAVLC", pps.slice_group_count, pps.ref_count[0], pps.ref_count[1], pps.weighted_pred ? "weighted" : "", pps.init_qp, pps.init_qs, pps.chroma_qp_index_offset[0], pps.chroma_qp_index_offset[1], pps.deblocking_filter_parameters_present ? "LPAR" : "", pps.constrained_intra_pred ? "CONSTR" : "", pps.redundant_pic_cnt_present ? "REDU" : "", pps.transform_8x8_mode ? "8x8DCT" : "" ); } */ this.pps_buffers[pps_id] = null; this.pps_buffers[pps_id] = pps; return 0; }
public void decode_scaling_matrices(SequenceParameterSet sps, PictureParameterSet pps, int is_sps, /* uint8_t (*scaling_matrix4)[16] */int[][] scaling_matrix4, /* * uint8_t * (* * scaling_matrix8 * )[64] */ int[][] scaling_matrix8) { int fallback_sps = (0 == is_sps && 0 != sps.scaling_matrix_present) ? 1 : 0; /* const uint8_t * */ int[][] fallback = new int[][] { (fallback_sps != 0) ? sps.scaling_matrix4[0] : default_scaling4[0], (fallback_sps != 0) ? sps.scaling_matrix4[3] : default_scaling4[1], (fallback_sps != 0) ? sps.scaling_matrix8[0] : default_scaling8[0], (fallback_sps != 0) ? sps.scaling_matrix8[1] : default_scaling8[1] }; if (0l != s.gb.get_bits1("01?")) { sps.scaling_matrix_present |= is_sps; decode_scaling_list(scaling_matrix4[0], 16, default_scaling4[0], fallback[0]); // Intra, Y decode_scaling_list(scaling_matrix4[1], 16, default_scaling4[0], scaling_matrix4[0]); // Intra, Cr decode_scaling_list(scaling_matrix4[2], 16, default_scaling4[0], scaling_matrix4[1]); // Intra, Cb decode_scaling_list(scaling_matrix4[3], 16, default_scaling4[1], fallback[1]); // Inter, Y decode_scaling_list(scaling_matrix4[4], 16, default_scaling4[1], scaling_matrix4[3]); // Inter, Cr decode_scaling_list(scaling_matrix4[5], 16, default_scaling4[1], scaling_matrix4[4]); // Inter, Cb if (is_sps != 0 || pps.transform_8x8_mode != 0) { decode_scaling_list(scaling_matrix8[0], 64, default_scaling8[0], fallback[2]); // Intra, Y decode_scaling_list(scaling_matrix8[1], 64, default_scaling8[1], fallback[3]); // Inter, Y } } }