Ejemplo n.º 1
0
        private PictureHeader readHeader(MemoryStream buffer)
        {
            PictureHeader ph = null;
            MemoryStream  segment;
            MemoryStream  fork = buffer.duplicate();

            while ((segment = MPEGUtil.nextSegment(fork)) != null)
            {
                int code = segment.getInt() & 0xff;
                if (code == MPEGConst.SEQUENCE_HEADER_CODE)
                {
                    SequenceHeader newSh = SequenceHeader.read(segment);
                    if (sh != null)
                    {
                        newSh.copyExtensions(sh);
                    }
                    sh = newSh;
                }
                else if (code == MPEGConst.GROUP_START_CODE)
                {
                    gh = GOPHeader.read(segment);
                }
                else if (code == MPEGConst.PICTURE_START_CODE)
                {
                    ph = PictureHeader.read(segment);
                }
                else if (code == MPEGConst.EXTENSION_START_CODE)
                {
                    int extType = segment.get(4) >> 4;
                    if (extType == SequenceHeader.Sequence_Extension || extType == SequenceHeader.Sequence_Scalable_Extension ||
                        extType == SequenceHeader.Sequence_Display_Extension)
                    {
                        SequenceHeader.readExtension(segment, sh);
                    }
                    else
                    {
                        PictureHeader.readExtension(segment, ph, sh);
                    }
                }
                else if (code == MPEGConst.USER_DATA_START_CODE)
                {
                    // do nothing
                }
                else
                {
                    break;
                }
                buffer.position(fork.position());
            }
            return(ph);
        }
Ejemplo n.º 2
0
 public MPEGDecoder(SequenceHeader sh, GOPHeader gh, string name, Media.Common.Binary.ByteOrder byteOrder, int defaultComponentCount, int defaultBitsPerComponent)
     : this(name, byteOrder, defaultComponentCount, defaultBitsPerComponent)
 {
     this.sh = sh;
     this.gh = gh;
 }