protected double ByteEntropy(TParser parser)
        {
            long currentPosition = parser.Position;

#if DEBUG
            long position = parser.Position;
#endif // DEBUG
            double entropy = 0.0;

            // Wrap the data reader
            ByteStreamDataReader byteStreamDataReader = new ByteStreamDataReader(parser);
            byteStreamDataReader.Position = this.Offset + 2;

            long[] byteValueCountArray = new long[256];
            long   endOffset           = this.Offset + this.Length;
            while (byteStreamDataReader.Position < endOffset)
            {
                byteValueCountArray[byteStreamDataReader.GetByte()]++;
            }

            for (int byteIndex = 0; byteIndex < 256; byteIndex++)
            {
                double p = byteValueCountArray[byteIndex] / (double)this.Length;
                if (p > 0.0)
                {
                    entropy += -(double)(p * Math.Log(p, 2.0));
                }
            }

            parser.Position = currentPosition;

#if DEBUG
            Debug.Assert(parser.Position == position);
#endif // DEBUG

            return(entropy);
        }
 protected ByteStreamParser(ByteStreamDataReader dataReader)
     : base(dataReader)
 {
     DataReader = dataReader;
 }