Exemplo n.º 1
0
        private void ParseScalingList(H264Bitstream r, int sizeOfScalingList)
        {
            int num1 = 8;
            int num2 = 8;

            for (int index = 0; index < sizeOfScalingList; ++index)
            {
                if (0 != num2)
                {
                    int num3 = H264BitstreamExtensions.ReadSe(r);
                    num2 = num1 + num3 + 256 & (int)byte.MaxValue;
                    bool flag = index == 0 && 0 == num2;
                }
                num1 = num2 == 0 ? num1 : num2;
            }
        }
Exemplo n.º 2
0
        private void ReadScalingList(H264Bitstream r, int sizeOfScalingList)
        {
            int num1 = 8;
            int num2 = 8;

            for (int index = 0; index < sizeOfScalingList; ++index)
            {
                if (num2 != 0)
                {
                    int num3 = H264BitstreamExtensions.ReadSe(r);
                    num2 = (num1 + num3 + 256) % 256;
                    bool flag = index == 0 && num2 == 0;
                }
                num1 = num2 == 0 ? num1 : num2;
            }
        }
Exemplo n.º 3
0
        public void ReadSliceHeader(H264Bitstream r, bool IdrPicFlag)
        {
            H264BitstreamExtensions.ReadUe(r);
            H264BitstreamExtensions.ReadUe(r);
            this._slicePicParameterSetId = new uint?(H264BitstreamExtensions.ReadUe(r));
            uint?nullable = this._separateColourPlaneFlag;

            if (((int)nullable.GetValueOrDefault() != 1 ? 0 : (nullable.HasValue ? 1 : 0)) != 0)
            {
                r.ReadBits(2);
            }
            H264Bitstream h264Bitstream1 = r;

            nullable = this._log2MaxFrameNumMinus4;
            int count1 = (nullable.HasValue ? (int)nullable.GetValueOrDefault() : 0) + 4;

            h264Bitstream1.ReadBits(count1);
            uint num1 = 0;

            nullable = this._frameMbsOnlyFlag;
            if (((int)nullable.GetValueOrDefault() != 0 ? 0 : (nullable.HasValue ? 1 : 0)) != 0)
            {
                num1 = r.ReadBits(1);
                if (0 != (int)num1)
                {
                    r.ReadBits(1);
                }
            }
            this._fieldPicFlag = new bool?(0 != (int)num1);
            if (!IdrPicFlag)
            {
                return;
            }
            H264BitstreamExtensions.ReadUe(r);
            nullable = this._picOrderCntType;
            if (((int)nullable.GetValueOrDefault() != 0 ? 0 : (nullable.HasValue ? 1 : 0)) != 0)
            {
                H264Bitstream h264Bitstream2 = r;
                nullable = this._log2MaxFrameNumMinus4;
                int count2 = (nullable.HasValue ? (int)nullable.GetValueOrDefault() : 0) + 4;
                h264Bitstream2.ReadBits(count2);
                nullable = this._bottomFieldPicOrderInFramePresentFlag;
                if (((int)nullable.GetValueOrDefault() != 0 ? 1 : (!nullable.HasValue ? 1 : 0)) != 0 && 0 == (int)num1)
                {
                    H264BitstreamExtensions.ReadSe(r);
                }
            }
            nullable = this._picOrderCntType;
            int num2;

            if (((int)nullable.GetValueOrDefault() != 1 ? 0 : (nullable.HasValue ? 1 : 0)) != 0)
            {
                nullable = this._deltaPicOrderAlwaysZeroFlag;
                num2     = ((int)nullable.GetValueOrDefault() != 0 ? 0 : (nullable.HasValue ? 1 : 0)) == 0 ? 1 : 0;
            }
            else
            {
                num2 = 1;
            }
            if (num2 == 0)
            {
                H264BitstreamExtensions.ReadSe(r);
                nullable = this._bottomFieldPicOrderInFramePresentFlag;
                if (((int)nullable.GetValueOrDefault() != 0 ? 1 : (!nullable.HasValue ? 1 : 0)) != 0 && 0 == (int)num1)
                {
                    H264BitstreamExtensions.ReadSe(r);
                }
            }
            nullable = this._redundantPicCntPresentFlag;
            if (((int)nullable.GetValueOrDefault() != 0 ? 1 : (!nullable.HasValue ? 1 : 0)) != 0)
            {
                H264BitstreamExtensions.ReadUe(r);
            }
        }
Exemplo n.º 4
0
        public void ReadPps(H264Bitstream r)
        {
            this._slicePicParameterSetId = new uint?();
            r.ReadBits(1);
            r.ReadBits(2);
            r.ReadBits(5);
            this._picParameterSetId    = new uint?(H264BitstreamExtensions.ReadUe(r));
            this._ppsSeqParameterSetId = new uint?(H264BitstreamExtensions.ReadUe(r));
            r.ReadBits(1);
            this._bottomFieldPicOrderInFramePresentFlag = new uint?(r.ReadBits(1));
            uint num1 = H264BitstreamExtensions.ReadUe(r);

            if (num1 > 0U)
            {
                uint num2 = H264BitstreamExtensions.ReadUe(r);
                if (0 == (int)num2)
                {
                    for (int index = 0; (long)index <= (long)num1; ++index)
                    {
                        H264BitstreamExtensions.ReadUe(r);
                    }
                }
                else if (2 == (int)num2)
                {
                    for (int index = 0; (long)index < (long)num1; ++index)
                    {
                        H264BitstreamExtensions.ReadUe(r);
                        H264BitstreamExtensions.ReadUe(r);
                    }
                }
                else if (3 == (int)num2 || 4 == (int)num2 || 5 == (int)num2)
                {
                    r.ReadBits(1);
                    H264BitstreamExtensions.ReadUe(r);
                }
                else if (6 == (int)num2)
                {
                    int  bitSize = H264Reader.GetBitSize(num1);
                    uint num3    = H264BitstreamExtensions.ReadUe(r);
                    for (int index = 0; (long)index <= (long)num3; ++index)
                    {
                        r.ReadBits(bitSize);
                    }
                }
            }
            H264BitstreamExtensions.ReadUe(r);
            H264BitstreamExtensions.ReadUe(r);
            r.ReadBits(1);
            r.ReadBits(2);
            H264BitstreamExtensions.ReadSe(r);
            H264BitstreamExtensions.ReadSe(r);
            H264BitstreamExtensions.ReadSe(r);
            r.ReadBits(1);
            r.ReadBits(1);
            this._redundantPicCntPresentFlag = new uint?(r.ReadBits(1));
            if (!this.more_rbsp_data(r))
            {
                return;
            }
            uint num4 = r.ReadBits(1);

            if (0 != (int)r.ReadBits(1))
            {
                int num2 = 0;
                while (true)
                {
                    long num3     = (long)num2;
                    long num5     = 6;
                    uint?nullable = this._chromaFormatIdc;
                    long num6     = (((int)nullable.GetValueOrDefault() != 3 ? 1 : (!nullable.HasValue ? 1 : 0)) != 0 ? 2L : 6L) * (long)num4;
                    long num7     = num5 + num6;
                    if (num3 < num7)
                    {
                        if (0 != (int)r.ReadBits(1))
                        {
                            if (num2 < 6)
                            {
                                this.ReadScalingList(r, 16);
                            }
                            else
                            {
                                this.ReadScalingList(r, 64);
                            }
                        }
                        ++num2;
                    }
                    else
                    {
                        break;
                    }
                }
            }
            H264BitstreamExtensions.ReadSe(r);
        }
Exemplo n.º 5
0
        public void ReadSps(H264Bitstream r)
        {
            this._ppsSeqParameterSetId = new uint?();
            r.ReadBits(1);
            r.ReadBits(2);
            r.ReadBits(5);
            uint profile_idc     = r.ReadBits(8);
            uint constraint_sets = r.ReadBits(8);
            uint num1            = r.ReadBits(8);

            this._seqParameterSetId = new uint?(H264BitstreamExtensions.ReadUe(r));
            if (Array.BinarySearch <uint>(H264Reader.ProfileIdcHasChromaFormat, profile_idc) >= 0)
            {
                uint num2 = H264BitstreamExtensions.ReadUe(r);
                this._chromaFormatIdc = new uint?(num2);
                if (3 == (int)num2)
                {
                    this._separateColourPlaneFlag = new uint?(r.ReadBits(1));
                }
                H264BitstreamExtensions.ReadUe(r);
                H264BitstreamExtensions.ReadUe(r);
                r.ReadBits(1);
                if (0 != (int)r.ReadBits(1))
                {
                    for (int index = 0; index < (3 != (int)num2 ? 8 : 12); ++index)
                    {
                        if (0 != (int)r.ReadBits(1))
                        {
                            this.ParseScalingList(r, index < 6 ? 16 : 64);
                        }
                    }
                }
            }
            this._log2MaxFrameNumMinus4 = new uint?(H264BitstreamExtensions.ReadUe(r));
            uint num3 = H264BitstreamExtensions.ReadUe(r);

            this._picOrderCntType = new uint?(num3);
            if (0 == (int)num3)
            {
                H264BitstreamExtensions.ReadUe(r);
            }
            else if (1 == (int)num3)
            {
                this._deltaPicOrderAlwaysZeroFlag = new uint?(r.ReadBits(1));
                H264BitstreamExtensions.ReadSe(r);
                H264BitstreamExtensions.ReadSe(r);
                uint num2 = H264BitstreamExtensions.ReadUe(r);
                for (int index = 0; (long)index < (long)num2; ++index)
                {
                    H264BitstreamExtensions.ReadSe(r);
                }
            }
            H264BitstreamExtensions.ReadUe(r);
            r.ReadBits(1);
            uint num4 = H264BitstreamExtensions.ReadUe(r);
            uint num5 = H264BitstreamExtensions.ReadUe(r);
            uint num6 = r.ReadBits(1);

            this._frameMbsOnlyFlag = new uint?(num6);
            if (0 == (int)num6)
            {
                r.ReadBits(1);
            }
            r.ReadBits(1);
            uint num7 = r.ReadBits(1);
            uint num8 = (uint)(((int)num4 + 1) * 16);
            uint num9 = (uint)((2 - (int)num6) * ((int)num5 + 1) * 16);

            if (0 != (int)num7)
            {
                uint num2  = H264BitstreamExtensions.ReadUe(r);
                uint num10 = H264BitstreamExtensions.ReadUe(r);
                uint num11 = H264BitstreamExtensions.ReadUe(r);
                uint num12 = H264BitstreamExtensions.ReadUe(r);
                num8 = (uint)((int)num8 - (int)num2 * 2 - (int)num10 * 2);
                num9 = (uint)((int)num9 - (int)num11 * 2 - (int)num12 * 2);
            }
            if (0 != (int)r.ReadBits(1))
            {
                this.ReadVuiParameters(r);
            }
            this.Height = new int?((int)num9);
            this.Width  = new int?((int)num8);
            this.Name   = string.Format("H.264 \"{0}\" profile, level {1} {2}x{3}", (object)H264Reader.ProfileName(profile_idc, constraint_sets), (object)((double)num1 / 10.0), (object)num8, (object)num9);
        }