Exemple #1
0
 //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
 //ORIGINAL LINE: private static void readScalingListMatrix(com.googlecode.mp4parser.h264.read.CAVLCReader reader, SeqParameterSet sps) throws java.io.IOException
 private static void readScalingListMatrix(CAVLCReader reader, SeqParameterSet sps)
 {
     sps.scalingMatrix = new ScalingMatrix();
     for (int i = 0; i < 8; i++)
     {
         bool seqScalingListPresentFlag = reader.readBool("SPS: seqScalingListPresentFlag");
         if (seqScalingListPresentFlag)
         {
             sps.scalingMatrix.ScalingList4x4 = new ScalingList[8];
             sps.scalingMatrix.ScalingList8x8 = new ScalingList[8];
             if (i < 6)
             {
                 sps.scalingMatrix.ScalingList4x4[i] = ScalingList.read(reader, 16);
             }
             else
             {
                 sps.scalingMatrix.ScalingList8x8[i - 6] = ScalingList.read(reader, 64);
             }
         }
     }
 }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static PictureParameterSet read(java.io.InputStream is) throws java.io.IOException
        public static PictureParameterSet read(Stream @is)
        {
            CAVLCReader         reader = new CAVLCReader(@is);
            PictureParameterSet pps    = new PictureParameterSet();

            pps.pic_parameter_set_id     = reader.readUE("PPS: pic_parameter_set_id");
            pps.seq_parameter_set_id     = reader.readUE("PPS: seq_parameter_set_id");
            pps.entropy_coding_mode_flag = reader.readBool("PPS: entropy_coding_mode_flag");
            pps.pic_order_present_flag   = reader.readBool("PPS: pic_order_present_flag");
            pps.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);
        }