Exemple #1
0
        public void Parse(IMpeg2VideoReader reader, IResultNodeState resultState)
        {
            IPictureState pictureState = reader.State.Picture;

            resultState.Name = Name;

            // It can occur after the last slice of the previous picture or after a sequence header
            // or group of pictures header, possible followed by user data and/or extensions.
            if ((reader.State.LastHeaderName != Slice.Name) && pictureState.Initialized)
            {
                resultState.Invalidate();
                return;
            }
            if (!reader.State.Sequence.Initialized && !reader.State.SeenGop)
            {
                reader.InsertReferenceHeaderBeforeStartCode();
            }

            pictureState.Reset();
            reader.State.Slice.Reset();

            reader.GetBits(10, Attribute.TemporalReference);
            var pictureCodingType = (PictureCodingType)reader.GetBits(3, Attribute.PictureCodingType, _pictureCodingTypeResultFormatter);

            pictureState.CodingType = pictureCodingType;
            reader.GetBits(16, Attribute.VbvDelay);

            if ((pictureCodingType == PictureCodingType.PType) || (pictureCodingType == PictureCodingType.BType))
            {
                reader.GetFlag(Attribute.FullPelForwardVector);

                byte forwardFCode = (byte)reader.GetBits(3, Attribute.ForwardFCode);
                pictureState.ForwardHorizontalFCode = forwardFCode;
                pictureState.ForwardVerticalFCode   = forwardFCode;
            }
            if (pictureCodingType == PictureCodingType.BType)
            {
                reader.GetFlag(Attribute.FullPelBackwardVector);

                byte backwardFCode = (byte)reader.GetBits(3, Attribute.BackwardFCode);
                pictureState.BackwardHorizontalFCode = backwardFCode;
                pictureState.BackwardVerticalFCode   = backwardFCode;
            }

            int  count = 0;             // Sanity check
            uint maxExtraInformationLength = reader.State.Configuration.PictureHeaderMaxLengthOfExtraInformation;

            while (reader.ShowBits(1) == 1)
            {
                reader.GetBits(1);                              // ExtraBitPicture
                reader.GetBits(8);                              // ExtraInformationPicture

                if (count++ > maxExtraInformationLength)
                {
                    resultState.Invalidate();
                    return;
                }
            }
        }
        public void Parse(IMpeg2VideoReader reader, IResultNodeState resultState)
        {
            resultState.Name = Name;

            IMpeg2VideoState state = reader.State;

            // It can occur after the last slice of a picture or after a sequence header, possible followed by user data and/or extensions
            if ((state.LastHeaderName != Slice.Name) && (state.LastHeaderName != null) && (!state.Sequence.Initialized || state.SeenGop || state.Picture.Initialized))
            {
                resultState.Invalidate();
                return;
            }
            if (!reader.State.Sequence.Initialized)
            {
                reader.InsertReferenceHeaderBeforeStartCode();
            }

            state.SeenGop = true;
            state.Picture.Reset();

            reader.GetAttribute(_timeCodeAttribute);
            reader.GetFlag(Attribute.ClosedGop);
            reader.GetFlag(Attribute.BrokenLink);
        }