public MacroBlockLayer(SequenceParameterSet sps, PictureParameterSet pps, SliceHeader header, SliceData data) { _sliceType = header.SliceType; _sps = sps; _pps = pps; _header = header; _data = data; _mbTypeParser = _data.MBTypeParser; _cbp = _data.CBP; _mbQPD = _data.MBQPD; }
public SliceData(SequenceParameterSet sps, PictureParameterSet pps, SliceHeader header) { _sps = sps; _pps = pps; _header = header; if (_pps.EntropyCodingModeFlag) { MBTypeParser = new MBTypeCABACParser(_pps, header); CBP = new CodedBlockPattern(_pps, _header); MBQPD = new MBQPDelta(_pps, _header); } }
public CABACBaseClass(PictureParameterSet pps, SliceHeader sliceHeader) { _pps = pps; _header = sliceHeader; }
public CodedSliceWithoutPartition(SequenceParameterSet sps, PictureParameterSet pps, Byte idc, NALUnitType naluType, uint size) : base(sps, pps, idc, naluType, size) { }
private bool _firstMacroBlock; // if true, no macroblock has been processed for slice public MBTypeCABACParser(PictureParameterSet pps, SliceHeader header) : base(pps, header) { _firstMacroBlock = true; }
public CodedSlicePartitionA(SequenceParameterSet sps, PictureParameterSet pps, byte idc, uint size) : base(sps, pps, idc, NALUnitType.SlicePartitionA, size) { }
public CodedSliceNonIDR(SequenceParameterSet sps, PictureParameterSet pps, byte idc, uint size) : base(sps, pps, idc, NALUnitType.NonIDRSlice, size) { }
public CodedSliceIDR(SequenceParameterSet sps, PictureParameterSet pps, uint size) : base(sps, pps, (byte)1, NALUnitType.IDRSlice, size) { }
public CodedSlicePartitionBorC(SequenceParameterSet sps, PictureParameterSet pps, byte idc, NALUnitType naluType, uint size) : base(sps, pps, (byte)0, NALUnitType.SlicePartitionA, size) { _pps = pps; }
public CodedBlockPattern(PictureParameterSet pps, SliceHeader header) : base(pps, header) { }
public SliceHeader(SequenceParameterSet sps, PictureParameterSet pps, NetworkAbstractionLayerUnit nalu) { _nalu = nalu; _sps = sps; _pps = pps; }
public SliceData(SequenceParameterSet sps, PictureParameterSet pps, SliceHeader header, NetworkAbstractionLayerUnit nalu) : this(sps, pps, header) { _nalu = nalu; }
void ParseThreadProc(object buffer) { byte[] sliceBytes = buffer as byte[]; BitReader br = new BitReader(new MemoryStream(sliceBytes)); int totalSize = _totalSize; int offset = 0; int state = 0; while (totalSize > 4) { int naluLen = (int)br.GetUIntFromNBits(32); if (naluLen > totalSize) { throw new Exception("H264 parsing: wrong byte count encountered"); } if (naluLen > 0) { byte b = br.PeekByte(); byte refIDC = (byte)(b >> 5); NALUnitType naluType = (NALUnitType)(b & 0x1F); switch (state) { case 0: AccessUnitDelimiter aud = new AccessUnitDelimiter((uint)naluLen); aud.Read(br); state = 1; break; case 1: // either SEI or SPS (if it's an SEI, don't change state) if (naluType == NALUnitType.SupplementalEnhancementInfo) { SupplementatlEnhancementMessage sei = new SupplementatlEnhancementMessage(_sps, (uint)naluLen); sei.Read(br); } else if (naluType == NALUnitType.SequenceParamSet) { // replace _sps _sps = new SequenceParameterSet((uint)naluLen); _sps.Read(br); } else if (naluType == NALUnitType.PictureParamSet) { // replace _pps _pps = new PictureParameterSet((uint)naluLen); _pps.Read(br); } else if (naluType == NALUnitType.IDRSlice) { CodedSliceIDR idr = new CodedSliceIDR(_sps, _pps, (uint)naluLen); idr.Read(br); SliceType = idr.Header.SliceType; FrameNum = idr.Header.FrameNum; state = 2; // next should be zero or more redundant coded pictures } else if (naluType == NALUnitType.NonIDRSlice) { CodedSliceNonIDR nonIdr = new CodedSliceNonIDR(_sps, _pps, GetIDC(refIDC), (uint)naluLen); nonIdr.Read(br); SliceType = nonIdr.Header.SliceType; FrameNum = nonIdr.Header.FrameNum; state = 2; // next should be zero or more redundant coded pictures } else if (naluType == NALUnitType.SlicePartitionA) { CodedSlicePartitionA partA = new CodedSlicePartitionA(_sps, _pps, GetIDC(refIDC), (uint)naluLen); partA.Read(br); SliceType = partA.Header.SliceType; FrameNum = partA.Header.FrameNum; state = 2; // next should be zero or more redundant coded pictures } else if ((naluType == NALUnitType.SlicePartitionB) || (naluType == NALUnitType.SlicePartitionC)) { CodedSlicePartitionBorC partBC = new CodedSlicePartitionBorC(_sps, _pps, GetIDC(refIDC), naluType, (uint)naluLen); partBC.Read(br); // FIXME: check that SliceType and FrameNum are set at this point state = 2; // next should be zero or more redundant coded pictures } break; case 2: // either coded picture or end of sequence break; default: break; } offset += naluLen; totalSize -= (naluLen + 4); } else { naluLen = 0; // debugging break point } } if (SampleDoneEvent != null) { SampleDoneEvent(this); } }
public H264Sample(SequenceParameterSet sps, PictureParameterSet pps, int size) { _sps = sps; _pps = pps; _totalSize = size; }
public CodedSliceBase(SequenceParameterSet sps, PictureParameterSet pps, Byte idc, NALUnitType naluType, uint size) { Nalu = new NetworkAbstractionLayerUnit(idc, naluType, size); Header = new SliceHeader(sps, pps, Nalu); Data = new SliceData(sps, pps, Header, Nalu); }
private bool _firstMacroBlock; // if true, no macroblock has been processed for slice #endregion Fields #region Constructors public MBTypeCABACParser(PictureParameterSet pps, SliceHeader header) : base(pps, header) { _firstMacroBlock = true; }
public MBQPDelta(PictureParameterSet pps, SliceHeader header) : base(pps, header) { }
private PictureParameterSet ParsePPS(byte[] data) { PictureParameterSet pps = new PictureParameterSet((uint)data.Length); H264.BitReader bitReader = new H264.BitReader(new MemoryStream(data)); pps.Read(bitReader); bitReader.Close(); return pps; }