예제 #1
0
 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;
 }
예제 #2
0
 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;
 }
예제 #3
0
 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);
     }
 }
예제 #4
0
 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);
       }
 }
예제 #5
0
 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)
   {
   }
예제 #7
0
        private bool _firstMacroBlock; // if true, no macroblock has been processed for slice

        public MBTypeCABACParser(PictureParameterSet pps, SliceHeader header) : base(pps, header)
        {
            _firstMacroBlock = true;
        }
예제 #8
0
 public CodedSlicePartitionA(SequenceParameterSet sps, PictureParameterSet pps, byte idc, uint size)
     : base(sps, pps, idc, NALUnitType.SlicePartitionA, size)
 {
 }
예제 #9
0
 public CABACBaseClass(PictureParameterSet pps, SliceHeader sliceHeader)
 {
     _pps    = pps;
     _header = sliceHeader;
 }
예제 #10
0
 public CodedSliceNonIDR(SequenceParameterSet sps, PictureParameterSet pps, byte idc, uint size)
     : base(sps, pps, idc, NALUnitType.NonIDRSlice, size)
 {
 }
예제 #11
0
 public CodedSliceIDR(SequenceParameterSet sps, PictureParameterSet pps, uint size)
     : base(sps, pps, (byte)1, NALUnitType.IDRSlice, size)
 {
 }
예제 #12
0
 public CodedSlicePartitionBorC(SequenceParameterSet sps, PictureParameterSet pps,
                                byte idc, NALUnitType naluType, uint size)
     : base(sps, pps, (byte)0, NALUnitType.SlicePartitionA, size)
 {
     _pps = pps;
 }
예제 #13
0
   public CodedSlicePartitionBorC(SequenceParameterSet sps, PictureParameterSet pps,
 byte idc, NALUnitType naluType, uint size)
       : base(sps, pps, (byte)0, NALUnitType.SlicePartitionA, size)
   {
       _pps = pps;
   }
예제 #14
0
 public CodedBlockPattern(PictureParameterSet pps, SliceHeader header) : base(pps, header)
 {
 }
예제 #15
0
 public SliceHeader(SequenceParameterSet sps, PictureParameterSet pps, NetworkAbstractionLayerUnit nalu)
 {
     _nalu = nalu;
       _sps = sps;
       _pps = pps;
 }
예제 #16
0
 public SliceData(SequenceParameterSet sps, PictureParameterSet pps, SliceHeader header, NetworkAbstractionLayerUnit nalu)
     : this(sps, pps, header)
 {
     _nalu = nalu;
 }
예제 #17
0
 public CodedSliceWithoutPartition(SequenceParameterSet sps, PictureParameterSet pps,
                                   Byte idc, NALUnitType naluType, uint size)
     : base(sps, pps, idc, naluType, size)
 {
 }
예제 #18
0
        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);
            }
        }
예제 #19
0
 public H264Sample(SequenceParameterSet sps, PictureParameterSet pps, int size)
 {
     _sps       = sps;
     _pps       = pps;
     _totalSize = size;
 }
예제 #20
0
 public SliceData(SequenceParameterSet sps, PictureParameterSet pps, SliceHeader header, NetworkAbstractionLayerUnit nalu) : this(sps, pps, header)
 {
     _nalu = nalu;
 }
예제 #21
0
 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);
 }
예제 #22
0
        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;
        }
예제 #23
0
 public CodedSliceNonIDR(SequenceParameterSet sps, PictureParameterSet pps, byte idc, uint size)
     : base(sps, pps, idc, NALUnitType.NonIDRSlice, size)
 {
 }
예제 #24
0
 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);
 }
예제 #25
0
 public CodedBlockPattern(PictureParameterSet pps, SliceHeader header)
     : base(pps, header)
 {
 }
예제 #26
0
 public MBQPDelta(PictureParameterSet pps, SliceHeader header) : base(pps, header)
 {
 }
예제 #27
0
 public MBQPDelta(PictureParameterSet pps, SliceHeader header)
     : base(pps, header)
 {
 }
예제 #28
0
 public SliceHeader(SequenceParameterSet sps, PictureParameterSet pps, NetworkAbstractionLayerUnit nalu)
 {
     _nalu = nalu;
     _sps  = sps;
     _pps  = pps;
 }
예제 #29
0
 public CodedSliceIDR(SequenceParameterSet sps, PictureParameterSet pps, uint size)
     : base(sps, pps, (byte)1, NALUnitType.IDRSlice, size)
 {
 }
예제 #30
0
 public CodedSlicePartitionA(SequenceParameterSet sps, PictureParameterSet pps, byte idc, uint size)
     : base(sps, pps, idc, NALUnitType.SlicePartitionA, size)
 {
 }
예제 #31
0
 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;
 }