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