예제 #1
0
        private byte ReadByte(MPEGVersionFrameDescriptor frameHeader, int index)
        {
            int startPosition = frameHeader.StartIndex + frameHeader.HeaderSize + (index * PartNumber);
            byte result = 0;
            for (int i = 0; i < PartNumber; ++i)
            {
                result |= (byte)((this._fileData[startPosition + i] & 0x03) << ((PartNumber - i - 1) * 2));
            }

            return result;
        }
예제 #2
0
 private void WriteByte(MPEGVersionFrameDescriptor frameHeader, byte @byte, int index)
 {
     int startPosition = frameHeader.StartIndex + frameHeader.HeaderSize + (index * PartNumber);
     for (int i = 0; i < PartNumber; ++i)
     {
         this._fileData[startPosition + i] = (byte)((this._fileData[startPosition + i] & 0xFC) | ((@byte >> ((PartNumber - i - 1) * 2)) & 0x3));
     }
 }
예제 #3
0
        private bool TryGetNextFrame(int startIndex, out MPEGVersionFrameDescriptor frameDescriptor)
        {
            frameDescriptor = null;
            var frameStartIndex = this.GetNextFrameStartPosition(startIndex);
            bool result = frameStartIndex != -1;
            if (result)
            {
                var header = new byte[FrameHeaderSize];
                Array.Copy(this._fileData, frameStartIndex, header, 0, FrameHeaderSize);
                frameDescriptor = this._frameDescriptorBuilder.Build(header);
                frameDescriptor.StartIndex = frameStartIndex;
                return true;
            }

            return false;
        }