Пример #1
0
 public function __construct(ReadStream $inputStream, $forceThirtyTwoBitMath = false)
 {
     $decoder = new RangeDecoder($inputStream, $forceThirtyTwoBitMath);
     $model = new Order0Model();
     $this->outputStream = new WriteStream();
     while (!$inputStream->atEnd()) {
         $frequency = $decoder->getFrequency($model->getFrequencyRange());
         $symbol = 256;
         for (; $model->getLowFrequency($symbol) > $frequency; $symbol--) {
         }
         if ($symbol == 256) {
             break;
         }
         $decoder->removeRange($model->getLowFrequency($symbol), $model->getHighFrequency($symbol), $model->getFrequencyRange());
         $model->update($symbol, $decoder->getMaximumRange());
         $this->outputStream->writeInt($symbol);
     }
 }
Пример #2
0
 /**
  * depends testReadReadCharPeekAndPeekChar
  */
 public function testToString()
 {
     $stream = new ReadStream('ABC');
     $stream->read();
     $this->assertEquals((string) $stream, 'ABC');
 }