コード例 #1
0
        public override bool Equals(object obj)
        {
            if (this == obj)
            {
                return(true);
            }
            if (obj == null)
            {
                return(false);
            }
            if (this.GetType() != obj.GetType())
            {
                return(false);
            }
            PictureParameterSet other = (PictureParameterSet)obj;

            if (!Array.Equals(bottom_right, other.bottom_right))
            {
                return(false);
            }
            if (chroma_qp_index_offset != other.chroma_qp_index_offset)
            {
                return(false);
            }
            if (constrained_intra_pred_flag != other.constrained_intra_pred_flag)
            {
                return(false);
            }
            if (deblocking_filter_control_present_flag != other.deblocking_filter_control_present_flag)
            {
                return(false);
            }
            if (entropy_coding_mode_flag != other.entropy_coding_mode_flag)
            {
                return(false);
            }
            if (extended == null)
            {
                if (other.extended != null)
                {
                    return(false);
                }
            }
            else if (!extended.Equals(other.extended))
            {
                return(false);
            }
            if (num_ref_idx_l0_active_minus1 != other.num_ref_idx_l0_active_minus1)
            {
                return(false);
            }
            if (num_ref_idx_l1_active_minus1 != other.num_ref_idx_l1_active_minus1)
            {
                return(false);
            }
            if (num_slice_groups_minus1 != other.num_slice_groups_minus1)
            {
                return(false);
            }
            if (pic_init_qp_minus26 != other.pic_init_qp_minus26)
            {
                return(false);
            }
            if (pic_init_qs_minus26 != other.pic_init_qs_minus26)
            {
                return(false);
            }
            if (pic_order_present_flag != other.pic_order_present_flag)
            {
                return(false);
            }
            if (pic_parameter_set_id != other.pic_parameter_set_id)
            {
                return(false);
            }
            if (redundant_pic_cnt_present_flag != other.redundant_pic_cnt_present_flag)
            {
                return(false);
            }
            if (!Array.Equals(run_length_minus1, other.run_length_minus1))
            {
                return(false);
            }
            if (seq_parameter_set_id != other.seq_parameter_set_id)
            {
                return(false);
            }
            if (slice_group_change_direction_flag != other.slice_group_change_direction_flag)
            {
                return(false);
            }
            if (slice_group_change_rate_minus1 != other.slice_group_change_rate_minus1)
            {
                return(false);
            }
            if (!Array.Equals(slice_group_id, other.slice_group_id))
            {
                return(false);
            }
            if (slice_group_map_type != other.slice_group_map_type)
            {
                return(false);
            }
            if (!Array.Equals(top_left, other.top_left))
            {
                return(false);
            }
            if (weighted_bipred_idc != other.weighted_bipred_idc)
            {
                return(false);
            }
            if (weighted_pred_flag != other.weighted_pred_flag)
            {
                return(false);
            }
            return(true);
        }
コード例 #2
0
        public static PictureParameterSet read(Stream @is)
        {
            var reader = new CAVLCReader(@is);
            PictureParameterSet pps = new PictureParameterSet
            {
                pic_parameter_set_id     = reader.ReadUE("PPS: pic_parameter_set_id"),
                seq_parameter_set_id     = reader.ReadUE("PPS: seq_parameter_set_id"),
                entropy_coding_mode_flag = reader.ReadBool("PPS: entropy_coding_mode_flag"),
                pic_order_present_flag   = reader.ReadBool("PPS: pic_order_present_flag"),
                num_slice_groups_minus1  = reader.ReadUE("PPS: num_slice_groups_minus1")
            };

            if (pps.num_slice_groups_minus1 > 0)
            {
                pps.slice_group_map_type = reader.ReadUE("PPS: slice_group_map_type");
                pps.top_left             = new int[pps.num_slice_groups_minus1 + 1];
                pps.bottom_right         = new int[pps.num_slice_groups_minus1 + 1];
                pps.run_length_minus1    = new int[pps.num_slice_groups_minus1 + 1];
                if (pps.slice_group_map_type == 0)
                {
                    for (int iGroup = 0; iGroup <= pps.num_slice_groups_minus1; iGroup++)
                    {
                        pps.run_length_minus1[iGroup] = reader.ReadUE("PPS: run_length_minus1");
                    }
                }
                else if (pps.slice_group_map_type == 2)
                {
                    for (int iGroup = 0; iGroup < pps.num_slice_groups_minus1; iGroup++)
                    {
                        pps.top_left[iGroup]     = reader.ReadUE("PPS: top_left");
                        pps.bottom_right[iGroup] = reader.ReadUE("PPS: bottom_right");
                    }
                }
                else if (pps.slice_group_map_type == 3 || pps.slice_group_map_type == 4 || pps.slice_group_map_type == 5)
                {
                    pps.slice_group_change_direction_flag = reader.ReadBool("PPS: slice_group_change_direction_flag");
                    pps.slice_group_change_rate_minus1    = reader.ReadUE("PPS: slice_group_change_rate_minus1");
                }
                else if (pps.slice_group_map_type == 6)
                {
                    int NumberBitsPerSliceGroupId;
                    if (pps.num_slice_groups_minus1 + 1 > 4)
                    {
                        NumberBitsPerSliceGroupId = 3;
                    }
                    else if (pps.num_slice_groups_minus1 + 1 > 2)
                    {
                        NumberBitsPerSliceGroupId = 2;
                    }
                    else
                    {
                        NumberBitsPerSliceGroupId = 1;
                    }
                    int pic_size_in_map_units_minus1 = reader.ReadUE("PPS: pic_size_in_map_units_minus1");
                    pps.slice_group_id = new int[pic_size_in_map_units_minus1 + 1];
                    for (int i = 0; i <= pic_size_in_map_units_minus1; i++)
                    {
                        pps.slice_group_id[i] = reader.ReadU(NumberBitsPerSliceGroupId, "PPS: slice_group_id [" + i + "]f");
                    }
                }
            }
            pps.num_ref_idx_l0_active_minus1           = reader.ReadUE("PPS: num_ref_idx_l0_active_minus1");
            pps.num_ref_idx_l1_active_minus1           = reader.ReadUE("PPS: num_ref_idx_l1_active_minus1");
            pps.weighted_pred_flag                     = reader.ReadBool("PPS: weighted_pred_flag");
            pps.weighted_bipred_idc                    = (int)reader.ReadNBit(2, "PPS: weighted_bipred_idc");
            pps.pic_init_qp_minus26                    = reader.ReadSE("PPS: pic_init_qp_minus26");
            pps.pic_init_qs_minus26                    = reader.ReadSE("PPS: pic_init_qs_minus26");
            pps.chroma_qp_index_offset                 = reader.ReadSE("PPS: chroma_qp_index_offset");
            pps.deblocking_filter_control_present_flag = reader.ReadBool("PPS: deblocking_filter_control_present_flag");
            pps.constrained_intra_pred_flag            = reader.ReadBool("PPS: constrained_intra_pred_flag");
            pps.redundant_pic_cnt_present_flag         = reader.ReadBool("PPS: redundant_pic_cnt_present_flag");
            if (reader.moreRBSPData())
            {
                pps.extended = new PictureParameterSet.PPSExt();
                pps.extended.transform_8x8_mode_flag = reader.ReadBool("PPS: transform_8x8_mode_flag");
                bool pic_scaling_matrix_present_flag = reader.ReadBool("PPS: pic_scaling_matrix_present_flag");
                if (pic_scaling_matrix_present_flag)
                {
                    for (int i = 0; i < 6 + 2 * (pps.extended.transform_8x8_mode_flag ? 1 : 0); i++)
                    {
                        bool pic_scaling_list_present_flag = reader.ReadBool("PPS: pic_scaling_list_present_flag");
                        if (pic_scaling_list_present_flag)
                        {
                            pps.extended.scalindMatrix.ScalingList4x4 = new ScalingList[8];
                            pps.extended.scalindMatrix.ScalingList8x8 = new ScalingList[8];
                            if (i < 6)
                            {
                                pps.extended.scalindMatrix.ScalingList4x4[i] = ScalingList.read(reader, 16);
                            }
                            else
                            {
                                pps.extended.scalindMatrix.ScalingList8x8[i - 6] = ScalingList.read(reader, 64);
                            }
                        }
                    }
                }
                pps.extended.second_chroma_qp_index_offset = reader.ReadSE("PPS: second_chroma_qp_index_offset");
            }

            reader.ReadTrailingBits();

            return(pps);
        }