public void Parse(IMpeg2VideoReader reader, IResultNodeState resultState) { resultState.Name = Name; ScalableMode scalableMode = (ScalableMode)reader.GetBits(2, Attribute.ScalableMode, _scalableModeResultFormatter); reader.State.Sequence.ScalableMode = scalableMode; reader.GetBits(4, Attribute.LayerID); if (scalableMode == ScalableMode.SpatialScalability) { reader.GetBits(14, Attribute.LowerLayerPredictionHorizontalSize); reader.GetMarker(); reader.GetBits(14, Attribute.LowerLayerPredictionVerticalSize); reader.GetBits(5, Attribute.HorizontalSubsamplingFactorM); reader.GetBits(5, Attribute.HorizontalSubsamplingFactorN); reader.GetBits(5, Attribute.VerticalSubsamplingFactorM); reader.GetBits(5, Attribute.VerticalSubsamplingFactorN); } if (scalableMode == ScalableMode.TemporalScalability) { if (reader.GetFlag(Attribute.PictureMuxEnable)) { reader.GetFlag(Attribute.MuxToProgressiveSequence); } reader.GetBits(3, Attribute.PictureMuxOrder); reader.GetBits(3, Attribute.PictureMuxFactor); } }
public int Load(byte[] buffer, int startIndex, int bufferLength) { // If less than 10 bytes are available for processing then the header and following start code // can't be read. if ((bufferLength - startIndex) < 10) { return(0); } int index = startIndex + 4; extensionStartCodeIdentifier = buffer[index] >> 4; scalableMode = (ScalableMode)((buffer[index++] & 0xC0) >> 2); layerId = (Read16(buffer, index++) & 0x03C0) >> 6; if (scalableMode == ScalableMode.SpatialScalability) { if ((bufferLength - startIndex) < 15) { return(0); } lowerLayerPredictionHorizontalSize = Read16(buffer, index += 2) & 0x3FFF; lowerLayerPredictionVerticalSize = (Read16(buffer, index++) & 0x7FFE) >> 1; horizontalSubsamplingFactorM = (Read16(buffer, index++) & 0x01F0) >> 4; horizontalSubsamplingFactorN = (Read16(buffer, index++) & 0x0F80) >> 7; verticalSubsamplingFactorM = (buffer[index] & 0x7C) >> 6; verticalSubsamplingFactorN = (Read16(buffer, index) & 0x03E0) >> 5; } if (scalableMode == ScalableMode.TemporalScalability) { pictureMuxEnable = (buffer[index] & 0x20) >> 5; if (pictureMuxEnable == 1) { muxToProgressiveSequence = (buffer[index] & 0x10) >> 4; pictureMuxOrder = (buffer[index] & 0x0E) >> 1; pictureMuxFactor = (Read16(buffer, index) & 0x01C0) >> 6; } else { pictureMuxOrder = (buffer[index] & 0x1C) >> 2; pictureMuxFactor = (Read16(buffer, index) & 0x0380) >> 7; } } index++; while (index < (bufferLength - 4)) { if ((Read32(buffer, index) >> 8) == 1) { return(index - startIndex); } index++; } return(0); }