当前位置: 首页>>代码示例>>C#>>正文


C# BitStream.GetBits方法代码示例

本文整理汇总了C#中BitStream.GetBits方法的典型用法代码示例。如果您正苦于以下问题:C# BitStream.GetBits方法的具体用法?C# BitStream.GetBits怎么用?C# BitStream.GetBits使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BitStream的用法示例。


在下文中一共展示了BitStream.GetBits方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Parse

        /// <summary>
        /// 
        /// </summary>
        /// <param name="input"></param>
        public override void Parse( Stream input )
        {
            BinaryReader br = new BinaryReader( input );

            _BlurX = br.ReadUInt32();
            _BlurY = br.ReadUInt32();

            BitStream bits = new BitStream( input );
            _Passes = ( byte )bits.GetBits( 5 );

            uint reserved = bits.GetBits( 3 );
            if ( 0 != reserved )
            {
                throw new SwfFormatException( "BlurFilter uses reserved bits" );
            }
        }
开发者ID:rtezli,项目名称:Blitzableiter,代码行数:20,代码来源:BlurFilter.cs

示例2: Parse

        /// <summary>
        /// 
        /// </summary>
        /// <param name="input"></param>
        public override void Parse( Stream input )
        {
            _GlowColor = new Rgba( this.Version );
            _GlowColor.Parse( input );

            BinaryReader br = new BinaryReader( input );

            _BlurX = br.ReadUInt32();
            _BlurY = br.ReadUInt32();
            _Strength = br.ReadUInt16();

            BitStream bits = new BitStream( input );
            _InnerGlow = ( 0 != bits.GetBits( 1 ) );
            _KnockOut = ( 0 != bits.GetBits( 1 ) );
            _CompositeSource = ( 0 != bits.GetBits( 1 ) );
            _Passes = ( byte )bits.GetBits( 5 );
        }
开发者ID:rtezli,项目名称:Blitzableiter,代码行数:21,代码来源:GlowFilter.cs

示例3: Parse

        /// <summary>
        /// Parses this object out of a stream
        /// </summary>
        public void Parse(Stream input)
        {
            log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            BitStream bits = new BitStream(input);

            this._pictureStartCode = bits.GetBits(17);
            this._version = (byte)bits.GetBits(5);
            this._temporalReference = (byte)bits.GetBits(8);
            this._pictureSize = (byte)bits.GetBits(3);

            if (this._pictureSize.Equals(0))
            {
                this._customWidth = (UInt16)bits.GetBits(8);
                this._customHeight = (UInt16)bits.GetBits(8);
            }
            else if (this._pictureSize.Equals(1))
            {
                this._customWidth = (UInt16)bits.GetBits(16);
                this._customHeight = (UInt16)bits.GetBits(16);
            }
            else
            {
                SwfFormatException e = new SwfFormatException("Not supported picture size.");
                log.Error(e.Message);
                throw e;
            }
            this._pictureType = (byte)bits.GetBits(2);
            this._deblockingFlag = Convert.ToBoolean(bits.GetBits(1));
            this._quantizer = (byte)bits.GetBits(5);
            this._extraInformationFlag = Convert.ToBoolean(bits.GetBits(1));
            bits.Reset();

            BinaryReader br = new BinaryReader(input);
            byte tempByte = 0;

            if (this._extraInformationFlag)
            {
                this._extraInformation = new List<byte>();

                while (0 != (tempByte = br.ReadByte()))
                {
                    this._extraInformation.Add(tempByte);
                }
            }
            this._extraInformation.Add(0);

            this._macroBlock = new MacroBlock(this._SwfVersion);
            this._macroBlock.Parse(input);
            //this._pictureStuffing.Parse(input);
        }
开发者ID:rtezli,项目名称:Blitzableiter,代码行数:54,代码来源:H236VideoPacket.cs

示例4: Parse

        /// <summary>
        /// Parses this object out of a stream
        /// </summary>
        public void Parse(Stream input)
        {
            log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            BitStream bits = new BitStream(input);

            this._blockWidth = (byte)bits.GetBits(4);
            this._imageWidth = (byte)bits.GetBits(12);
            this._blockHeight = (byte)bits.GetBits(4);
            this._imageHeight = (byte)bits.GetBits(12);

            ImageBlock temp = null;

            this._imageBlocks = new List<ImageBlock>();

            while (input.Length - input.Position > sizeof(UInt16))
            {
                temp = new ImageBlock(this._SwfVersion);
                temp.Parse(input);
                this._imageBlocks.Add(temp);
            }
        }
开发者ID:rtezli,项目名称:Blitzableiter,代码行数:25,代码来源:ScreenVideoPacket.cs

示例5: BigHuffmanTree

        public BigHuffmanTree(BitStream bs, int allocSize)
        {
            _bs = bs;
            uint bit = _bs.GetBit();
            if (bit == 0)
            {
                _tree = new uint[1];
                _tree[0] = 0;
                _last[0] = _last[1] = _last[2] = 0;
                return;
            }

            for (uint i = 0; i < 256; ++i)
                _prefixtree[i] = _prefixlength[i] = 0;

            _loBytes = new SmallHuffmanTree(_bs);
            _hiBytes = new SmallHuffmanTree(_bs);

            _markers[0] = _bs.GetBits(16);
            _markers[1] = _bs.GetBits(16);
            _markers[2] = _bs.GetBits(16);

            _last[0] = _last[1] = _last[2] = 0xffffffff;

            _treeSize = 0;
            _tree = new uint[allocSize / 4];
            DecodeTree(0, 0);
            bit = _bs.GetBit();
            Debug.Assert(bit == 0);

            for (uint i = 0; i < 3; ++i)
            {
                if (_last[i] == 0xffffffff)
                {
                    _last[i] = _treeSize;
                    _tree[_treeSize++] = 0;
                }
            }
        }
开发者ID:scemino,项目名称:nscumm,代码行数:39,代码来源:BigHuffmanTree.cs

示例6: Parse

        /// <summary>
        /// Parses this object out of a stream
        /// </summary>
        public void Parse(Stream input)
        {
            log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            BitStream bits = new BitStream(input);

            this._dataSize = (UInt16)bits.GetBits(16);

            if (this._dataSize > 0)
            {
                this._data = new byte[this._dataSize];
                int read = input.Read(this._data, 0, this._dataSize);
            }
        }
开发者ID:rtezli,项目名称:Blitzableiter,代码行数:17,代码来源:ImageBlock.cs

示例7: ParseFlags

        /// <summary>
        /// Parses the flags of this object out of a stream.
        /// </summary>
        /// <param name="br">The BinaryReader</param>
        /// <param name="bs">The Bitstream</param>
        private void ParseFlags(BinaryReader br, BitStream bs)
        {
            this._PlaceFlagHasClipActions = 0 != bs.GetBits(1) ? true : false;
            this._PlaceFlagHasClipDepth = 0 != bs.GetBits(1) ? true : false;
            this._PlaceFlagHasName = 0 != bs.GetBits(1) ? true : false;
            this._PlaceFlagHasRatio = 0 != bs.GetBits(1) ? true : false;
            this._PlaceFlagHasColorTransform = 0 != bs.GetBits(1) ? true : false;
            this._PlaceFlagHasMatrix = 0 != bs.GetBits(1) ? true : false;
            this._PlaceFlagHasCharacter = 0 != bs.GetBits(1) ? true : false;
            this._PlaceFlagMove = 0 != bs.GetBits(1) ? true : false;
            bs.GetBits(3); // Reserved
            this._PlaceFlagHasImage = 0 != bs.GetBits(1) ? true : false;
            this._PlaceFlagHasClassName = 0 != bs.GetBits(1) ? true : false;
            this._PlaceFlagHasCacheAsBitmap = 0 != bs.GetBits(1) ? true : false;
            this._PlaceFlagHasBlendMode = 0 != bs.GetBits(1) ? true : false;
            this._PlaceFlagHasFilterList = 0 != bs.GetBits(1) ? true : false;
            bs.Reset();

            if (!(_PlaceFlagMove || _PlaceFlagHasCharacter))
            {
                SwfFormatException e = new SwfFormatException("Object is neither a creation (PlaceFlagHasCharacter) nor an update (PlaceFlagMove).");
                Log.Error(this, e.Message);
                throw e;
            }
        }
开发者ID:rtezli,项目名称:Blitzableiter,代码行数:30,代码来源:PlaceObject3.cs

示例8: Parse

        /// <summary>
        /// Parses this object out of a stream
        /// </summary>
        protected override void Parse()
        {
            // Log.Debug(this, "Offset : " + _dataStream.Position);
            BinaryReader2 br = new BinaryReader2(this._dataStream);

            this._shapeID = br.ReadUInt16();

            this._shapeBounds.Parse(this._dataStream);
            this._edgeBounds.Parse(this._dataStream);

            BitStream bits = new BitStream(this._dataStream);

            this._reserved = (byte)bits.GetBits(5); //Reserved. Must be 0

            if (0 != this._reserved)
            {
                SwfFormatException e = new SwfFormatException(" Reserved bits has been set. ");
                Log.Warn(this, e.Message);
                //throw e;
            }

            this._usesFillWindingRule = 0 != bits.GetBits(1) ? true : false;
            this._usesNonScalingStrokes = 0 != bits.GetBits(1) ? true : false;
            this._usesScalingStrokes = 0 != bits.GetBits(1) ? true : false;

            Int64 shapesLength = this._dataStream.Length - this._dataStream.Position;
            this._shapes.Parse(this._dataStream, shapesLength, this._tag.TagType);
        }
开发者ID:rtezli,项目名称:Blitzableiter,代码行数:31,代码来源:DefineShape4.cs

示例9: Parse

        /// <summary>
        /// Parses this object out of a stream
        /// </summary>
        protected override void Parse()
        {
            //Log.Debug(this, "Offset : " + _dataStream.Position);
            BinaryReader br = new BinaryReader(this._dataStream);

            this._characterID = br.ReadUInt16();

            this._bounds.Parse(this._dataStream);

            BitStream bits = new BitStream(this._dataStream);

            this._hasText = ((0 != bits.GetBits(1)) ? true : false);
            this.Wordrap = ((0 != bits.GetBits(1)) ? true : false);
            this.MultiLine = ((0 != bits.GetBits(1)) ? true : false);
            this._password = ((0 != bits.GetBits(1)) ? true : false);
            this.ReadOnly = ((0 != bits.GetBits(1)) ? true : false);
            this._hasTextColor = ((0 != bits.GetBits(1)) ? true : false);
            this._hasMaxLength = ((0 != bits.GetBits(1)) ? true : false);
            this._hasFont = ((0 != bits.GetBits(1)) ? true : false);

            this._hasFontClass = ((0 != bits.GetBits(1)) ? true : false);
            this._autoSize = ((0 != bits.GetBits(1)) ? true : false);
            this._hasLayout = ((0 != bits.GetBits(1)) ? true : false);
            this.NoSelect = ((0 != bits.GetBits(1)) ? true : false);
            this._border = ((0 != bits.GetBits(1)) ? true : false);
            this._wasStatic = ((0 != bits.GetBits(1)) ? true : false);
            this.Html = ((0 != bits.GetBits(1)) ? true : false);
            this._hasOutlines = ((0 != bits.GetBits(1)) ? true : false);

            if (this._hasFont)
            {
                this._fontID = br.ReadUInt16();
            }
            if (this._hasFontClass)
            {
                this._fontClass = SwfStrings.SwfString(this._SwfVersion, br);
            }

            if (this._hasFont)
            {
                this._fontHeight = br.ReadUInt16();
            }
            if (this._hasTextColor)
            {
                this.TextColor.Parse(this._dataStream);
            }
            if (this._hasMaxLength)
            {
                this._maxLength = br.ReadUInt16();
            }
            if (this._hasLayout)
            {
                this._align = (Align)br.ReadByte();
                this._leftMargin = br.ReadUInt16();
                this._rightMargin = br.ReadUInt16();
                this._indent = br.ReadUInt16();
                this._leading = br.ReadInt16();
            }

            this.VariableName = SwfStrings.SwfString(this._SwfVersion, br);

            if (this._hasText)
            {
                this.InitialText = SwfStrings.SwfString(this._SwfVersion, br);
            }
        }
开发者ID:rtezli,项目名称:Blitzableiter,代码行数:69,代码来源:DefineEditText.cs

示例10: ParseFlags

        /// <summary>
        /// Parses the flags of this tag.
        /// </summary>
        /// <param name="input">The input stream where to read from.</param>
        protected virtual void ParseFlags(Stream input)
        {
            BinaryReader br = new BinaryReader(this._dataStream);
            BitStream bits = new BitStream(this._dataStream);

            base._fontID = br.ReadUInt16();

            this._fontFlagsHasLayout = 0 == bits.GetBits(1) ? false : true;
            this._fontFlagsShiftJIS = 0 == bits.GetBits(1) ? false : true;
            this._fontFlagsSmallText = 0 == bits.GetBits(1) ? false : true;
            this._fontFlagsANSI = 0 == bits.GetBits(1) ? false : true;

            this._fontFlagsWideOffsets = 0 == bits.GetBits(1) ? false : true;
            this._fontFlagsWideCodes = 0 == bits.GetBits(1) ? false : true;
            this._fontFlagsItalic = 0 == bits.GetBits(1) ? false : true;
            this._fontFlagsBold = 0 == bits.GetBits(1) ? false : true;

            if (this._SwfVersion <= 5)
            {
                br.ReadByte();
                this._languageCode = 0;
            }
            else
            {
                this._languageCode = (LangCode)br.ReadByte();
            }

            this._fontNameLen = br.ReadByte();
            this._fontName = new byte[this._fontNameLen];
            this._dataStream.Read(this._fontName, 0, this._fontNameLen);
               //Log.Debug(this, "Font name: " + Encoding.UTF8.GetString(this._fontName) + " Character ID:" + this._fontID);

            this._numberOfGlyphs = br.ReadUInt16(); // Zero for device fonts

            Int64 offsetTableOffset = this._dataStream.Position;

            if (this._dataStream.Position < this._dataStream.Length)
            {
                this._hasGlyphs = true;

                if (this._numberOfGlyphs.Equals(0))
                {
                    Log.Warn(this, "Number of glyphs is zero which means that this tag is used for a device font. For device fonts no glyph-rendering fallback is desired, but trailing data has been detected.");
                }

                if (this._fontFlagsWideOffsets)
                {
                    this._wideOffsetTable = new UInt32[this._numberOfGlyphs];

                    for (int i = 0; i < this._numberOfGlyphs; i++)
                    {
                        this._wideOffsetTable[i] = br.ReadUInt32();
                    }

                    this._wideCodeTableOffset = br.ReadUInt32();
                    Int64 realCodeTableOffset = offsetTableOffset + this._wideCodeTableOffset;

                    this._glyphShapeTable = new Shape[this._numberOfGlyphs];

                    for (int i = 0; i < this._numberOfGlyphs; i++)
                    {
                        Shape s = new Shape(this._SwfVersion);

                        if (i < this._numberOfGlyphs - 1)
                        {
                            s.Parse(this._dataStream, this._wideOffsetTable[i + 1] - this._wideOffsetTable[i], this._tag.TagType);
                            this._glyphShapeTable[i] = s;
                        }
                        else // last
                        {
                            s.Parse(this._dataStream, realCodeTableOffset - this._dataStream.Position, this._tag.TagType);
                            this._glyphShapeTable[i] = s;
                        }
                    }
                }

                else
                {
                    this._offsetTable = new UInt16[this._numberOfGlyphs];

                    for (int i = 0; i < this._numberOfGlyphs; i++)
                    {
                        this._offsetTable[i] = br.ReadUInt16();
                    }

                    this._codeTableOffset = br.ReadUInt16();
                    Int64 realCodeTableOffset = offsetTableOffset + this._codeTableOffset;

                    this._glyphShapeTable = new Shape[this._numberOfGlyphs];

                    for (int i = 0; i < this._numberOfGlyphs; i++)
                    {
                        Shape s = new Shape(this._SwfVersion);

                        if (i < this._numberOfGlyphs - 1)
                        {
//.........这里部分代码省略.........
开发者ID:rtezli,项目名称:Blitzableiter,代码行数:101,代码来源:DefineFont2.cs

示例11: Parse

        /// <summary>
        /// Parses this object out of a stream
        /// </summary>
        protected override void Parse()
        {
            BinaryReader br = new BinaryReader(this._dataStream);
            this._fontID = br.ReadUInt16();

            BitStream bits = new BitStream(this._dataStream);
            bits.GetBits(5); //reserved
            this._fontFlagsHasFontData = ((0 != bits.GetBits(1)) ? true : false);
            this._fontFlagsItalic = ((0 != bits.GetBits(1)) ? true : false);
            this._fontFlagsBold = ((0 != bits.GetBits(1)) ? true : false);
            this._fontName = SwfStrings.SwfString(this._SwfVersion, br);
            bits.Reset();

            this._restOfTheRecord = new Byte[this._dataStream.Length - this._dataStream.Position];
            this._dataStream.Read(this._restOfTheRecord, 0, this._restOfTheRecord.Length);

            // another funny statement "FontData : When present, this is an OpenType"
            // Kräht der Gockel auf dem Mist ändert sich das Wetter oder es bleibt wie es ist. XD

            //if (!this._dataStream.Position.Equals(this._dataStream.Length))// if something is present ^^
            //{
            //    this._fontData.Parse(this._dataStream);
            //}
        }
开发者ID:rtezli,项目名称:Blitzableiter,代码行数:27,代码来源:DefineFont4.cs

示例12: Parse

        protected override void Parse()
        {
            BinaryReader br = new BinaryReader(this._dataStream);
            BitStream bits = new BitStream(this._dataStream);

            ushort _reserved = (ushort)bits.GetBits(4);
            this._playbacksoundrate = DefineSound.getSoundRate(bits.GetBits(2));
            this._playbacksoundsize = (bits.GetBits(1) == 0) ? SoundSize.snd_8bit : SoundSize.snd_16bit;
            this._playbacksoundtype = (bits.GetBits(1) == 0) ? SoundType.mono : SoundType.stereo;

            this._streamsoundcompression = DefineSound.getFormat(bits.GetBits(4));
            this._streamsoundrate = DefineSound.getSoundRate(bits.GetBits(2));
            this._streamsoundsize = (bits.GetBits(1) == 0) ? SoundSize.snd_8bit : SoundSize.snd_16bit;
            this._streamsoundtype = (bits.GetBits(1) == 0) ? SoundType.mono : SoundType.stereo;

            this._streamsoundsamplecount = br.ReadUInt16();

            if (_streamsoundcompression == SoundEncoding.MP3)
                this._latencyseek = br.ReadInt16();

            if (_reserved != 0)
            {
                Exception e = new SwfFormatException("Reserved bits are set");
                Log.Warn(this, e);
            }
            String s1 = String.Format("0x{0:X08}: reading soundstreamhead. Avarage samples {1}", this.Tag.OffsetData, this.AvarageCount);
            Log.Debug(this, s1);

               String s2 = String.Format("0x{0:X08}:\tPlayback: {1} {2} {3}",
                this.Tag.OffsetData,
                this.PlaybackRate,
                this.PlaybackSize,
                this.PlaybackType);
               Log.Debug(this, s2);

               String s3 = String.Format("0x{0:X08}:\tStream:   {1} {2} {3} {4}",
                this.Tag.OffsetData,
                this.StreamCompression,
                this.StreamRate,
                this.StreamSize,
                this.StreamType);
               Log.Debug(this, s3);
        }
开发者ID:rtezli,项目名称:Blitzableiter,代码行数:43,代码来源:SoundStreamHead.cs

示例13: Parse

        public static SoundInfo Parse(System.IO.Stream input)
        {
            BinaryReader br = new BinaryReader(input);

            BitStream bits = new BitStream(input);

            SoundInfo info = new SoundInfo();

            bool _reserved1 = bits.GetBits(1) == 1;
            bool _reserved2 = bits.GetBits(1) == 1;
            info._syncstop = bits.GetBits(1) == 1;
            info._syncnomultiple = bits.GetBits(1) == 1;
            info._hasEnvelope = bits.GetBits(1) == 1;
            info._hasLoops = bits.GetBits(1) == 1;
            info._hasOutPoint = bits.GetBits(1) == 1;
            info._hasInPoint = bits.GetBits(1) == 1;

            if (_reserved1 || _reserved2)
                throw new SwfFormatException("Reserved bits are not set to false");

            if (info._hasInPoint)
                info._inPoint = br.ReadUInt32();

            if (info._hasOutPoint)
                info._outPoint = br.ReadUInt32();

            if (info._hasLoops)
                info._loopCount = br.ReadUInt16();

            if (info._hasEnvelope)
            {
                info._envelopePoints = br.ReadByte();
                info._envelopeRecords = new SoundEnvelope[info._envelopePoints];
                for (uint i = 0; i < info._envelopePoints; i++)
                    info._envelopeRecords[i] = SoundEnvelope.Parse(br);

            }

            return info;
        }
开发者ID:rtezli,项目名称:Blitzableiter,代码行数:40,代码来源:SoundInfo.cs

示例14: Parse

        /// <summary>
        /// 
        /// </summary>
        /// <param name="input"></param>
        public override void Parse( Stream input )
        {
            BinaryReader br = new BinaryReader( input );

            _MatrixX = br.ReadByte();
            _MatrixY = br.ReadByte();
            _DivisorFLOAT = br.ReadUInt32();
            _BiasFLOAT = br.ReadUInt32();
            _MatrixValues = new List<uint>();
            for ( int i = 0; i < ( _MatrixX * _MatrixY ); i++ )
            {
                UInt32 a = br.ReadUInt32();
                _MatrixValues.Add( a );
            }
            _DefaultColor = new Rgba( this.Version );
            _DefaultColor.Parse( input );
            BitStream bits = new BitStream( input );

            uint reserved = bits.GetBits( 6 );
            if ( 0 != reserved )
            {
                throw new SwfFormatException( "ConvolutionFilter uses reserved bits" );
            }

            _Clamp = ( 0 != bits.GetBits( 1 ) );
            _PreserveAlpha = ( 0 != bits.GetBits( 1 ) );
        }
开发者ID:rtezli,项目名称:Blitzableiter,代码行数:31,代码来源:ConvolutionFilter.cs

示例15: DecodeFrame

            public void DecodeFrame(Stream frame, int sectorCount)
            {
                // A frame is essentially an MPEG-1 intra frame

                var bits = new BitStream(frame, BitStreamType.SixteenBits, true, true);

                bits.Skip(16); // unknown
                bits.Skip(16); // 0x3800
                ushort scale = (ushort)bits.GetBits(16);
                ushort version = (ushort)bits.GetBits(16);

                if (version != 2 && version != 3)
                    throw new InvalidOperationException("Unknown PSX stream frame version");

                // Initalize default v3 DC here
                _lastDC[0] = _lastDC[1] = _lastDC[2] = 0;

                for (int mbX = 0; mbX < _macroBlocksW; mbX++)
                    for (int mbY = 0; mbY < _macroBlocksH; mbY++)
                        DecodeMacroBlock(bits, mbX, mbY, scale, version);

                // Output data onto the frame
                YUVToRGBManager.Convert420(_surface, LuminanceScale.ScaleFull, _yBuffer, _cbBuffer, _crBuffer, _surface.Width, _surface.Height, _macroBlocksW * 16, _macroBlocksW * 8);

                _curFrame++;

                // Increase the time by the amount of sectors we read
                // One may notice that this is still not the most precise
                // method since a frame takes up the time its sectors took
                // up instead of the amount of time it takes the next frame
                // to be read from the sectors. The actual frame rate should
                // be constant instead of variable, so the slight difference
                // in a frame's showing time is negligible (1/150 of a second).
                _nextFrameStartTime = _nextFrameStartTime.AddFrames(sectorCount);
            }
开发者ID:scemino,项目名称:nscumm,代码行数:35,代码来源:PsxStreamDecoder.Video.cs


注:本文中的BitStream.GetBits方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。