예제 #1
0
        //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        //ORIGINAL LINE: private void writeVUIParameters(VUIParameters vuip, mp4parser.h264.write.CAVLCWriter writer) throws java.io.IOException
        private void writeVUIParameters(VUIParameters vuip, CAVLCWriter writer)
        {
            writer.writeBool(vuip.aspect_ratio_info_present_flag, "VUI: aspect_ratio_info_present_flag");
            if (vuip.aspect_ratio_info_present_flag)
            {
                writer.writeNBit(vuip.aspect_ratio.Value, 8, "VUI: aspect_ratio");
                if (vuip.aspect_ratio == AspectRatio.Extended_SAR)
                {
                    writer.writeNBit(vuip.sar_width, 16, "VUI: sar_width");
                    writer.writeNBit(vuip.sar_height, 16, "VUI: sar_height");
                }
            }
            writer.writeBool(vuip.overscan_info_present_flag, "VUI: overscan_info_present_flag");
            if (vuip.overscan_info_present_flag)
            {
                writer.writeBool(vuip.overscan_appropriate_flag, "VUI: overscan_appropriate_flag");
            }
            writer.writeBool(vuip.video_signal_type_present_flag, "VUI: video_signal_type_present_flag");
            if (vuip.video_signal_type_present_flag)
            {
                writer.writeNBit(vuip.video_format, 3, "VUI: video_format");
                writer.writeBool(vuip.video_full_range_flag, "VUI: video_full_range_flag");
                writer.writeBool(vuip.colour_description_present_flag, "VUI: colour_description_present_flag");
                if (vuip.colour_description_present_flag)
                {
                    writer.writeNBit(vuip.colour_primaries, 8, "VUI: colour_primaries");
                    writer.writeNBit(vuip.transfer_characteristics, 8, "VUI: transfer_characteristics");
                    writer.writeNBit(vuip.matrix_coefficients, 8, "VUI: matrix_coefficients");
                }
            }
            writer.writeBool(vuip.chroma_loc_info_present_flag, "VUI: chroma_loc_info_present_flag");
            if (vuip.chroma_loc_info_present_flag)
            {
                writer.writeUE(vuip.chroma_sample_loc_type_top_field, "VUI: chroma_sample_loc_type_top_field");
                writer.writeUE(vuip.chroma_sample_loc_type_bottom_field, "VUI: chroma_sample_loc_type_bottom_field");
            }
            writer.writeBool(vuip.timing_info_present_flag, "VUI: timing_info_present_flag");
            if (vuip.timing_info_present_flag)
            {
                writer.writeNBit(vuip.num_units_in_tick, 32, "VUI: num_units_in_tick");
                writer.writeNBit(vuip.time_scale, 32, "VUI: time_scale");
                writer.writeBool(vuip.fixed_frame_rate_flag, "VUI: fixed_frame_rate_flag");
            }
            writer.writeBool(vuip.nalHRDParams != null, "VUI: ");
            if (vuip.nalHRDParams != null)
            {
                writeHRDParameters(vuip.nalHRDParams, writer);
            }
            writer.writeBool(vuip.vclHRDParams != null, "VUI: ");
            if (vuip.vclHRDParams != null)
            {
                writeHRDParameters(vuip.vclHRDParams, writer);
            }

            if (vuip.nalHRDParams != null || vuip.vclHRDParams != null)
            {
                writer.writeBool(vuip.low_delay_hrd_flag, "VUI: low_delay_hrd_flag");
            }
            writer.writeBool(vuip.pic_struct_present_flag, "VUI: pic_struct_present_flag");
            writer.writeBool(vuip.bitstreamRestriction != null, "VUI: ");
            if (vuip.bitstreamRestriction != null)
            {
                writer.writeBool(vuip.bitstreamRestriction.Motion_vectors_over_pic_boundaries_flag, "VUI: motion_vectors_over_pic_boundaries_flag");
                writer.writeUE(vuip.bitstreamRestriction.Max_bytes_per_pic_denom, "VUI: max_bytes_per_pic_denom");
                writer.writeUE(vuip.bitstreamRestriction.Max_bits_per_mb_denom, "VUI: max_bits_per_mb_denom");
                writer.writeUE(vuip.bitstreamRestriction.Log2_max_mv_length_horizontal, "VUI: log2_max_mv_length_horizontal");
                writer.writeUE(vuip.bitstreamRestriction.Log2_max_mv_length_vertical, "VUI: log2_max_mv_length_vertical");
                writer.writeUE(vuip.bitstreamRestriction.Num_reorder_frames, "VUI: num_reorder_frames");
                writer.writeUE(vuip.bitstreamRestriction.Max_dec_frame_buffering, "VUI: max_dec_frame_buffering");
            }
        }
예제 #2
0
        private static VUIParameters ReadVUIParameters(CAVLCReader reader)
        {
            VUIParameters vuip = new VUIParameters();

            vuip.aspect_ratio_info_present_flag = reader.ReadBool("VUI: aspect_ratio_info_present_flag");
            if (vuip.aspect_ratio_info_present_flag)
            {
                vuip.aspect_ratio = AspectRatio.fromValue((int)reader.ReadNBit(8, "VUI: aspect_ratio"));
                if (vuip.aspect_ratio == AspectRatio.Extended_SAR)
                {
                    vuip.sar_width  = (int)reader.ReadNBit(16, "VUI: sar_width");
                    vuip.sar_height = (int)reader.ReadNBit(16, "VUI: sar_height");
                }
            }
            vuip.overscan_info_present_flag = reader.ReadBool("VUI: overscan_info_present_flag");
            if (vuip.overscan_info_present_flag)
            {
                vuip.overscan_appropriate_flag = reader.ReadBool("VUI: overscan_appropriate_flag");
            }
            vuip.video_signal_type_present_flag = reader.ReadBool("VUI: video_signal_type_present_flag");
            if (vuip.video_signal_type_present_flag)
            {
                vuip.video_format                    = (int)reader.ReadNBit(3, "VUI: video_format");
                vuip.video_full_range_flag           = reader.ReadBool("VUI: video_full_range_flag");
                vuip.colour_description_present_flag = reader.ReadBool("VUI: colour_description_present_flag");
                if (vuip.colour_description_present_flag)
                {
                    vuip.colour_primaries         = (int)reader.ReadNBit(8, "VUI: colour_primaries");
                    vuip.transfer_characteristics = (int)reader.ReadNBit(8, "VUI: transfer_characteristics");
                    vuip.matrix_coefficients      = (int)reader.ReadNBit(8, "VUI: matrix_coefficients");
                }
            }
            vuip.chroma_loc_info_present_flag = reader.ReadBool("VUI: chroma_loc_info_present_flag");
            if (vuip.chroma_loc_info_present_flag)
            {
                vuip.chroma_sample_loc_type_top_field    = reader.ReadUE("VUI chroma_sample_loc_type_top_field");
                vuip.chroma_sample_loc_type_bottom_field = reader.ReadUE("VUI chroma_sample_loc_type_bottom_field");
            }
            vuip.timing_info_present_flag = reader.ReadBool("VUI: timing_info_present_flag");
            if (vuip.timing_info_present_flag)
            {
                vuip.num_units_in_tick     = (int)reader.ReadNBit(32, "VUI: num_units_in_tick");
                vuip.time_scale            = (int)reader.ReadNBit(32, "VUI: time_scale");
                vuip.fixed_frame_rate_flag = reader.ReadBool("VUI: fixed_frame_rate_flag");
            }
            bool nal_hrd_parameters_present_flag = reader.ReadBool("VUI: nal_hrd_parameters_present_flag");

            if (nal_hrd_parameters_present_flag)
            {
                vuip.nalHRDParams = readHRDParameters(reader);
            }
            bool vcl_hrd_parameters_present_flag = reader.ReadBool("VUI: vcl_hrd_parameters_present_flag");

            if (vcl_hrd_parameters_present_flag)
            {
                vuip.vclHRDParams = readHRDParameters(reader);
            }
            if (nal_hrd_parameters_present_flag || vcl_hrd_parameters_present_flag)
            {
                vuip.low_delay_hrd_flag = reader.ReadBool("VUI: low_delay_hrd_flag");
            }
            vuip.pic_struct_present_flag = reader.ReadBool("VUI: pic_struct_present_flag");
            bool bitstream_restriction_flag = reader.ReadBool("VUI: bitstream_restriction_flag");

            if (bitstream_restriction_flag)
            {
                vuip.bitstreamRestriction = new VUIParameters.BitstreamRestriction();
                vuip.bitstreamRestriction.Motion_vectors_over_pic_boundaries_flag = reader.ReadBool("VUI: motion_vectors_over_pic_boundaries_flag");
                vuip.bitstreamRestriction.Max_bytes_per_pic_denom       = reader.ReadUE("VUI max_bytes_per_pic_denom");
                vuip.bitstreamRestriction.Max_bits_per_mb_denom         = reader.ReadUE("VUI max_bits_per_mb_denom");
                vuip.bitstreamRestriction.Log2_max_mv_length_horizontal = reader.ReadUE("VUI log2_max_mv_length_horizontal");
                vuip.bitstreamRestriction.Log2_max_mv_length_vertical   = reader.ReadUE("VUI log2_max_mv_length_vertical");
                vuip.bitstreamRestriction.Num_reorder_frames            = reader.ReadUE("VUI num_reorder_frames");
                vuip.bitstreamRestriction.Max_dec_frame_buffering       = reader.ReadUE("VUI max_dec_frame_buffering");
            }

            return(vuip);
        }